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.