20.2 The diffusion model in ns

The directed diffusion model consists of a core diffusion layer, a diffusion library provides an application programming interface for overlying diffusion applications and finally the application layer which includes both diffusion applications and filters. The core diffusion layer is used to receive/send out packets from/into the network. The library provides a interface for the overlying application classes for publishing/subscribing etc. These APIs have been described in details in a document called Network Routing API 8.0 and can be found at http://www.isi.edu/scadds/publications.html under APIs section. In the following paragraphs we are going to describe how the diffusion model looks like in ns.

First we start with a brief description of the diffusion3 directory structure. If the reader wishes to examine the C++ code related to NS Diffusion that underpins the OTcl script commands, it may be found in ~ns/ns/diffustion3. Here is a summary by subdirectory:

apps
contains sample source and sink applications like gear, ping and rmst.
lib
has DiffusionRouting class definitions and definitions of diffusion application class. In addition there are sub-dirs called main and nr. main houses misc diffusion utility code. nr includes attribute definition and the class NR which is an abstract factory for the API (so that either ISI or MIT implementations may derive from it.

ns
contains ns wrappers for diffusion code. These wrapper classes allow the core diffusion code and the diffusion API to be seamlessly incorporated into the NS class hierarchy. The DiffRoutingAgent is a wrapper for the Core Diffusion code, and DiffAppAgent is a wrapper for the DiffusionRouting (API) code.

filter_core
has the core diffusion agent.

filters
holds the different filters supported by diffusion implementation including two-phase-pull, one-phase-pull, gear, rmst, log, tag and srcrt (as of 10/03/03).

Figure 20.1: Message flow in directed diffusion
\includegraphics{filter}

The above Figure 20.1 is from SCADDS' network routing API document available from their homepage (URL given earlier). The document describes attribute factories, matching rules for attributes, how applications interface with the core diffusion layer, and filter/timer APIs. All messages coming from/going out in the network is received at/sent out from the core diffusion layer. Messages can also come to core-diffusion layer from local applications and/or filters that might be connected to the node. The applications use the publish/subscribe/send interface to send interest and data messages to the network.

The core diffusion agent and diffusion application agent are attached to two well-known ports defined in ~ns//tcl/lib/ns-default.tcl. Diffusion applications attached to the node call the underlying diffusion application agent for publishing/subscribing/sending data.

Tom Henderson 2011-11-05