TCP Test - send string data from client to server and back. More...
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 |
TestCase & | operator= (const TestCase &)=delete |
Private Member Functions | |
Ptr< SimpleNetDevice > | AddSimpleNetDevice (Ptr< Node > node, const char *ipaddr, const char *netmask) |
Add a SimpleNetDevice to a node (IPv4 version). More... | |
Ptr< SimpleNetDevice > | AddSimpleNetDevice6 (Ptr< Node > node, Ipv6Address ipaddr, Ipv6Prefix prefix) |
Add a SimpleNetDevice to a node (IPv6 version). More... | |
Ptr< Node > | CreateInternetNode (void) |
Create a node with the Internet stack (IPv4 version). More... | |
Ptr< Node > | CreateInternetNode6 (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... | |
TestCase * | GetParent () 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... | |
TCP Test - send string data from client to server and back.
Definition at line 61 of file tcp-test.cc.
TcpTestCase::TcpTestCase | ( | uint32_t | totalStreamSize, |
uint32_t | sourceWriteSize, | ||
uint32_t | sourceReadSize, | ||
uint32_t | serverWriteSize, | ||
uint32_t | serverReadSize, | ||
bool | useIpv6 | ||
) |
Constructor.
totalStreamSize | Total stream size (in bytes). |
sourceWriteSize | Client data size when sending. |
sourceReadSize | Client data size when receiving. |
serverWriteSize | Server data size when sending. |
serverReadSize | Server data size when receiving. |
useIpv6 | Use IPv6 instead of IPv4. |
Definition at line 187 of file tcp-test.cc.
|
private |
Add a SimpleNetDevice to a node (IPv4 version).
node | The target node. |
ipaddr | the SimpleNetDevice IPv4 address. |
netmask | the SimpleNetDevice IPv4 address netmask. |
Definition at line 373 of file tcp-test.cc.
References ns3::Node::AddDevice(), and ns3::Object::GetObject().
Referenced by SetupDefaultSim().
|
private |
Add a SimpleNetDevice to a node (IPv6 version).
node | The target node. |
ipaddr | the SimpleNetDevice IPv6 address. |
prefix | the SimpleNetDevice IP6 address prefix. |
Definition at line 509 of file tcp-test.cc.
References ns3::Node::AddDevice(), and ns3::Object::GetObject().
Referenced by SetupDefaultSim6().
Create a node with the Internet stack (IPv4 version).
Definition at line 342 of file tcp-test.cc.
References ns3::Object::AggregateObject().
Referenced by SetupDefaultSim().
Create a node with the Internet stack (IPv6 version).
Definition at line 479 of file tcp-test.cc.
References ns3::Object::AggregateObject().
Referenced by SetupDefaultSim6().
|
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().
|
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.
Server: Handle connection created.
s | The socket. |
addr | The 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().
Server: Receive data.
sock | The 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().
Server: Send data.
sock | The socket. |
available | Unused 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().
|
private |
Setup the test (IPv4 version).
Definition at line 387 of file tcp-test.cc.
References AddSimpleNetDevice(), third::channel, ns3::Socket::Connect(), CreateInternetNode(), ns3::Socket::CreateSocket(), ns3::Socket::GetErrno(), ns3::Object::GetObject(), ns3::Socket::GetPeerName(), ns3::MakeCallback(), ns3::MakeNullCallback(), NS_TEST_EXPECT_MSG_EQ, port, ServerHandleConnectionCreated(), ns3::Socket::SetRecvCallback(), ns3::Socket::SetSendCallback(), SourceHandleRecv(), and SourceHandleSend().
Referenced by DoRun().
|
private |
Setup the test (IPv6 version).
Definition at line 433 of file tcp-test.cc.
References AddSimpleNetDevice6(), third::channel, ns3::Socket::Connect(), CreateInternetNode6(), ns3::Socket::CreateSocket(), ns3::Socket::GetErrno(), ns3::Object::GetObject(), ns3::Socket::GetPeerName(), ns3::MakeCallback(), ns3::MakeNullCallback(), NS_TEST_EXPECT_MSG_EQ, port, ServerHandleConnectionCreated(), ns3::Socket::SetRecvCallback(), ns3::Socket::SetSendCallback(), SourceHandleRecv(), and SourceHandleSend().
Referenced by DoRun().
Client: Receive data.
sock | The 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().
Client: Send data.
sock | The socket. |
available | Unused 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().
|
private |
Server Tx bytes.
Definition at line 157 of file tcp-test.cc.
Referenced by DoRun(), ServerHandleRecv(), and ServerHandleSend().
|
private |
Server Rx bytes.
Definition at line 158 of file tcp-test.cc.
Referenced by DoRun(), and ServerHandleSend().
|
private |
Client Rx bytes.
Definition at line 156 of file tcp-test.cc.
Referenced by DoRun(), and SourceHandleRecv().
|
private |
Client Tx bytes.
Definition at line 155 of file tcp-test.cc.
Referenced by DoRun(), and SourceHandleSend().
|
private |
Server data size when receiving.
Definition at line 154 of file tcp-test.cc.
Referenced by ServerHandleRecv().
|
private |
Server Rx payload.
Definition at line 161 of file tcp-test.cc.
Referenced by DoRun(), DoTeardown(), ServerHandleRecv(), and ServerHandleSend().
|
private |
Server data size when sending.
Definition at line 153 of file tcp-test.cc.
Referenced by ServerHandleSend().
|
private |
Client data size when receiving.
Definition at line 152 of file tcp-test.cc.
Referenced by SourceHandleRecv().
|
private |
Client Rx payload.
Definition at line 160 of file tcp-test.cc.
Referenced by DoRun(), DoTeardown(), and SourceHandleRecv().
|
private |
Client Tx payload.
Definition at line 159 of file tcp-test.cc.
Referenced by DoRun(), DoTeardown(), and SourceHandleSend().
|
private |
Client data size when sending.
Definition at line 151 of file tcp-test.cc.
Referenced by SourceHandleSend().
|
private |
Total stream size (in bytes).
Definition at line 150 of file tcp-test.cc.
Referenced by DoRun(), ServerHandleRecv(), ServerHandleSend(), SourceHandleRecv(), and SourceHandleSend().
|
private |