--- a/src/internet/model/tcp-l4-protocol.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/model/tcp-l4-protocol.cc Mon Feb 15 09:45:55 2016 -0800 @@ -18,6 +18,8 @@ * Author: Raj Bhattacharjea */ +#define __STDC_LIMIT_MACROS +#include #include "ns3/assert.h" #include "ns3/log.h" #include "ns3/nstime.h" @@ -29,6 +31,7 @@ #include "ns3/simulator.h" #include "ns3/ipv4-route.h" #include "ns3/ipv6-route.h" +#include "ns3/random-variable-stream.h" #include "tcp-l4-protocol.h" #include "tcp-header.h" @@ -92,6 +95,7 @@ { NS_LOG_FUNCTION_NOARGS (); NS_LOG_LOGIC ("Made a TcpL4Protocol " << this); + m_isnGenerator = CreateObject (); } TcpL4Protocol::~TcpL4Protocol () @@ -99,6 +103,14 @@ NS_LOG_FUNCTION (this); } +int64_t +TcpL4Protocol::AssignStreams (int64_t stream) +{ + NS_LOG_FUNCTION (this << stream); + m_isnGenerator->SetStream (stream); + return 1; +} + void TcpL4Protocol::SetNode (Ptr node) { @@ -190,6 +202,7 @@ socket->SetTcp (this); socket->SetRtt (rtt); socket->SetCongestionControlAlgorithm (algo); + socket->SetInitialSequence (m_isnGenerator->GetInteger (0, UINT32_MAX)); m_sockets.push_back (socket); return socket; @@ -697,6 +710,7 @@ ++it; } + socket->SetInitialSequence (m_isnGenerator->GetInteger (0, UINT32_MAX)); m_sockets.push_back (socket); } --- a/src/internet/model/tcp-l4-protocol.h Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/model/tcp-l4-protocol.h Mon Feb 15 09:45:55 2016 -0800 @@ -40,6 +40,7 @@ class TcpSocketBase; class Ipv4EndPoint; class Ipv6EndPoint; +class UniformRandomVariable; /** * \ingroup tcp @@ -210,6 +211,16 @@ */ void DeAllocate (Ipv6EndPoint *endPoint); + /** + * Assign a fixed random variable stream number to the random variables + * used by this model. Return the number of streams (possibly zero) that + * have been assigned. + * + * \param stream first stream index to use + * \return the number of stream indices assigned by this model + */ + int64_t AssignStreams (int64_t stream); + // From IpL4Protocol virtual enum IpL4Protocol::RxStatus Receive (Ptr p, Ipv4Header const &incomingIpHeader, @@ -281,6 +292,7 @@ Ptr m_node; //!< the node this stack is associated with Ipv4EndPointDemux *m_endPoints; //!< A list of IPv4 end points. Ipv6EndPointDemux *m_endPoints6; //!< A list of IPv6 end points. + Ptr m_isnGenerator; //! Generate TCP initial seq no TypeId m_rttTypeId; //!< The RTT Estimator TypeId TypeId m_congestionTypeId; //!< The socket TypeId std::vector > m_sockets; //!< list of sockets --- a/src/internet/model/tcp-socket-base.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/model/tcp-socket-base.cc Mon Feb 15 09:45:55 2016 -0800 @@ -447,6 +447,14 @@ m_tcp = tcp; } +void +TcpSocketBase::SetInitialSequence (uint32_t initialSequence) +{ + NS_LOG_FUNCTION (this << initialSequence); + NS_ABORT_MSG_IF (m_state > LISTEN, "cannot set initial sequence number on socket with state " << m_state); + m_nextTxSequence = initialSequence; +} + /* Set an RTT estimator with this socket */ void TcpSocketBase::SetRtt (Ptr rtt) --- a/src/internet/model/tcp-socket-base.h Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/model/tcp-socket-base.h Mon Feb 15 09:45:55 2016 -0800 @@ -285,6 +285,15 @@ virtual void SetTcp (Ptr tcp); /** + * \brief Set TCP initial sequence number + * \param initialSequence the value to set + * + * This method will error exit the simulation if the socket state is + * not equal to CLOSED or LISTEN + */ + virtual void SetInitialSequence (uint32_t initialSequence); + + /** * \brief Set the associated RTT estimator. * \param rtt the RTT estimator */