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 ...

nmlab.korea.ac.kr
from nmlab.korea.ac.kr More from this publisher
12.07.2015 Views

are computed at different times (while propagation delays are continuously changing). This effect can be seen bytoggling this parameter in the Iridium example script ~ns/tcl/ex/sat-iridium.tcl.• In the trace file, when a packet is dropped due to “no route to host” (such as when there is a topology change), the tracelooks a bit different depending on whether wiredRouting is turned OFF or ON. In the former case, there is one line perdrop, with the destination labelled as “-2”. In the latter case, there are three events (enque “+”, deque “-”, and drop “d”)corresponding to the same packet, and the destination is shown as “-1”.• In rare cases, there may be warning messages during the execution indicating “node out of range.” This can occur if anode becomes disconnected in the topology and then another node tries to send a packet to it. For example, try enablingwiredRouting in the file ~ns/tcl/ex/sat-mixed.tcl. This occurs because the routing table is dynamically sized upontopology change, and if a node becomes disconnected it may not have any entries inserted in the routing table (andhence the routing table is not grown to accommodate its node number). This warning should not affect actual traceoutput.• There has been no attempt to interoperate with wireless or mobile-IP code.17.2.10 Example scriptsExample scripts can be found in the ~ns/tcl/ex directory, including:• sat-mixed.tcl A simulation with a mixture of polar and geostationary satellites.• sat-wired.tcl Similar to the previous script, but shows how to connect wired nodes to a satellite simulation.• sat-repeater.tcl Demonstrates the use of a simple bent-pipe geostationary satellite, and also error models.• sat-aloha.tcl Simulates one hundred terminals in a mesh-VSAT configuration using an unslotted Aloha MACprotocol with a “bent-pipe” geostationary satellite. Terminals listen to their own transmissions (after a delay), and ifthey do not successfully receive their own packet within a timeout interval, they perform exponential backoff and thenretransmit the packet. Three variants exist: basic, basic_tracing, and poisson. These variants are describedfurther in the header comments of the script.• sat-iridium.tcl Simulates a broadband LEO constellation with parameters similar to that of the Iridium constellation(with supporting scripts sat-iridium-links.tcl, sat-iridium-linkswithcross.tcl, andsat-iridium-nodes.tcl).• sat-teledesic.tcl Simulates a broadband LEO constellation with parameters similar to those proposed for the288 satellite Teledesic constellation (with supporting scripts sat-teledesic-links.tcl and sat-teledesic-nodes.tclIn addition, there is a test suite script that tries to exercise a lot of features simultaneously, it can be found at ~ns/tcl/test/testsuite-sat.tcl.17.3 ImplementationThe code for the implementation of satellite extensions can be found in ~ns/{sat.h, sathandoff.{cc,h}, satlink.{cc,h}, satnode.{cc,h},satposition.{cc,h}, satroute.{cc,h}, sattrace.{cc,h}}, and ~ns/tcl/lib/ns-sat.tcl. Almost all of the mechanism isimplemented in C++.In this section, we focus on some of the key components of the implementation; namely, the use of linked lists, the nodestructure, and a detailed look at the satellite link structure.181

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 implementation in ns.17.3.1 Use of linked listsThere are a number of linked lists used heavily in the implementation:• class Node maintains a (static) list of all objects of class Node in the simulator. The variable Node::nodehead_stores the head of the list. The linked list of nodes is used for centralized routing, for finding satellites to hand off to,and for tracing.• class Node maintains a list of all (satellite) links on the node. Specifically, the list is a list of objects of classLinkHead. The variable linklisthead_ stores the head of the list. The linked list of LinkHeads is used forchecking whether or not to handoff links, and to discover topology adjacencies.• class Channel maintains a list of all objects of class Phy on the channel. The head of the list is stored in thevariable if_head_. This list is used to determine the set of interfaces on a channel that should receive a copy of apacket.Figure 17.4 provides a schematic of how the linked list is organized. Each object in the list is linked through a “LINK_ENTRY”that is a protected member of the class. This entry contains a pointer to the next item in the list and also a pointer to the addressof the previous “next” pointer in the preceding object. Various macros found in ~ns/list.h can be used to manipulate the list;the implementation of linked-lists in ns is similar to the queue implementation found in some variants of BSD UNIX.17.3.2 Node structureFigure 17.5 is a schematic of the main components of a SatNode. The structure bears resemblance to the MobileNode inthe wireless extensions, but there are several differences. Like all ns nodes, the SatNode has an “entry” point to a series ofclassifiers. The address classifier contains a slot table for forwarding packets to foreign nodes, but since OTcl routing is notused, all packets not destined for this node (and 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 and are also forwarded tothe routing agent.Each node contains one or more “network stacks” that include a generic SatLinkHead at the entry point of the link. TheSatLinkHead is intended to serve as an API to get at other objects in the link structure, so it contains 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 importantfeature is that 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.The base class routing agent is class SatRouteAgent; it can be used in conjunction with centralized routing. SatRouteAgentscontain a forwarding table that resolves a packet’s address to a particular LinkHead target– it is the job of the SatRouteObject182

are computed <strong>at</strong> different times (while propag<strong>at</strong>ion delays are continuously changing). This effect can be seen bytoggling this parameter in the Iridium example script ~<strong>ns</strong>/tcl/ex/s<strong>at</strong>-iridium.tcl.• In the trace file, when a packet is dropped due to “no route to host” (such as when there is a topology change), the tracelooks a bit different depending on whether wiredRouting is turned OFF or ON. In the former case, there is one line perdrop, with the destin<strong>at</strong>ion labelled as “-2”. In the l<strong>at</strong>ter case, there are three events (enque “+”, deque “-”, <strong>and</strong> drop “d”)corresponding to the same packet, <strong>and</strong> the destin<strong>at</strong>ion is shown as “-1”.• In rare cases, there may be warning messages during the execution indic<strong>at</strong>ing “node out of range.” This can occur if anode becomes disconnected in the topology <strong>and</strong> then another node tries to send a packet to it. For example, try enablingwiredRouting in the file ~<strong>ns</strong>/tcl/ex/s<strong>at</strong>-mixed.tcl. This occurs because the routing table is dynamically sized upontopology change, <strong>and</strong> if a node becomes disconnected it may not have any entries i<strong>ns</strong>erted in the routing table (<strong>and</strong>hence the routing table is not grown to accommod<strong>at</strong>e its node number). This warning should not affect actual traceoutput.• <strong>The</strong>re has been no <strong>at</strong>tempt to interoper<strong>at</strong>e with wireless or mobile-IP code.17.2.10 Example scriptsExample scripts can be found in the ~<strong>ns</strong>/tcl/ex directory, including:• s<strong>at</strong>-mixed.tcl A simul<strong>at</strong>ion with a mixture of polar <strong>and</strong> geost<strong>at</strong>ionary s<strong>at</strong>ellites.• s<strong>at</strong>-wired.tcl Similar to the previous script, but shows how to connect wired nodes to a s<strong>at</strong>ellite simul<strong>at</strong>ion.• s<strong>at</strong>-repe<strong>at</strong>er.tcl Demo<strong>ns</strong>tr<strong>at</strong>es the use of a simple bent-pipe geost<strong>at</strong>ionary s<strong>at</strong>ellite, <strong>and</strong> also error models.• s<strong>at</strong>-aloha.tcl Simul<strong>at</strong>es one hundred terminals in a mesh-VSAT configur<strong>at</strong>ion using an u<strong>ns</strong>lotted Aloha MACprotocol with a “bent-pipe” geost<strong>at</strong>ionary s<strong>at</strong>ellite. Terminals listen to their own tra<strong>ns</strong>missio<strong>ns</strong> (after a delay), <strong>and</strong> ifthey do not successfully receive their own packet within a timeout interval, they perform exponential backoff <strong>and</strong> thenretra<strong>ns</strong>mit the packet. Three variants exist: basic, basic_tracing, <strong>and</strong> poisson. <strong>The</strong>se variants are describedfurther in the header comments of the script.• s<strong>at</strong>-iridium.tcl Simul<strong>at</strong>es a broadb<strong>and</strong> LEO co<strong>ns</strong>tell<strong>at</strong>ion with parameters similar to th<strong>at</strong> of the Iridium co<strong>ns</strong>tell<strong>at</strong>ion(with supporting scripts s<strong>at</strong>-iridium-links.tcl, s<strong>at</strong>-iridium-linkswithcross.tcl, <strong>and</strong>s<strong>at</strong>-iridium-nodes.tcl).• s<strong>at</strong>-teledesic.tcl Simul<strong>at</strong>es a broadb<strong>and</strong> LEO co<strong>ns</strong>tell<strong>at</strong>ion with parameters similar to those proposed for the288 s<strong>at</strong>ellite Teledesic co<strong>ns</strong>tell<strong>at</strong>ion (with supporting scripts s<strong>at</strong>-teledesic-links.tcl <strong>and</strong> s<strong>at</strong>-teledesic-nodes.tclIn addition, there is a test suite script th<strong>at</strong> tries to exercise a lot of fe<strong>at</strong>ures simultaneously, it can be found <strong>at</strong> ~<strong>ns</strong>/tcl/test/testsuite-s<strong>at</strong>.tcl.17.3 Implement<strong>at</strong>ion<strong>The</strong> code for the implement<strong>at</strong>ion of s<strong>at</strong>ellite exte<strong>ns</strong>io<strong>ns</strong> can be found in ~<strong>ns</strong>/{s<strong>at</strong>.h, s<strong>at</strong>h<strong>and</strong>off.{cc,h}, s<strong>at</strong>link.{cc,h}, s<strong>at</strong>node.{cc,h},s<strong>at</strong>position.{cc,h}, s<strong>at</strong>route.{cc,h}, s<strong>at</strong>trace.{cc,h}}, <strong>and</strong> ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-s<strong>at</strong>.tcl. Almost all of the mechanism isimplemented in C++.In this section, we focus on some of the key components of the implement<strong>at</strong>ion; namely, the use of linked lists, the nodestructure, <strong>and</strong> a detailed look <strong>at</strong> the s<strong>at</strong>ellite link structure.181

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

Saved successfully!

Ooh no, something went wrong!