next up previous contents index
Next: 31.2.2 Attaching applications to Up: 31.2 The transport agent Previous: 31.2 The transport agent

   
31.2.1 Attaching transport agents to nodes

This step is typically done at OTcl level. Agent management was also briefly discussed in Section 5.2.

        set src [new Agent/TCP/FullTcp]
        set sink [new Agent/TCP/FullTcp]
        \$ns\_ attach-agent \$node\_(s1) \$src
        \$ns\_ attach-agent \$node\_(k1) \$sink
        \$ns\_ connect \$src \$sink

The above code illustrates that in , agents are first attached to a node via attach-agent. Next, the connect instproc sets each agent's destination target to the other. Note that, in , connect() has different semantics than in regular sockets. In , connect() simply establishes the destination address for an agent, but does not set up the connection. As a result, the overlying application does not need to know its peer's address. For TCPs that exchange SYN segments, the first call to send() will trigger the SYN exchange.

To detach an agent from a node, the instproc detach-agent can be used; this resets the target for the agent to a null agent.




2000-08-24