A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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.
 
- Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 
virtual ~TestCase ()
 Destructor.
 
std::string GetName () 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).
 
Ptr< SimpleNetDeviceAddSimpleNetDevice6 (Ptr< Node > node, Ipv6Address ipaddr, Ipv6Prefix prefix)
 Add a SimpleNetDevice to a node (IPv6 version).
 
Ptr< NodeCreateInternetNode ()
 Create a node with the Internet stack (IPv4 version).
 
Ptr< NodeCreateInternetNode6 ()
 Create a node with the Internet stack (IPv6 version).
 
void DoRun () override
 Implementation to actually run this TestCase.
 
void DoTeardown () override
 Implementation to do any local setup required for this TestCase.
 
void ServerHandleConnectionCreated (Ptr< Socket > s, const Address &addr)
 Server: Handle connection created.
 
void ServerHandleRecv (Ptr< Socket > sock)
 Server: Receive data.
 
void ServerHandleSend (Ptr< Socket > sock, uint32_t available)
 Server: Send data.
 
void SetupDefaultSim ()
 Setup the test (IPv4 version).
 
void SetupDefaultSim6 ()
 Setup the test (IPv6 version).
 
void SourceHandleRecv (Ptr< Socket > sock)
 Client: Receive data.
 
void SourceHandleSend (Ptr< Socket > sock, uint32_t available)
 Client: Send data.
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from ns3::TestCase
enum class  Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
 
- Static Public Attributes inherited from ns3::TestCase
static constexpr auto QUICK = Duration::QUICK
 Deprecated test duration simple enums.
 
static constexpr auto EXTENSIVE = Duration::EXTENSIVE
 
static constexpr auto TAKES_FOREVER = Duration::TAKES_FOREVER
 
- Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor.
 
void AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK)
 Add an individual child TestCase to this test suite.
 
TestCaseGetParent () const
 Get the parent of this TestCase.
 
bool IsStatusFailure () const
 Check if any tests failed.
 
bool IsStatusSuccess () const
 Check if all tests passed.
 
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found.
 
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.
 
bool MustAssertOnFailure () const
 Check if this run should assert on failure.
 
bool MustContinueOnFailure () const
 Check if this run should continue on failure.
 
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory.
 
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory.
 

Detailed Description

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

Definition at line 47 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 178 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 369 of file tcp-test.cc.

References ns3::Mac48Address::Allocate(), ns3::Mac48Address::ConvertFrom(), and ns3::CreateObject().

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 513 of file tcp-test.cc.

References ns3::Mac48Address::Allocate(), ns3::Mac48Address::ConvertFrom(), and ns3::CreateObject().

Referenced by SetupDefaultSim6().

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

◆ CreateInternetNode()

Ptr< Node > TcpTestCase::CreateInternetNode ( )
private

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

Returns
The new node.

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

References ns3::CreateObject().

Referenced by SetupDefaultSim().

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

◆ CreateInternetNode6()

Ptr< Node > TcpTestCase::CreateInternetNode6 ( )
private

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

Returns
The new node.

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

References ns3::CreateObject().

Referenced by SetupDefaultSim6().

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

◆ DoRun()

void TcpTestCase::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 201 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, ns3::Simulator::Run(), SetupDefaultSim(), and SetupDefaultSim6().

+ Here is the call graph for this function:

◆ DoTeardown()

void TcpTestCase::DoTeardown ( )
overrideprivatevirtual

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 241 of file tcp-test.cc.

References ns3::Simulator::Destroy(), m_serverRxPayload, m_sourceRxPayload, and m_sourceTxPayload.

+ Here is the call graph for this function:

◆ 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 250 of file tcp-test.cc.

References ns3::MakeCallback(), ServerHandleRecv(), and ServerHandleSend().

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 257 of file tcp-test.cc.

References ns3::Socket::ERROR_NOTERROR, GetString(), m_currentServerRxBytes, m_serverReadSize, m_serverRxPayload, m_totalBytes, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, 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 278 of file tcp-test.cc.

References ns3::Create(), GetString(), m_currentServerRxBytes, m_currentServerTxBytes, m_serverRxPayload, m_serverWriteSize, m_totalBytes, NS_LOG_DEBUG, and NS_TEST_EXPECT_MSG_EQ.

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 ( )
private

Setup the test (IPv4 version).

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

References AddSimpleNetDevice(), CreateInternetNode(), ns3::CreateObject(), ns3::Socket::ERROR_NOTCONN, ns3::Ipv4Address::GetAny(), ns3::MakeCallback(), ns3::MakeNullCallback(), NS_TEST_EXPECT_MSG_EQ, port, ServerHandleConnectionCreated(), SourceHandleRecv(), and SourceHandleSend().

Referenced by DoRun().

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

◆ SetupDefaultSim6()

void TcpTestCase::SetupDefaultSim6 ( )
private

Setup the test (IPv6 version).

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

References AddSimpleNetDevice6(), CreateInternetNode6(), ns3::CreateObject(), ns3::Socket::ERROR_NOTCONN, ns3::Ipv6Address::GetAny(), ns3::MakeCallback(), ns3::MakeNullCallback(), NS_TEST_EXPECT_MSG_EQ, port, ServerHandleConnectionCreated(), SourceHandleRecv(), and SourceHandleSend().

Referenced by DoRun().

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

◆ SourceHandleRecv()

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

Client: Receive data.

Parameters
sockThe socket.

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

References ns3::Socket::ERROR_NOTERROR, GetString(), m_currentSourceRxBytes, m_sourceReadSize, m_sourceRxPayload, m_totalBytes, NS_FATAL_ERROR, NS_LOG_DEBUG, and NS_TEST_EXPECT_MSG_EQ.

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 298 of file tcp-test.cc.

References ns3::Create(), GetString(), m_currentSourceTxBytes, m_sourceTxPayload, m_sourceWriteSize, m_totalBytes, NS_LOG_DEBUG, and NS_TEST_EXPECT_MSG_EQ.

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 145 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 146 of file tcp-test.cc.

Referenced by DoRun(), and ServerHandleSend().

◆ m_currentSourceRxBytes

uint32_t TcpTestCase::m_currentSourceRxBytes
private

Client Rx bytes.

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

Referenced by DoRun(), and SourceHandleRecv().

◆ m_currentSourceTxBytes

uint32_t TcpTestCase::m_currentSourceTxBytes
private

Client Tx bytes.

Definition at line 143 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 142 of file tcp-test.cc.

Referenced by ServerHandleRecv().

◆ m_serverRxPayload

uint8_t* TcpTestCase::m_serverRxPayload
private

Server Rx payload.

Definition at line 149 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 141 of file tcp-test.cc.

Referenced by ServerHandleSend().

◆ m_sourceReadSize

uint32_t TcpTestCase::m_sourceReadSize
private

Client data size when receiving.

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

Referenced by SourceHandleRecv().

◆ m_sourceRxPayload

uint8_t* TcpTestCase::m_sourceRxPayload
private

Client Rx payload.

Definition at line 148 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 147 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 139 of file tcp-test.cc.

Referenced by SourceHandleSend().

◆ m_totalBytes

uint32_t TcpTestCase::m_totalBytes
private

Total stream size (in bytes).

Definition at line 138 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 151 of file tcp-test.cc.

Referenced by DoRun().


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