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

A test class which verifies that each HTTP object sent is also received the same size. More...

+ Inheritance diagram for ThreeGppHttpObjectTestCase:

Classes

class  ThreeGppHttpObjectTracker
 

Public Member Functions

 ThreeGppHttpObjectTestCase (const std::string &name, uint32_t rngRun, const TypeId &tcpType, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6)
 
- Public Member Functions inherited from ns3::TestCase
virtual ~TestCase ()
 Destructor. More...
 
std::string GetName (void) const
 

Private Member Functions

void ClientRxDelayCallback (const Time &delay, const Address &from)
 Connected with RxDelay trace source of the client. More...
 
void ClientRxEmbeddedObjectCallback (Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
 Connected with RxEmbeddedObject trace source of the client. More...
 
void ClientRxEmbeddedObjectPacketCallback (Ptr< const Packet > packet)
 Connected with RxEmbeddedObjectPacket trace source of the client. More...
 
void ClientRxMainObjectCallback (Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
 Connected with RxMainObject trace source of the client. More...
 
void ClientRxMainObjectPacketCallback (Ptr< const Packet > packet)
 Connected with RxMainObjectPacket trace source of the client. More...
 
void ClientRxRttCallback (const Time &rtt, const Address &from)
 Connected with RxRtt trace source of the client. More...
 
void ClientStateTransitionCallback (const std::string &oldState, const std::string &newState)
 Connected with StateTransition trace source of the client. More...
 
void ClientTxEmbeddedObjectRequestCallback (Ptr< const Packet > packet)
 Connected with TxEmbeddedObjectRequest trace source of the client. More...
 
void ClientTxMainObjectRequestCallback (Ptr< const Packet > packet)
 Connected with TxMainObjectRequest trace source of the client. More...
 
Ptr< NodeCreateSimpleInternetNode (Ptr< SimpleChannel > channel, Address &assignedAddress)
 Creates a Node, complete with a TCP/IP stack and address assignment. More...
 
void DeviceDropCallback (Ptr< const Packet > packet)
 Connected with PhyRxDrop trace source of both the client's and server's devices. More...
 
virtual void DoRun ()
 Implementation to actually run this TestCase. More...
 
virtual void DoTeardown ()
 Implementation to do any local setup required for this TestCase. More...
 
void ProgressCallback ()
 Dummy event. More...
 
void ServerEmbeddedObjectCallback (uint32_t size)
 Connected with EmbeddedObject trace source of the server. More...
 
void ServerMainObjectCallback (uint32_t size)
 Connected with MainObject trace source of the server. More...
 
void ServerRxCallback (Ptr< const Packet > packet, const Address &from)
 Connected with Rx trace source of the server. More...
 

Private Attributes

Time m_channelDelay
 Time needed by a packet to propagate. More...
 
Ptr< MinMaxAvgTotalCalculator< double > > m_delayCalculator
 Keeps statistical information of one-trip delays (in seconds). More...
 
ThreeGppHttpObjectTracker m_embeddedObjectTracker
 Tracker of embedded objects. More...
 
Ptr< RateErrorModelm_errorModel
 Receive error model to be attached to the devices of both directions. More...
 
InternetStackHelper m_internetStackHelper
 Installs TCP/IP stack on the nodes. More...
 
Ipv4AddressHelper m_ipv4AddressHelper
 Assigns IPv4 addresses to the nodes. More...
 
Ipv6AddressHelper m_ipv6AddressHelper
 Assigns IPv6 addresses to the nodes. More...
 
ThreeGppHttpObjectTracker m_mainObjectTracker
 Tracker of main objects. More...
 
uint32_t m_mtuSize
 Maximum transmission unit (in bytes). More...
 
uint16_t m_numOfPacketDrops
 Number of packets dropped because of m_errorModel. More...
 
uint16_t m_numOfPagesReceived
 Begins with 0. Simulation stops if this reaches 3. More...
 
ThreeGppHttpObjectTracker m_requestObjectTracker
 Tracker of request objects. More...
 
uint32_t m_rngRun
 Determines the set of random values generated. More...
 
Ptr< MinMaxAvgTotalCalculator< double > > m_rttCalculator
 Keeps statistical information of round-trip delays (in seconds). More...
 
TypeId m_tcpType
 TCP algorithm used. More...
 
bool m_useIpv6
 Whether to use IPv6 or 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

A test class which verifies that each HTTP object sent is also received the same size.

The test uses a minimalist scenario of one HTTP server and one HTTP client, connected through a SimpleChannel. The simulation runs until 3 web pages have been successfully downloaded by the client.

The test also collects some statistical information from the simulation for informational or debugging purpose. This can be seen by enabling LOG_INFO.

Definition at line 70 of file three-gpp-http-client-server-test.cc.

Constructor & Destructor Documentation

◆ ThreeGppHttpObjectTestCase()

ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTestCase ( const std::string &  name,
uint32_t  rngRun,
const TypeId tcpType,
const Time channelDelay,
double  bitErrorRate,
uint32_t  mtuSize,
bool  useIpv6 
)
Parameters
nameA textual label to briefly describe the test.
rngRunRun index to be used, intended to affect the values produced by random number generators throughout the test.
tcpTypeType of TCP algorithm to be used by the connection between the client and the server. Must be a child type of ns3::TcpSocketFactory.
channelDelayTransmission delay between the client and the server (and vice versa) which is due to the channel.
bitErrorRateThe probability of transmission error between the client and the server (and vice versa) in the unit of bits.
mtuSizeMaximum transmission unit (in bytes) to be used by the server model.
useIpv6If true, IPv6 will be used to address both client and server. Otherwise, IPv4 will be used.

Definition at line 295 of file three-gpp-http-client-server-test.cc.

References ns3::TestCase::GetName(), ns3::Time::IsPositive(), m_delayCalculator, m_errorModel, m_ipv4AddressHelper, m_ipv6AddressHelper, m_rttCalculator, NS_ASSERT, NS_LOG_FUNCTION, ns3::Ipv4AddressHelper::SetBase(), ns3::Ipv6AddressHelper::SetBase(), ns3::RateErrorModel::SetRate(), and ns3::RateErrorModel::SetUnit().

Member Function Documentation

◆ ClientRxDelayCallback()

void ThreeGppHttpObjectTestCase::ClientRxDelayCallback ( const Time delay,
const Address from 
)
private

Connected with RxDelay trace source of the client.

Updates the statistics in m_delayCalculator.

Parameters
delayThe packet one-trip delay time.
fromThe address of the device where the packet originates from.

Definition at line 761 of file three-gpp-http-client-server-test.cc.

References ns3::Time::GetSeconds(), m_delayCalculator, NS_LOG_FUNCTION, and ns3::MinMaxAvgTotalCalculator< T >::Update().

Referenced by DoRun().

◆ ClientRxEmbeddedObjectCallback()

void ThreeGppHttpObjectTestCase::ClientRxEmbeddedObjectCallback ( Ptr< const ThreeGppHttpClient httpClient,
Ptr< const Packet packet 
)
private

◆ ClientRxEmbeddedObjectPacketCallback()

void ThreeGppHttpObjectTestCase::ClientRxEmbeddedObjectPacketCallback ( Ptr< const Packet packet)
private

Connected with RxEmbeddedObjectPacket trace source of the client.

Updates m_embeddedObjectTracker and perform some tests on the packet.

Parameters
packetThe packet received.

Definition at line 699 of file three-gpp-http-client-server-test.cc.

References ns3::Packet::GetSize(), m_embeddedObjectTracker, NS_LOG_FUNCTION, and ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::PartReceived().

Referenced by DoRun().

◆ ClientRxMainObjectCallback()

void ThreeGppHttpObjectTestCase::ClientRxMainObjectCallback ( Ptr< const ThreeGppHttpClient httpClient,
Ptr< const Packet packet 
)
private

◆ ClientRxMainObjectPacketCallback()

void ThreeGppHttpObjectTestCase::ClientRxMainObjectPacketCallback ( Ptr< const Packet packet)
private

Connected with RxMainObjectPacket trace source of the client.

Updates m_mainObjectTracker and perform some tests on the packet.

Parameters
packetThe packet received.

Definition at line 657 of file three-gpp-http-client-server-test.cc.

References ns3::Packet::GetSize(), m_mainObjectTracker, NS_LOG_FUNCTION, and ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::PartReceived().

Referenced by DoRun().

◆ ClientRxRttCallback()

void ThreeGppHttpObjectTestCase::ClientRxRttCallback ( const Time rtt,
const Address from 
)
private

Connected with RxRtt trace source of the client.

Updates the statistics in m_rttCalculator.

Parameters
rttThe packet round trip delay time.
fromThe address of the device where the packet originates from.

Definition at line 769 of file three-gpp-http-client-server-test.cc.

References ns3::Time::GetSeconds(), m_rttCalculator, NS_LOG_FUNCTION, and ns3::MinMaxAvgTotalCalculator< T >::Update().

Referenced by DoRun().

◆ ClientStateTransitionCallback()

void ThreeGppHttpObjectTestCase::ClientStateTransitionCallback ( const std::string &  oldState,
const std::string &  newState 
)
private

Connected with StateTransition trace source of the client.

Increments m_numOfPagesReceived when the client enters READING state.

Parameters
oldStateThe name of the previous state.
newStateThe name of the current state.

Definition at line 735 of file three-gpp-http-client-server-test.cc.

References m_numOfPagesReceived, NS_LOG_FUNCTION, and NS_LOG_LOGIC().

Referenced by DoRun().

◆ ClientTxEmbeddedObjectRequestCallback()

void ThreeGppHttpObjectTestCase::ClientTxEmbeddedObjectRequestCallback ( Ptr< const Packet packet)
private

Connected with TxEmbeddedObjectRequest trace source of the client.

Updates m_requestObjectTracker.

Parameters
packetThe packet of embedded object sent.

Definition at line 614 of file three-gpp-http-client-server-test.cc.

References ns3::Packet::GetSize(), m_requestObjectTracker, NS_LOG_FUNCTION, and ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::ObjectSent().

Referenced by DoRun().

◆ ClientTxMainObjectRequestCallback()

void ThreeGppHttpObjectTestCase::ClientTxMainObjectRequestCallback ( Ptr< const Packet packet)
private

Connected with TxMainObjectRequest trace source of the client.

Updates m_requestObjectTracker.

Parameters
packetThe packet of main object sent.

Definition at line 607 of file three-gpp-http-client-server-test.cc.

References ns3::Packet::GetSize(), m_requestObjectTracker, NS_LOG_FUNCTION, and ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::ObjectSent().

Referenced by DoRun().

◆ CreateSimpleInternetNode()

Ptr< Node > ThreeGppHttpObjectTestCase::CreateSimpleInternetNode ( Ptr< SimpleChannel channel,
Address assignedAddress 
)
private

Creates a Node, complete with a TCP/IP stack and address assignment.

m_tcpType determines the TCP algorithm installed at the TCP stack. m_useIpv6 determines whether to use IPv4 addressing or IPv6 addressing.

Parameters
[in]channelPointer to a channel which the node's device will be attached to.
[out]assignedAddressThe resulting address of the node.
Returns
Pointer to the newly created node.

Definition at line 332 of file three-gpp-http-client-server-test.cc.

References ns3::Node::AddDevice(), ns3::Ipv6AddressHelper::Assign(), ns3::Ipv4AddressHelper::Assign(), third::channel, DeviceDropCallback(), ns3::Ipv6InterfaceContainer::GetAddress(), ns3::Ipv4InterfaceContainer::GetAddress(), ns3::Ipv6InterfaceContainer::GetN(), ns3::Ipv4InterfaceContainer::GetN(), ns3::Object::GetObject(), ns3::InternetStackHelper::Install(), m_errorModel, m_internetStackHelper, m_ipv4AddressHelper, m_ipv6AddressHelper, m_tcpType, m_useIpv6, ns3::MakeCallback(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::SimpleNetDevice::SetAddress(), ns3::ObjectBase::SetAttribute(), ns3::SimpleNetDevice::SetChannel(), ns3::SimpleNetDevice::SetReceiveErrorModel(), and ns3::ObjectBase::TraceConnectWithoutContext().

Referenced by DoRun().

◆ DeviceDropCallback()

void ThreeGppHttpObjectTestCase::DeviceDropCallback ( Ptr< const Packet packet)
private

Connected with PhyRxDrop trace source of both the client's and server's devices.

Increments m_numOfPacketDrops.

Parameters
packetPointer to the packet being dropped.

Definition at line 777 of file three-gpp-http-client-server-test.cc.

References ns3::Packet::GetSize(), m_numOfPacketDrops, and NS_LOG_FUNCTION.

Referenced by CreateSimpleInternetNode().

◆ DoRun()

void ThreeGppHttpObjectTestCase::DoRun ( )
privatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 377 of file three-gpp-http-client-server-test.cc.

References third::channel, ClientRxDelayCallback(), ClientRxEmbeddedObjectCallback(), ClientRxEmbeddedObjectPacketCallback(), ClientRxMainObjectCallback(), ClientRxMainObjectPacketCallback(), ClientRxRttCallback(), ClientStateTransitionCallback(), ClientTxEmbeddedObjectRequestCallback(), ClientTxMainObjectRequestCallback(), CreateSimpleInternetNode(), ns3::ApplicationContainer::Get(), ns3::MinMaxAvgTotalCalculator< T >::getMax(), ns3::MinMaxAvgTotalCalculator< T >::getMean(), ns3::MinMaxAvgTotalCalculator< T >::getMin(), ns3::ApplicationContainer::GetN(), ns3::TestCase::GetName(), ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::GetNumOfObjectsReceived(), ns3::Object::GetObject(), ns3::ThreeGppHttpClientHelper::Install(), ns3::ThreeGppHttpServerHelper::Install(), ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::IsEmpty(), m_channelDelay, m_delayCalculator, m_embeddedObjectTracker, m_mainObjectTracker, m_mtuSize, m_numOfPacketDrops, m_numOfPagesReceived, m_requestObjectTracker, m_rngRun, m_rttCalculator, ns3::MakeCallback(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_INFO, NS_TEST_ASSERT_MSG_EQ, NS_TEST_ASSERT_MSG_NE, NS_TEST_EXPECT_MSG_EQ, ProgressCallback(), ns3::Seconds(), ServerEmbeddedObjectCallback(), ServerMainObjectCallback(), ServerRxCallback(), and ns3::Config::SetGlobal().

◆ DoTeardown()

void ThreeGppHttpObjectTestCase::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 545 of file three-gpp-http-client-server-test.cc.

References ns3::TestCase::GetName(), and NS_LOG_FUNCTION.

◆ ProgressCallback()

void ThreeGppHttpObjectTestCase::ProgressCallback ( )
private

Dummy event.

Definition at line 754 of file three-gpp-http-client-server-test.cc.

References ns3::Now(), NS_LOG_INFO, and ns3::Seconds().

Referenced by DoRun().

◆ ServerEmbeddedObjectCallback()

void ThreeGppHttpObjectTestCase::ServerEmbeddedObjectCallback ( uint32_t  size)
private

Connected with EmbeddedObject trace source of the server.

Updates m_embeddedObjectTracker.

Parameters
sizeSize of the generated embedded object (in bytes).

Definition at line 692 of file three-gpp-http-client-server-test.cc.

References m_embeddedObjectTracker, NS_LOG_FUNCTION, and ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::ObjectSent().

Referenced by DoRun().

◆ ServerMainObjectCallback()

void ThreeGppHttpObjectTestCase::ServerMainObjectCallback ( uint32_t  size)
private

Connected with MainObject trace source of the server.

Updates m_mainObjectTracker.

Parameters
sizeSize of the generated main object (in bytes).

Definition at line 650 of file three-gpp-http-client-server-test.cc.

References m_mainObjectTracker, NS_LOG_FUNCTION, and ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::ObjectSent().

Referenced by DoRun().

◆ ServerRxCallback()

void ThreeGppHttpObjectTestCase::ServerRxCallback ( Ptr< const Packet packet,
const Address from 
)
private

Connected with Rx trace source of the server.

Updates m_requestObjectTracker and perform some tests on the packet and the size of the object.

Parameters
packetThe packet received.
fromThe address where the packet originates from.

Definition at line 621 of file three-gpp-http-client-server-test.cc.

References ns3::Packet::Copy(), ns3::ThreeGppHttpHeader::GetClientTs(), ns3::Packet::GetSize(), m_requestObjectTracker, NS_LOG_FUNCTION, NS_TEST_ASSERT_MSG_EQ, NS_TEST_ASSERT_MSG_GT, ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::ObjectReceived(), ThreeGppHttpObjectTestCase::ThreeGppHttpObjectTracker::PartReceived(), and ns3::Seconds().

Referenced by DoRun().

Member Data Documentation

◆ m_channelDelay

Time ThreeGppHttpObjectTestCase::m_channelDelay
private

Time needed by a packet to propagate.

Definition at line 270 of file three-gpp-http-client-server-test.cc.

Referenced by DoRun().

◆ m_delayCalculator

Ptr<MinMaxAvgTotalCalculator<double> > ThreeGppHttpObjectTestCase::m_delayCalculator
private

Keeps statistical information of one-trip delays (in seconds).

Definition at line 289 of file three-gpp-http-client-server-test.cc.

Referenced by ClientRxDelayCallback(), DoRun(), and ThreeGppHttpObjectTestCase().

◆ m_embeddedObjectTracker

ThreeGppHttpObjectTracker ThreeGppHttpObjectTestCase::m_embeddedObjectTracker
private

◆ m_errorModel

Ptr<RateErrorModel> ThreeGppHttpObjectTestCase::m_errorModel
private

Receive error model to be attached to the devices of both directions.

Definition at line 277 of file three-gpp-http-client-server-test.cc.

Referenced by CreateSimpleInternetNode(), and ThreeGppHttpObjectTestCase().

◆ m_internetStackHelper

InternetStackHelper ThreeGppHttpObjectTestCase::m_internetStackHelper
private

Installs TCP/IP stack on the nodes.

Definition at line 283 of file three-gpp-http-client-server-test.cc.

Referenced by CreateSimpleInternetNode().

◆ m_ipv4AddressHelper

Ipv4AddressHelper ThreeGppHttpObjectTestCase::m_ipv4AddressHelper
private

Assigns IPv4 addresses to the nodes.

Definition at line 285 of file three-gpp-http-client-server-test.cc.

Referenced by CreateSimpleInternetNode(), and ThreeGppHttpObjectTestCase().

◆ m_ipv6AddressHelper

Ipv6AddressHelper ThreeGppHttpObjectTestCase::m_ipv6AddressHelper
private

Assigns IPv6 addresses to the nodes.

Definition at line 287 of file three-gpp-http-client-server-test.cc.

Referenced by CreateSimpleInternetNode(), and ThreeGppHttpObjectTestCase().

◆ m_mainObjectTracker

ThreeGppHttpObjectTracker ThreeGppHttpObjectTestCase::m_mainObjectTracker
private

◆ m_mtuSize

uint32_t ThreeGppHttpObjectTestCase::m_mtuSize
private

Maximum transmission unit (in bytes).

Definition at line 271 of file three-gpp-http-client-server-test.cc.

Referenced by DoRun().

◆ m_numOfPacketDrops

uint16_t ThreeGppHttpObjectTestCase::m_numOfPacketDrops
private

Number of packets dropped because of m_errorModel.

Definition at line 281 of file three-gpp-http-client-server-test.cc.

Referenced by DeviceDropCallback(), and DoRun().

◆ m_numOfPagesReceived

uint16_t ThreeGppHttpObjectTestCase::m_numOfPagesReceived
private

Begins with 0. Simulation stops if this reaches 3.

Definition at line 279 of file three-gpp-http-client-server-test.cc.

Referenced by ClientStateTransitionCallback(), and DoRun().

◆ m_requestObjectTracker

ThreeGppHttpObjectTracker ThreeGppHttpObjectTestCase::m_requestObjectTracker
private

◆ m_rngRun

uint32_t ThreeGppHttpObjectTestCase::m_rngRun
private

Determines the set of random values generated.

Definition at line 268 of file three-gpp-http-client-server-test.cc.

Referenced by DoRun().

◆ m_rttCalculator

Ptr<MinMaxAvgTotalCalculator<double> > ThreeGppHttpObjectTestCase::m_rttCalculator
private

Keeps statistical information of round-trip delays (in seconds).

Definition at line 291 of file three-gpp-http-client-server-test.cc.

Referenced by ClientRxRttCallback(), DoRun(), and ThreeGppHttpObjectTestCase().

◆ m_tcpType

TypeId ThreeGppHttpObjectTestCase::m_tcpType
private

TCP algorithm used.

Definition at line 269 of file three-gpp-http-client-server-test.cc.

Referenced by CreateSimpleInternetNode().

◆ m_useIpv6

bool ThreeGppHttpObjectTestCase::m_useIpv6
private

Whether to use IPv6 or IPv4.

Definition at line 272 of file three-gpp-http-client-server-test.cc.

Referenced by CreateSimpleInternetNode().


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