12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Traffic gener<strong>at</strong>orsApplic<strong>at</strong>ion/Traffic/ExponentialSimul<strong>at</strong>ed applic<strong>at</strong>io<strong>ns</strong>Applic<strong>at</strong>ion/FTPAPIAPIAgent/UDPAgent/TCP/FullTcp38.2 <strong>The</strong> tra<strong>ns</strong>port agent APIFigure 38.1: Example of Applic<strong>at</strong>ion CompositionIn real-world systems, applic<strong>at</strong>io<strong>ns</strong> typically access network services through an applic<strong>at</strong>io<strong>ns</strong> programming interface (API).<strong>The</strong> most popular of these APIs is known as “sockets.” In <strong>ns</strong>, we mimic the behavior of the sockets API through a setof well-defined API functio<strong>ns</strong>. <strong>The</strong>se functio<strong>ns</strong> are then mapped to the appropri<strong>at</strong>e internal agent functio<strong>ns</strong> (e.g., a call tosend(numBytes) causes TCP to increment its “send buffer” by a corresponding number of bytes).This section describes how agents <strong>and</strong> applic<strong>at</strong>io<strong>ns</strong> are hooked together <strong>and</strong> communic<strong>at</strong>e with one another via the API.38.2.1 Attaching tra<strong>ns</strong>port agents to nodesThis step is typically done <strong>at</strong> OTcl level. Agent management was also briefly discussed in Section 5.2.set src [new Agent/TCP/FullTcp]set sink [new Agent/TCP/FullTcp]$<strong>ns</strong>_ <strong>at</strong>tach-agent $node_(s1) $src$<strong>ns</strong>_ <strong>at</strong>tach-agent $node_(k1) $sink$<strong>ns</strong>_ connect $src $sink<strong>The</strong> above code illustr<strong>at</strong>es th<strong>at</strong> in <strong>ns</strong>, agents are first <strong>at</strong>tached to a node via <strong>at</strong>tach-agent. Next, the connect i<strong>ns</strong>tprocsets each agent’s destin<strong>at</strong>ion target to the other. Note th<strong>at</strong>, in <strong>ns</strong>, connect() has different semantics than in regular sockets.In <strong>ns</strong>, connect() simply establishes the destin<strong>at</strong>ion address for an agent, but does not set up the connection. As a result,the overlying applic<strong>at</strong>ion does not need to know its peer’s address. For TCPs th<strong>at</strong> exchange SYN segments, the first call tosend() will trigger the SYN exchange.To detach an agent from a node, the i<strong>ns</strong>tproc detach-agent can be used; this resets the target for the agent to a null agent.332

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!