next up previous contents index
Next: 28. TCP Agents Up: 27. UDP Agents Previous: 27.1 UDP Agents

27.2 Commands at a glance

The following commands are used to setup UDP agents in simulation scripts:

set udp0 [new Agent/UDP]
This creates an instance of the UDP agent.

$ns_ attach-agent node agent
This is a common command used to attach any <agent> to a given <node>.

$traffic-gen attach-agent agent
This a class Application/Traffic/<traffictype> method which connects the traffic generator to the given <agent>. For example, if we want to setup a CBR traffic flow for the udp agent, udp1, we given the following commands

set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1

$ns_ connect src-agent dst-agent
This command sets up an end-to-end connection between two agents (at the transport layer).

$udp set packetSize_ \
$udp set dst_addr_ \
$udp set dst_port_ \
$udp set class_ \
$udp set ttl_ \
..... etc

The above are different parameter values that may be set as shown above for udp agents. The default values can be found in /tcl/lib/ns-default.tcl.

For a typical example of setting up an UDP agent used in a simulation, see the above section 27.1.