[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ns-3 contains a port of the TCP model from GTNetS. This model is a full TCP, in that it is bidirectional and attempts to model the connection setup and close logic. In fact, it is a more complete implementation of the TCP state machine than ns-2's "FullTcp" model. This TCP model was originally written by George Riley as part of GTNetS and ported to ns-3 by Raj Bhattacharjea.
The implementation of TCP is contained in the following files:
src/internet-stack/tcp-header.{cc,h} src/internet-stack/tcp-l4-protocol.{cc,h} src/internet-stack/tcp-socket-factory-impl.{cc,h} src/internet-stack/tcp-socket-impl.{cc,h} src/internet-stack/tcp-typedefs.h src/internet-stack/rtt-estimator.{cc,h} src/internet-stack/sequence-number.{cc,h}
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file examples/tcp-star-server.cc
contains an example that
makes use of ns3::OnOffApplication
and ns3::PacketSink
applications.
Using the helper functions defined in src/helper
, here is how
one would create a TCP receiver:
// Create a packet sink on the star "hub" to receive these packets uint16_t port = 50000; Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port)); PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress); ApplicationContainer sinkApp = sinkHelper.Install (serverNode); sinkApp.Start (Seconds (1.0)); sinkApp.Stop (Seconds (10.0));
Similarly, the below snippet configures OnOffApplication traffic source to use TCP:
// Create the OnOff applications to send TCP to the server OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
The careful reader will note above that we have specified the TypeId
of an abstract base class TcpSocketFactory
. How does the
script tell ns-3 that it wants the native ns-3 TCP vs. some other one?
Well, when internet stacks are added to the node, the default
TCP implementation that is aggregated to the node is the ns-3 TCP.
This can be overridden as we show below when using Network
Simulation Cradle. So, by default, when using the ns-3 helper API,
the TCP that is aggregated to nodes with an Internet stack is the
native ns-3 TCP.
Once a TCP socket is created, you will want to follow conventional socket logic and either connect() and send() (for a TCP client) or bind(), listen(), and accept() (for a TCP server). See section Sockets API for a review of how sockets are used in ns-3.
To configure behavior of TCP, a number of parameters are exported through
the ns-3 attribute system. These are documented in the
Doxygen
for class TcpSocket
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated on April, 2 2009 using texi2html 1.78.