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.

Chapter 33UDP Agents33.1 UDP AgentsUDP agents are implemented in udp.{cc, h}. A UDP agent accepts d<strong>at</strong>a in variable size chunks from an applic<strong>at</strong>ion,<strong>and</strong> segments the d<strong>at</strong>a if needed. UDP packets also contain a monotonically increasing sequence number <strong>and</strong> an RTP timestamp.Although real UDP packets do not contain sequence numbers or timestamps, this sequence number does not incur anysimul<strong>at</strong>ed overhead, <strong>and</strong> can be useful for tracefile analysis or for simul<strong>at</strong>ing UDP-based applic<strong>at</strong>io<strong>ns</strong>.<strong>The</strong> default maximum segment size (MSS) for UDP agents is 1000 byte:Agent/UDP set packetSize_ 1000 ;# max segment sizeThis OTcl i<strong>ns</strong>tvar is bound to the C++ agent variable size_.Applic<strong>at</strong>io<strong>ns</strong> can access UDP agents via the sendmsg() function in C++, or via the send or sendmsg methods in OTcl, asdescribed in section 38.2.3.<strong>The</strong> following is a simple example of how a UDP agent may be used in a program. In the example, the CBR traffic gener<strong>at</strong>oris started <strong>at</strong> time 1.0, <strong>at</strong> which time the gener<strong>at</strong>or begi<strong>ns</strong> to periodically call the UDP agent sendmsg() function.set <strong>ns</strong> [new Simul<strong>at</strong>or]set n0 [$<strong>ns</strong> node]set n1 [$<strong>ns</strong> node]$<strong>ns</strong> duplex-link $n0 $n1 5Mb 2ms DropTailset udp0 [new Agent/UDP]$<strong>ns</strong> <strong>at</strong>tach-agent $n0 $udp0set cbr0 [new Applic<strong>at</strong>ion/Traffic/CBR]$cbr0 <strong>at</strong>tach-agent $udp0$udp0 set packetSize_ 536;# set MSS to 536 bytesset null0 [new Agent/Null]$<strong>ns</strong> <strong>at</strong>tach-agent $n1 $null0$<strong>ns</strong> connect $udp0 $null0$<strong>ns</strong> <strong>at</strong> 1.0 "$cbr0 start"286

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

Saved successfully!

Ooh no, something went wrong!