next up previous contents index
Next: 9.7 The Agent API Up: 9.6 Creating a New Previous: 9.6.3 Linking the ``ping''

   
9.6.4 Using the agent through OTcl

The agent we have created will have to be instantiated and attached to a node. Note that a node and simulator object is assumed to have already been created. The following OTcl code performs these functions:

        set echoagent [new Agent/ECHO]
        $simulator attach-agent $node $echoagent
To set the interval and packet size, and start packet generation, the following OTcl code is executed:
        $echoagent set dst_ $dest
        $echoagent set fid_ 0
        $echoagent set prio_ 0
        $echoagent set flags_ 0
        $echoagent set interval_ 1.5
        $echoagent set packetSize_ 1024
        $echoagent start
This will cause our agent to generate one 1024-byte packet destined for node $dest every 1.5 seconds.




2000-08-24