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

The following member functions are also defined by the class Agent, but are intended to be over-ridden by classes derivingfrom Agent:void timeout(timeout number)void recv(Packet*, Handler*)subclass-specific time out methodreceiving agent main receive pathThe allocpkt() method is used by derived classes to create packets to send. The function fills in the following fields inthe common packet header (Section 12): uid, ptype, size, and the following fields in the IP header: src, dst,flowid, prio, ttl. It also zero-fills in the following fields of the Flags header: ecn, pri, usr1, usr2. Anypacket header information not included in these lists must be must be handled in the classes derived from Agent.The recv() method is the main entry point for an Agent which receives packets, and is invoked by upstream nodes whensending a packet. In most cases, Agents make no use of the second argument (the handler defined by upstream nodes).10.3 Protocol AgentsThere are several agents supported in the simulator. These are their names in OTcl:TCPTCP/RenoTCP/NewrenoTCP/Sack1TCP/FackTCP/FullTcpTCP/VegasTCP/Vegas/RBPTCP/Vegas/RBPTCP/AsymTCP/Reno/AsymTCP/Newreno/AsymTCPSinkTCPSink/DelAckTCPSink/AsymTCPSink/Sack1TCPSink/Sack1/DelAcka “Tahoe” TCP sender (cwnd = 1 on any loss)a “Reno” TCP sender (with fast recovery)a modified Reno TCP sender (changes fast recovery)a SACK TCP sendera “forward” SACK sender TCPa more full-functioned TCP with 2-way traffica “Vegas” TCP sendera Vegas TCP with “rate based pacing”a Reno TCP with “rate based pacing”an experimental Tahoe TCP for asymmetric linksan experimental Reno TCP for asymmetric linksan experimental Newreno TCP for asymmetric linksa Reno or Tahoe TCP receiver (not used for FullTcp)a TCP delayed-ACK receiveran experimental TCP sink for asymmetric linksa SACK TCP receivera delayed-ACK SACK TCP receiverUDPa basic UDP agentRTPRTCPan RTP sender and receiveran RTCP sender and receiverLossMonitora packet sink which checks for lossesIVS/SourceIVS/Receiveran IVS sourcean IVS receiver97

CtrMcast/EncapCtrMcast/DecapMessageMessage/PruneSRMSRM/AdaptiveTapNullrtProto/DVa “centralised multicast” encapsulatora “centralised multicast” de-encapsulatora protocol to carry textual messagesprocesses multicast routing prune messagesan SRM agent with non-adaptive timersan SRM agent with adaptive timersinterfaces the simulator to a live networka degenerate agent which discards packetsdistance-vector routing protocol agentAgents are used in the implementation of protocols at various layers. Thus, for some transport protocols (e.g. UDP) thedistribution of packet sizes and/or inter-departure times may be dictated by some separate object representing the demandsof an application. To this end, agents expose an application programming interface (API) to the application. For agents usedin the implementation of lower-layer protocols (e.g. routing agents), size and departure timing is generally dictated by theagent’s own processing of protocol messages.10.4 OTcl LinkageAgents may be created within OTcl and an agent’s internal state can be modified by use of Tcl’s set function and any Tclfunctions an Agent (or its base classes) implements. Note that some of an Agent’s internal state may exist only within OTcl,and is thus is not directly accessible from C++.10.4.1 Creating and Manipulating AgentsThe following example illustrates the creation and modification of an Agent in OTcl:set newtcp [new Agent/TCP];# create new object (and C++ shadow object)$newtcp set window_ 20 ;# sets the tcp agent’s window to 20$newtcp target $dest;# target is implemented in Connector class$newtcp set portID_ 1;# exists only in OTcl, not in C++10.4.2 Default ValuesDefault values for member variables, those visible in OTcl only and those linked between OTcl and C++ with bind areinitialized in the ~ns/tcl/lib/ns-default.tcl file. For example, Agent is initialized as follows:Agent set fid_ 0Agent set prio_ 0Agent set addr_ 098

CtrMcast/EncapCtrMcast/DecapMessageMessage/PruneSRMSRM/AdaptiveTapNullrtProto/DVa “centralised multicast” encapsul<strong>at</strong>ora “centralised multicast” de-encapsul<strong>at</strong>ora protocol to carry textual messagesprocesses multicast routing prune messagesan SRM agent with non-adaptive timersan SRM agent with adaptive timersinterfaces the simul<strong>at</strong>or to a live networka degener<strong>at</strong>e agent which discards packetsdistance-vector routing protocol agentAgents are used in the implement<strong>at</strong>ion of protocols <strong>at</strong> various layers. Thus, for some tra<strong>ns</strong>port protocols (e.g. UDP) thedistribution of packet sizes <strong>and</strong>/or inter-departure times may be dict<strong>at</strong>ed by some separ<strong>at</strong>e object representing the dem<strong>and</strong>sof an applic<strong>at</strong>ion. To this end, agents expose an applic<strong>at</strong>ion programming interface (API) to the applic<strong>at</strong>ion. For agents usedin the implement<strong>at</strong>ion of lower-layer protocols (e.g. routing agents), size <strong>and</strong> departure timing is generally dict<strong>at</strong>ed by theagent’s own processing of protocol messages.10.4 OTcl LinkageAgents may be cre<strong>at</strong>ed within OTcl <strong>and</strong> an agent’s internal st<strong>at</strong>e can be modified by use of Tcl’s set function <strong>and</strong> any Tclfunctio<strong>ns</strong> an Agent (or its base classes) implements. Note th<strong>at</strong> some of an Agent’s internal st<strong>at</strong>e may exist only within OTcl,<strong>and</strong> is thus is not directly accessible from C++.10.4.1 Cre<strong>at</strong>ing <strong>and</strong> Manipul<strong>at</strong>ing Agents<strong>The</strong> following example illustr<strong>at</strong>es the cre<strong>at</strong>ion <strong>and</strong> modific<strong>at</strong>ion of an Agent in OTcl:set newtcp [new Agent/TCP];# cre<strong>at</strong>e new object (<strong>and</strong> C++ shadow object)$newtcp set window_ 20 ;# sets the tcp agent’s window to 20$newtcp target $dest;# target is implemented in Connector class$newtcp set portID_ 1;# exists only in OTcl, not in C++10.4.2 Default ValuesDefault values for member variables, those visible in OTcl only <strong>and</strong> those linked between OTcl <strong>and</strong> C++ with bind areinitialized in the ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-default.tcl file. For example, Agent is initialized as follows:Agent set fid_ 0Agent set prio_ 0Agent set addr_ 098

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

Saved successfully!

Ooh no, something went wrong!