12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

lh_firstnameobj‘‘name’’ is the name of the structure containing the list head‘‘lh_first’’ is a pointer of type *obj, initialized to NULL‘‘lh_next’’ is a pointer of type *obj‘‘lh_prev’’ (of type **obj) is a pointer to the previous lh_nextobjobjlh_nextlh_prevlh_nextlh_prevlh_nextlh_prevNULLFigure 17.4: Linked list implement<strong>at</strong>ion in <strong>ns</strong>.17.3.1 Use of linked lists<strong>The</strong>re are a number of linked lists used heavily in the implement<strong>at</strong>ion:• class Node maintai<strong>ns</strong> a (st<strong>at</strong>ic) list of all objects of class Node in the simul<strong>at</strong>or. <strong>The</strong> variable Node::nodehead_stores the head of the list. <strong>The</strong> linked list of nodes is used for centralized routing, for finding s<strong>at</strong>ellites to h<strong>and</strong> off to,<strong>and</strong> for tracing.• class Node maintai<strong>ns</strong> a list of all (s<strong>at</strong>ellite) links on the node. Specifically, the list is a list of objects of classLinkHead. <strong>The</strong> variable linklisthead_ stores the head of the list. <strong>The</strong> linked list of LinkHeads is used forchecking whether or not to h<strong>and</strong>off links, <strong>and</strong> to discover topology adjacencies.• class Channel maintai<strong>ns</strong> a list of all objects of class Phy on the channel. <strong>The</strong> head of the list is stored in thevariable if_head_. This list is used to determine the set of interfaces on a channel th<strong>at</strong> should receive a copy of apacket.Figure 17.4 provides a schem<strong>at</strong>ic of how the linked list is organized. Each object in the list is linked through a “LINK_ENTRY”th<strong>at</strong> is a protected member of the class. This entry contai<strong>ns</strong> a pointer to the next item in the list <strong>and</strong> also a pointer to the addressof the previous “next” pointer in the preceding object. Various macros found in ~<strong>ns</strong>/list.h can be used to manipul<strong>at</strong>e the list;the implement<strong>at</strong>ion of linked-lists in <strong>ns</strong> is similar to the queue implement<strong>at</strong>ion found in some variants of BSD UNIX.17.3.2 Node structureFigure 17.5 is a schem<strong>at</strong>ic of the main components of a S<strong>at</strong>Node. <strong>The</strong> structure bears resemblance to the MobileNode inthe wireless exte<strong>ns</strong>io<strong>ns</strong>, but there are several differences. Like all <strong>ns</strong> nodes, the S<strong>at</strong>Node has an “entry” point to a series ofclassifiers. <strong>The</strong> address classifier contai<strong>ns</strong> a slot table for forwarding packets to foreign nodes, but since OTcl routing is notused, all packets not destined for this node (<strong>and</strong> hence forwarded to the port classifier), are sent to the default target, whichpoints to a routing agent. Packets destined on the node for port 255 are classified as routing packets <strong>and</strong> are also forwarded tothe routing agent.Each node contai<strong>ns</strong> one or more “network stacks” th<strong>at</strong> include a generic S<strong>at</strong>LinkHead <strong>at</strong> the entry point of the link. <strong>The</strong>S<strong>at</strong>LinkHead is intended to serve as an API to get <strong>at</strong> other objects in the link structure, so it contai<strong>ns</strong> a number of pointers(although the API here has not been finalized). Packets leaving the network stack are sent to the node’s entry. An importantfe<strong>at</strong>ure is th<strong>at</strong> each packet leaving a network stack has its iface_ field in the common packet header coded with the uniqueNetworkInterface index corresponding to the link. This value can be used to support distributed routing as describedbelow.<strong>The</strong> base class routing agent is class S<strong>at</strong>RouteAgent; it can be used in conjunction with centralized routing. S<strong>at</strong>RouteAgentscontain a forwarding table th<strong>at</strong> resolves a packet’s address to a particular LinkHead target– it is the job of the S<strong>at</strong>RouteObject182

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!