next up previous contents index
Next: 27.2 Commands at a Up: 27. UDP Agents Previous: 27. UDP Agents

   
27.1 UDP Agents

UDP agents are implemented in udp.{cc, h}. A UDP agent accepts data in variable size chunks from an application, and segments the data if needed. UDP packets also contain a monotonically increasing sequence number and an RTP timestamp. Although real UDP packets do not contain sequence numbers or timestamps, this sequence number does not incur any simulated overhead, and can be useful for tracefile analysis or for simulating UDP-based applications.

The default maximum segment size (MSS) for UDP agents is 1000 byte:

Agent/UDP set packetSize_   1000              # max segment size;
This OTcl instvar is bound to the C++ agent variable size_.

Applications can access UDP agents via the []sendmsg function in C++, or via the send or sendmsg methods in OTcl, as described in section 31.2.3.

The following is a simple example of how a UDP agent may be used in a program. In the example, the CBR traffic generator is started at time 1.0, at which time the generator begins to periodically call the UDP agent []sendmsg function.

        set ns [new Simulator]
        set n0 [$ns node]
        set n1 [$ns node]
        $ns duplex-link $n0 $n1 5Mb 2ms DropTail

        set udp0 [new Agent/UDP]
        $ns attach-agent $n0 $udp0
        set cbr0 [new Application/Traffic/CBR]
        $cbr0 attach-agent $udp0
        $udp0 set packetSize_ 536	# set MSS to 536 bytes;

        set null0 [new Agent/Null]
        $ns attach-agent $n1 $null0
        $ns connect $udp0 $null0
        $ns at 1.0 "$cbr0 start"




2000-08-24