A Discrete-Event Network Simulator
API
TcpTestCase Class Reference

TCP Test - send string data from client to server and back. More...

+ Inheritance diagram for TcpTestCase:
+ Collaboration diagram for TcpTestCase:

Public Member Functions

 TcpTestCase (uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t sourceReadSize, uint32_t serverWriteSize, uint32_t serverReadSize, bool useIpv6)
 Constructor. More...
 
- Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 
virtual ~TestCase ()
 Destructor. More...
 
std::string GetName (void) const
 
TestCaseoperator= (const TestCase &)=delete
 

Private Member Functions

Ptr< SimpleNetDeviceAddSimpleNetDevice (Ptr< Node > node, const char *ipaddr, const char *netmask)
 Add a SimpleNetDevice to a node (IPv4 version). More...
 
Ptr< SimpleNetDeviceAddSimpleNetDevice6 (Ptr< Node > node, Ipv6Address ipaddr, Ipv6Prefix prefix)
 Add a SimpleNetDevice to a node (IPv6 version). More...
 
Ptr< NodeCreateInternetNode (void)
 Create a node with the Internet stack (IPv4 version). More...
 
Ptr< NodeCreateInternetNode6 (void)
 Create a node with the Internet stack (IPv6 version). More...
 
virtual void DoRun (void)
 Implementation to actually run this TestCase. More...
 
virtual void DoTeardown (void)
 Implementation to do any local setup required for this TestCase. More...
 
void ServerHandleConnectionCreated (Ptr< Socket > s, const Address &addr)
 Server: Handle connection created. More...
 
void ServerHandleRecv (Ptr< Socket > sock)
 Server: Receive data. More...
 
void ServerHandleSend (Ptr< Socket > sock, uint32_t available)
 Server: Send data. More...
 
void SetupDefaultSim (void)
 Setup the test (IPv4 version). More...
 
void SetupDefaultSim6 (void)
 Setup the test (IPv6 version). More...
 
void SourceHandleRecv (Ptr< Socket > sock)
 Client: Receive data. More...
 
void SourceHandleSend (Ptr< Socket > sock, uint32_t available)
 Client: Send data. More...
 

Private Attributes

uint32_t m_currentServerRxBytes
 Server Tx bytes. More...
 
uint32_t m_currentServerTxBytes
 Server Rx bytes. More...
 
uint32_t m_currentSourceRxBytes
 Client Rx bytes. More...
 
uint32_t m_currentSourceTxBytes
 Client Tx bytes. More...
 
uint32_t m_serverReadSize
 Server data size when receiving. More...
 
uint8_t * m_serverRxPayload
 Server Rx payload. More...
 
uint32_t m_serverWriteSize
 Server data size when sending. More...
 
uint32_t m_sourceReadSize
 Client data size when receiving. More...
 
uint8_t * m_sourceRxPayload
 Client Rx payload. More...
 
uint8_t * m_sourceTxPayload
 Client Tx payload. More...
 
uint32_t m_sourceWriteSize
 Client data size when sending. More...
 
uint32_t m_totalBytes
 Total stream size (in bytes). More...
 
bool m_useIpv6
 Use IPv6 instead of IPv4. 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

TCP Test - send string data from client to server and back.

Definition at line 61 of file tcp-test.cc.

Constructor & Destructor Documentation

◆ TcpTestCase()

TcpTestCase::TcpTestCase ( uint32_t  totalStreamSize,
uint32_t  sourceWriteSize,
uint32_t  sourceReadSize,
uint32_t  serverWriteSize,
uint32_t  serverReadSize,
bool  useIpv6 
)

Constructor.

Parameters
totalStreamSizeTotal stream size (in bytes).
sourceWriteSizeClient data size when sending.
sourceReadSizeClient data size when receiving.
serverWriteSizeServer data size when sending.
serverReadSizeServer data size when receiving.
useIpv6Use IPv6 instead of IPv4.

Definition at line 187 of file tcp-test.cc.

Member Function Documentation

◆ AddSimpleNetDevice()

Ptr< SimpleNetDevice > TcpTestCase::AddSimpleNetDevice ( Ptr< Node node,
const char *  ipaddr,
const char *  netmask 
)
private

Add a SimpleNetDevice to a node (IPv4 version).

Parameters
nodeThe target node.
ipaddrthe SimpleNetDevice IPv4 address.
netmaskthe SimpleNetDevice IPv4 address netmask.
Returns
The new SimpleNetDevice.

Definition at line 373 of file tcp-test.cc.

References ns3::Node::AddDevice(), and ns3::Object::GetObject().

Referenced by SetupDefaultSim().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddSimpleNetDevice6()

Ptr< SimpleNetDevice > TcpTestCase::AddSimpleNetDevice6 ( Ptr< Node node,
Ipv6Address  ipaddr,
Ipv6Prefix  prefix 
)
private

Add a SimpleNetDevice to a node (IPv6 version).

Parameters
nodeThe target node.
ipaddrthe SimpleNetDevice IPv6 address.
prefixthe SimpleNetDevice IP6 address prefix.
Returns
The new SimpleNetDevice.

Definition at line 509 of file tcp-test.cc.

References ns3::Node::AddDevice(), and ns3::Object::GetObject().

Referenced by SetupDefaultSim6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateInternetNode()

Ptr< Node > TcpTestCase::CreateInternetNode ( void  )
private

Create a node with the Internet stack (IPv4 version).

Returns
The new node.

Definition at line 342 of file tcp-test.cc.

References ns3::Object::AggregateObject().

Referenced by SetupDefaultSim().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateInternetNode6()

Ptr< Node > TcpTestCase::CreateInternetNode6 ( void  )
private

Create a node with the Internet stack (IPv6 version).

Returns
The new node.

Definition at line 479 of file tcp-test.cc.

References ns3::Object::AggregateObject().

Referenced by SetupDefaultSim6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoRun()

void TcpTestCase::DoRun ( void  )
privatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 210 of file tcp-test.cc.

References m_currentServerRxBytes, m_currentServerTxBytes, m_currentSourceRxBytes, m_currentSourceTxBytes, m_serverRxPayload, m_sourceRxPayload, m_sourceTxPayload, m_totalBytes, m_useIpv6, NS_TEST_EXPECT_MSG_EQ, SetupDefaultSim(), and SetupDefaultSim6().

+ Here is the call graph for this function:

◆ DoTeardown()

void TcpTestCase::DoTeardown ( void  )
privatevirtual

Implementation to do any local setup required for this TestCase.

Subclasses should override this method to perform any costly per-test teardown

Reimplemented from ns3::TestCase.

Definition at line 247 of file tcp-test.cc.

References m_serverRxPayload, m_sourceRxPayload, and m_sourceTxPayload.

◆ ServerHandleConnectionCreated()

void TcpTestCase::ServerHandleConnectionCreated ( Ptr< Socket s,
const Address addr 
)
private

Server: Handle connection created.

Parameters
sThe socket.
addrThe other party address.

Definition at line 256 of file tcp-test.cc.

References ns3::MakeCallback(), ServerHandleRecv(), ServerHandleSend(), ns3::Socket::SetRecvCallback(), and ns3::Socket::SetSendCallback().

Referenced by SetupDefaultSim(), and SetupDefaultSim6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ServerHandleRecv()

void TcpTestCase::ServerHandleRecv ( Ptr< Socket sock)
private

Server: Receive data.

Parameters
sockThe socket.

Definition at line 263 of file tcp-test.cc.

References ns3::Packet::CopyData(), ns3::Socket::GetErrno(), ns3::Socket::GetRxAvailable(), ns3::Packet::GetSize(), GetString(), ns3::Socket::GetTxAvailable(), m_currentServerRxBytes, m_serverReadSize, m_serverRxPayload, m_totalBytes, min, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, ns3::Socket::Recv(), and ServerHandleSend().

Referenced by ServerHandleConnectionCreated().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ServerHandleSend()

void TcpTestCase::ServerHandleSend ( Ptr< Socket sock,
uint32_t  available 
)
private

Server: Send data.

Parameters
sockThe socket.
availableUnused in the test.

Definition at line 283 of file tcp-test.cc.

References ns3::Socket::Close(), GetString(), ns3::Socket::GetTxAvailable(), m_currentServerRxBytes, m_currentServerTxBytes, m_serverRxPayload, m_serverWriteSize, m_totalBytes, min, NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, and ns3::Socket::Send().

Referenced by ServerHandleConnectionCreated(), and ServerHandleRecv().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetupDefaultSim()

void TcpTestCase::SetupDefaultSim ( void  )
private

◆ SetupDefaultSim6()

void TcpTestCase::SetupDefaultSim6 ( void  )
private

◆ SourceHandleRecv()

void TcpTestCase::SourceHandleRecv ( Ptr< Socket sock)
private

Client: Receive data.

Parameters
sockThe socket.

Definition at line 319 of file tcp-test.cc.

References ns3::Socket::Close(), ns3::Packet::CopyData(), ns3::Socket::GetErrno(), ns3::Socket::GetRxAvailable(), ns3::Packet::GetSize(), GetString(), m_currentSourceRxBytes, m_sourceReadSize, m_sourceRxPayload, m_totalBytes, min, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, and ns3::Socket::Recv().

Referenced by SetupDefaultSim(), and SetupDefaultSim6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SourceHandleSend()

void TcpTestCase::SourceHandleSend ( Ptr< Socket sock,
uint32_t  available 
)
private

Client: Send data.

Parameters
sockThe socket.
availableUnused in the test.

Definition at line 303 of file tcp-test.cc.

References GetString(), ns3::Socket::GetTxAvailable(), m_currentSourceTxBytes, m_sourceTxPayload, m_sourceWriteSize, m_totalBytes, min, NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, and ns3::Socket::Send().

Referenced by SetupDefaultSim(), and SetupDefaultSim6().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_currentServerRxBytes

uint32_t TcpTestCase::m_currentServerRxBytes
private

Server Tx bytes.

Definition at line 157 of file tcp-test.cc.

Referenced by DoRun(), ServerHandleRecv(), and ServerHandleSend().

◆ m_currentServerTxBytes

uint32_t TcpTestCase::m_currentServerTxBytes
private

Server Rx bytes.

Definition at line 158 of file tcp-test.cc.

Referenced by DoRun(), and ServerHandleSend().

◆ m_currentSourceRxBytes

uint32_t TcpTestCase::m_currentSourceRxBytes
private

Client Rx bytes.

Definition at line 156 of file tcp-test.cc.

Referenced by DoRun(), and SourceHandleRecv().

◆ m_currentSourceTxBytes

uint32_t TcpTestCase::m_currentSourceTxBytes
private

Client Tx bytes.

Definition at line 155 of file tcp-test.cc.

Referenced by DoRun(), and SourceHandleSend().

◆ m_serverReadSize

uint32_t TcpTestCase::m_serverReadSize
private

Server data size when receiving.

Definition at line 154 of file tcp-test.cc.

Referenced by ServerHandleRecv().

◆ m_serverRxPayload

uint8_t* TcpTestCase::m_serverRxPayload
private

Server Rx payload.

Definition at line 161 of file tcp-test.cc.

Referenced by DoRun(), DoTeardown(), ServerHandleRecv(), and ServerHandleSend().

◆ m_serverWriteSize

uint32_t TcpTestCase::m_serverWriteSize
private

Server data size when sending.

Definition at line 153 of file tcp-test.cc.

Referenced by ServerHandleSend().

◆ m_sourceReadSize

uint32_t TcpTestCase::m_sourceReadSize
private

Client data size when receiving.

Definition at line 152 of file tcp-test.cc.

Referenced by SourceHandleRecv().

◆ m_sourceRxPayload

uint8_t* TcpTestCase::m_sourceRxPayload
private

Client Rx payload.

Definition at line 160 of file tcp-test.cc.

Referenced by DoRun(), DoTeardown(), and SourceHandleRecv().

◆ m_sourceTxPayload

uint8_t* TcpTestCase::m_sourceTxPayload
private

Client Tx payload.

Definition at line 159 of file tcp-test.cc.

Referenced by DoRun(), DoTeardown(), and SourceHandleSend().

◆ m_sourceWriteSize

uint32_t TcpTestCase::m_sourceWriteSize
private

Client data size when sending.

Definition at line 151 of file tcp-test.cc.

Referenced by SourceHandleSend().

◆ m_totalBytes

uint32_t TcpTestCase::m_totalBytes
private

Total stream size (in bytes).

Definition at line 150 of file tcp-test.cc.

Referenced by DoRun(), ServerHandleRecv(), ServerHandleSend(), SourceHandleRecv(), and SourceHandleSend().

◆ m_useIpv6

bool TcpTestCase::m_useIpv6
private

Use IPv6 instead of IPv4.

Definition at line 163 of file tcp-test.cc.

Referenced by DoRun().


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