--- a/src/aodv/test/bug-772.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/aodv/test/bug-772.cc Tue Feb 16 15:22:36 2016 -0800 @@ -81,6 +81,9 @@ RngSeedManager::SetSeed (12345); RngSeedManager::SetRun (7); + // Traces are based on initial sequence number of zero + Config::SetDefault ("ns3::TcpL4Protocol::IsnRandomVariable", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); + CreateNodes (); CreateDevices (); --- a/src/internet/model/tcp-l4-protocol.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/model/tcp-l4-protocol.cc Tue Feb 16 15:22:36 2016 -0800 @@ -29,6 +29,9 @@ #include "ns3/simulator.h" #include "ns3/ipv4-route.h" #include "ns3/ipv6-route.h" +#include "ns3/random-variable-stream.h" +#include "ns3/string.h" +#include "ns3/pointer.h" #include "tcp-l4-protocol.h" #include "tcp-header.h" @@ -83,6 +86,11 @@ ObjectVectorValue (), MakeObjectVectorAccessor (&TcpL4Protocol::m_sockets), MakeObjectVectorChecker ()) + .AddAttribute ("IsnRandomVariable", + "Random variable used to generate an initial sequence number.", + StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=4294967295.0]"), + MakePointerAccessor (&TcpL4Protocol::m_isnGenerator), + MakePointerChecker ()) ; return tid; } @@ -99,6 +107,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 +206,7 @@ socket->SetTcp (this); socket->SetRtt (rtt); socket->SetCongestionControlAlgorithm (algo); + socket->SetInitialSequence (m_isnGenerator->GetInteger ()); m_sockets.push_back (socket); return socket; @@ -697,6 +714,7 @@ ++it; } + socket->SetInitialSequence (m_isnGenerator->GetInteger ()); 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 Tue Feb 16 15:22:36 2016 -0800 @@ -40,6 +40,7 @@ class TcpSocketBase; class Ipv4EndPoint; class Ipv6EndPoint; +class RandomVariableStream; /** * \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 Tue Feb 16 15:22:36 2016 -0800 @@ -269,8 +269,8 @@ m_node (0), m_tcp (0), m_rtt (0), - m_nextTxSequence (0), // Change this for non-zero initial sequence number - m_highTxMark (0), + m_nextTxSequence (0), // Can be changed with SetInitialSequence () + m_highTxMark (0), // Should track the m_nextTxSequence initialization m_state (CLOSED), m_errno (ERROR_NOTERROR), m_closeNotified (false), @@ -291,7 +291,7 @@ m_timestampEnabled (true), m_timestampToEcho (0), m_sendPendingDataEvent (), - m_recover (0), // Set to the initial sequence number + m_recover (0), // Should track the m_nextTxSequence initialization m_retxThresh (3), m_limitedTx (false), m_congestionControl (0), @@ -447,6 +447,16 @@ 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; + m_recover = initialSequence; + m_highTxMark = 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 Tue Feb 16 15:22:36 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 */ --- a/src/internet/test/tcp-fast-retr-test.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/test/tcp-fast-retr-test.cc Tue Feb 16 15:22:36 2016 -0800 @@ -20,6 +20,8 @@ #include "tcp-fast-retr-test.h" #include "ns3/tcp-westwood.h" #include "ns3/node.h" +#include "ns3/config.h" +#include "ns3/string.h" namespace ns3 { @@ -40,6 +42,12 @@ { } +void +TcpFastRetrTest::DoSetup (void) +{ + Config::SetDefault ("ns3::TcpL4Protocol::IsnRandomVariable", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); +} + Ptr TcpFastRetrTest::CreateSenderErrorModel () { --- a/src/internet/test/tcp-fast-retr-test.h Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/test/tcp-fast-retr-test.h Tue Feb 16 15:22:36 2016 -0800 @@ -60,6 +60,10 @@ void PktDropped (const Ipv4Header &ipH, const TcpHeader& tcpH); void FinalChecks (); +private: + virtual void DoSetup (void); + +protected: bool m_pktDropped; bool m_pktWasDropped; uint32_t m_seqToKill; --- a/src/internet/test/tcp-rto-test.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/test/tcp-rto-test.cc Tue Feb 16 15:22:36 2016 -0800 @@ -21,6 +21,8 @@ #include "ns3/node.h" #include "ns3/log.h" +#include "ns3/config.h" +#include "ns3/string.h" #include "ns3/tcp-westwood.h" namespace ns3 { @@ -35,6 +37,12 @@ { } +void +TcpRtoTest::DoSetup (void) +{ + Config::SetDefault ("ns3::TcpL4Protocol::IsnRandomVariable", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); +} + Ptr TcpRtoTest::CreateSenderSocket (Ptr node) { --- a/src/internet/test/tcp-rto-test.h Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/test/tcp-rto-test.h Tue Feb 16 15:22:36 2016 -0800 @@ -49,6 +49,8 @@ virtual void FinalChecks (); private: + virtual void DoSetup (void); + bool m_rtoExpired; bool m_segmentReceived; }; --- a/src/internet/test/tcp-zero-window-test.cc Tue Feb 09 19:29:52 2016 +0300 +++ a/src/internet/test/tcp-zero-window-test.cc Tue Feb 16 15:22:36 2016 -0800 @@ -20,7 +20,9 @@ #include "tcp-general-test.h" #include "tcp-error-model.h" #include "ns3/node.h" +#include "ns3/config.h" #include "ns3/log.h" +#include "ns3/string.h" namespace ns3 { @@ -43,6 +45,8 @@ void FinalChecks (); void IncreaseBufSize (); +private: + virtual void DoSetup (void); protected: EventId m_receivePktEvent; @@ -63,6 +67,12 @@ } void +TcpZeroWindowTest::DoSetup (void) +{ + Config::SetDefault ("ns3::TcpL4Protocol::IsnRandomVariable", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); +} + +void TcpZeroWindowTest::IncreaseBufSize () { SetRcvBufSize (RECEIVER, 2500);