A Discrete-Event Network Simulator
API
Public Member Functions | Private Attributes | List of all members
TcpEndPointBug2211Test Class Reference

Test for bug 2211. More...

+ Inheritance diagram for TcpEndPointBug2211Test:

Public Member Functions

 TcpEndPointBug2211Test (std::string desc, bool ipVersion)
 Constructor. More...
 
virtual void DoRun ()
 Implementation to actually run this TestCase. More...
 
void HandleAccept (Ptr< Socket > s, const Address &from)
 Handle an incoming connection. More...
 
void HandleConnect (Ptr< Socket > socket)
 Handle a connection establishment. More...
 
void Recv (Ptr< Socket > socket)
 Receive a packet. More...
 
- Public Member Functions inherited from ns3::TestCase
virtual ~TestCase ()
 Destructor. More...
 
std::string GetName (void) const
 

Private Attributes

bool m_v6
 True to use IPv6. More...
 

Additional Inherited Members

- Public Types inherited from ns3::TestCase
enum  TestDuration { QUICK = 1, EXTENSIVE = 2, TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
 
- Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor. More...
 
void AddTestCase (TestCase *testCase, TestDuration duration=QUICK)
 Add an individual child TestCase to this test suite. More...
 
TestCaseGetParent () const
 Get the parent of this TestCsse. More...
 
bool IsStatusFailure (void) const
 Check if any tests failed. More...
 
bool IsStatusSuccess (void) const
 Check if all tests passed. More...
 
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found. More...
 
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 Log the failure of this TestCase. More...
 
bool MustAssertOnFailure (void) const
 Check if this run should assert on failure. More...
 
bool MustContinueOnFailure (void) const
 Check if this run should continue on failure. More...
 
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory. More...
 
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory. More...
 

Detailed Description

Test for bug 2211.

https://www.nsnam.org/bugzilla/show_bug.cgi?id=2211

NOTE: It is a valgrind testcase, it contains no ASSERTs.

Test creates one node and sets up two TCP sockets on the loopback with default parameters: CWND = 1, MTU = 536. Sender socket sends 3 segments. When first segment is acknowledged, cwnd is raised to 2. Then, two segments are sent and arrive into receive buffer. Until bugfix, the following happened: Ipv4EndPoint::ForwardUp was called for both second and third segment. These calls scheduled two Ipv4EndPoint::DoForwardUp events. To demonstrate the bug, test case closes the receiver socket after receiving the second segment. As a result, Ipv4EndPoint is destroyed. However, Ipv4EndPoint::DoForwardUp is already scheduled for third segment. It is a use-after-free bug.

Definition at line 52 of file tcp-endpoint-bug2211.cc.

Constructor & Destructor Documentation

◆ TcpEndPointBug2211Test()

TcpEndPointBug2211Test::TcpEndPointBug2211Test ( std::string  desc,
bool  ipVersion 
)

Constructor.

Parameters
descTest description.
ipVersionTrue to use IPv6.

Definition at line 107 of file tcp-endpoint-bug2211.cc.

References m_v6.

Member Function Documentation

◆ DoRun()

void TcpEndPointBug2211Test::DoRun ( )
virtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 113 of file tcp-endpoint-bug2211.cc.

References ns3::Socket::Bind(), ns3::Socket::Connect(), HandleAccept(), HandleConnect(), ns3::InternetStackHelper::Install(), m_v6, ns3::MakeCallback(), ns3::MakeNullCallback(), ns3::Socket::SetConnectCallback(), and sink.

◆ HandleAccept()

void TcpEndPointBug2211Test::HandleAccept ( Ptr< Socket s,
const Address from 
)

Handle an incoming connection.

Parameters
sThe receiving socket.
fromThe other node IP address.

Definition at line 93 of file tcp-endpoint-bug2211.cc.

References ns3::MakeCallback(), Recv(), and ns3::Socket::SetRecvCallback().

Referenced by DoRun().

◆ HandleConnect()

void TcpEndPointBug2211Test::HandleConnect ( Ptr< Socket socket)

Handle a connection establishment.

Parameters
socketThe receiving socket.

Definition at line 99 of file tcp-endpoint-bug2211.cc.

References ns3::Socket::Close(), and ns3::Socket::Send().

Referenced by DoRun().

◆ Recv()

void TcpEndPointBug2211Test::Recv ( Ptr< Socket socket)

Receive a packet.

Parameters
socketThe receiving socket.

Definition at line 84 of file tcp-endpoint-bug2211.cc.

References ns3::Socket::Close(), and ns3::Socket::GetRxAvailable().

Referenced by HandleAccept().

Member Data Documentation

◆ m_v6

bool TcpEndPointBug2211Test::m_v6
private

True to use IPv6.

Definition at line 80 of file tcp-endpoint-bug2211.cc.

Referenced by DoRun(), and TcpEndPointBug2211Test().


The documentation for this class was generated from the following file: