10#include <ns3/basic-data-calculators.h>
11#include <ns3/config.h>
12#include <ns3/error-model.h>
13#include <ns3/integer.h>
14#include <ns3/internet-stack-helper.h>
15#include <ns3/ipv4-address-helper.h>
16#include <ns3/ipv6-address-helper.h>
18#include <ns3/mac48-address.h>
20#include <ns3/nstime.h>
21#include <ns3/packet.h>
23#include <ns3/simple-channel.h>
24#include <ns3/simple-net-device.h>
25#include <ns3/tcp-congestion-ops.h>
26#include <ns3/tcp-l4-protocol.h>
28#include <ns3/three-gpp-http-client.h>
29#include <ns3/three-gpp-http-header.h>
30#include <ns3/three-gpp-http-helper.h>
31#include <ns3/three-gpp-http-server.h>
81 const Time& channelDelay,
85 std::optional<uint16_t>
port);
127 void DoRun()
override;
316 const Time& channelDelay,
320 std::optional<uint16_t>
port)
324 m_channelDelay{channelDelay},
328 m_numOfPagesReceived{0},
329 m_numOfPacketDrops{0}
356 dev->SetChannel(channel);
360 node->AddDevice(dev);
368 dev->TraceConnectWithoutContext(
381 const auto assignedAddress = ipv4Ifs.
GetAddress(0, 0);
384 NS_LOG_DEBUG(
this <<
" node is assigned to " << assignedAddress <<
".");
386 return assignedAddress;
395 const auto assignedAddress = ipv6Ifs.
GetAddress(0, 0);
398 NS_LOG_DEBUG(
this <<
" node is assigned to " << assignedAddress <<
".");
400 return assignedAddress;
419 NS_LOG_DEBUG(
this <<
" node is assigned to " << assignedAddress <<
".");
421 return assignedAddress;
466 serverApplications = serverHelper.
Install(serverNode);
469 clientApplications = clientHelper.
Install(clientNode);
477 serverApplications = serverHelper.
Install(serverNode);
480 clientApplications = clientHelper.
Install(clientNode);
486 serverApplications = serverHelper.
Install(serverNode);
489 clientApplications = clientHelper.
Install(clientNode);
494 "Invalid number of HTTP servers has been installed");
498 "HTTP server installation fails to produce a proper type");
502 "Invalid number of HTTP clients has been installed");
506 "HTTP client installation fails to produce a proper type");
509 bool traceSourceConnected = httpClient->TraceConnectWithoutContext(
510 "TxMainObjectRequest",
513 traceSourceConnected = httpClient->TraceConnectWithoutContext(
514 "TxEmbeddedObjectRequest",
517 traceSourceConnected = httpServer->TraceConnectWithoutContext(
523 traceSourceConnected = httpServer->TraceConnectWithoutContext(
527 traceSourceConnected = httpClient->TraceConnectWithoutContext(
528 "RxMainObjectPacket",
531 traceSourceConnected = httpClient->TraceConnectWithoutContext(
537 traceSourceConnected = httpServer->TraceConnectWithoutContext(
542 traceSourceConnected = httpClient->TraceConnectWithoutContext(
543 "RxEmbeddedObjectPacket",
547 traceSourceConnected = httpClient->TraceConnectWithoutContext(
553 traceSourceConnected = httpClient->TraceConnectWithoutContext(
557 traceSourceConnected = httpClient->TraceConnectWithoutContext(
561 traceSourceConnected = httpClient->TraceConnectWithoutContext(
576 NS_LOG_INFO(
this <<
" Total request objects received: "
578 NS_LOG_INFO(
this <<
" Total main objects received: "
580 NS_LOG_INFO(
this <<
" Total embedded objects received: "
595 "Tracker of request objects detected irrelevant packet(s).");
598 "Tracker of main objects detected irrelevant packet(s).");
601 "Tracker of embedded objects detected irrelevant packet(s).");
615 m_numOfObjectsReceived(0)
624 m_objectsSize.push_back(size);
640 if (m_objectsSize.empty())
646 txSize = m_objectsSize.front();
650 m_objectsSize.pop_front();
652 m_numOfObjectsReceived++;
660 return (m_objectsSize.empty() && (m_rxBuffer == 0));
666 return m_numOfObjectsReceived;
688 NS_LOG_INFO(
this << packet << packet->GetSize() << from << to);
708 "Error finding ThreeGppHttpHeader in a packet received by the server");
711 "Request object's client TS is unexpectedly non-positive");
725 "Transmitted size and received size of request object differ");
753 "Error finding ThreeGppHttpHeader in a packet received by the server");
756 "Invalid content type in the received packet");
759 "Main object's client TS is unexpectedly non-positive");
762 "Main object's server TS is unexpectedly non-positive");
770 "Transmitted size and received size of main object differ");
773 "Actual main object packet size and received size of main object differ");
801 "Error finding ThreeGppHttpHeader in a packet received by the server");
804 "Invalid content type in the received packet");
807 "Embedded object's client TS is unexpectedly non-positive");
810 "Embedded object's server TS is unexpectedly non-positive");
818 "Transmitted size and received size of embedded object differ");
822 "Actual embedded object packet size and received size of embedded object differ");
827 const std::string& newState)
831 if (newState ==
"READING")
897 :
TestSuite(
"applications-three-gpp-http-client-server",
Type::SYSTEM)
905 double bitErrorRate[] = {0.0, 5.0e-6};
917 AddHttpObjectTestCase(run++,
922 AddHttpObjectTestCase(run++,
928 AddHttpObjectTestCase(run++,
957 const Time& channelDelay,
961 std::optional<uint16_t>
port = std::nullopt)
963 std::ostringstream name;
964 name <<
"Run #" << rngRun;
965 name <<
" delay=" << channelDelay.
As(
Time::MS);
966 name <<
" ber=" << bitErrorRate;
967 name <<
" mtu=" << mtuSize;
979 name <<
"(" << *
port <<
")";
986 testDuration = TestCase::Duration::EXTENSIVE;
990 testDuration = TestCase::Duration::TAKES_FOREVER;
A test class for running several system tests which validate the web browsing traffic model.
void AddHttpObjectTestCase(uint32_t rngRun, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6, std::optional< uint16_t > port=std::nullopt)
Creates a test case with the given parameters.
ThreeGppHttpClientServerTestSuite()
Instantiate the test suite.
ThreeGppHttpObjectTracker()
Creates a new instance with all counters begin at zero.
void PartReceived(uint32_t size)
Shall be invoked when an object part has been received.
void ObjectSent(uint32_t size)
Shall be invoked when a whole object has been transmitted.
bool ObjectReceived(uint32_t &txSize, uint32_t &rxSize)
Shall be invoked after all parts of a complete object have been received.
uint32_t m_rxBuffer
The accumulated size (in bytes) of parts of a whole object.
uint16_t GetNumOfObjectsReceived() const
uint16_t m_numOfObjectsReceived
Number of whole objects that have been received so far.
std::list< uint32_t > m_objectsSize
Each entry is the size (in bytes) of object transmitted.
A test class which verifies that each HTTP object sent is also received the same size.
ThreeGppHttpObjectTracker m_embeddedObjectTracker
Tracker of embedded objects.
void DeviceDropCallback(Ptr< const Packet > packet)
Connected with PhyRxDrop trace source of both the client's and server's devices.
InternetStackHelper m_internetStackHelper
Installs TCP/IP stack on the nodes.
void ClientRxDelayCallback(const Time &delay, const Address &from)
Connected with RxDelay trace source of the client.
TypeId m_tcpType
TCP algorithm used.
void ClientTxEmbeddedObjectRequestCallback(Ptr< const Packet > packet)
Connected with TxEmbeddedObjectRequest trace source of the client.
void ClientTxMainObjectRequestCallback(Ptr< const Packet > packet)
Connected with TxMainObjectRequest trace source of the client.
void ClientRxEmbeddedObjectCallback(Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
Connected with RxEmbeddedObject trace source of the client.
uint16_t m_numOfPagesReceived
Begins with 0. Simulation stops if this reaches 3.
void DoRun() override
Implementation to actually run this TestCase.
Ipv4AddressHelper m_ipv4AddressHelper
Assigns IPv4 addresses to the nodes.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
uint32_t m_mtuSize
Maximum transmission unit (in bytes).
void ClientRxMainObjectPacketCallback(Ptr< const Packet > packet)
Connected with RxMainObjectPacket trace source of the client.
std::optional< uint16_t > m_port
port to use if provided, otherwise the default port is used
void ClientRxMainObjectCallback(Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
Connected with RxMainObject trace source of the client.
void ClientRxEmbeddedObjectPacketCallback(Ptr< const Packet > packet)
Connected with RxEmbeddedObjectPacket trace source of the client.
Ptr< MinMaxAvgTotalCalculator< double > > m_rttCalculator
Keeps statistical information of round-trip delays (in seconds).
void ProgressCallback()
Dummy event.
void ClientStateTransitionCallback(const std::string &oldState, const std::string &newState)
Connected with StateTransition trace source of the client.
ThreeGppHttpObjectTracker m_requestObjectTracker
Tracker of request objects.
Time m_channelDelay
Time needed by a packet to propagate.
Address AssignSocketAddress(Ptr< NetDevice > dev, uint16_t port)
Assign a socket address for a device.
uint32_t m_rngRun
Determines the set of random values generated.
void ServerEmbeddedObjectCallback(uint32_t size)
Connected with EmbeddedObject trace source of the server.
uint16_t m_numOfPacketDrops
Number of packets dropped because of m_errorModel.
Ipv6AddressHelper m_ipv6AddressHelper
Assigns IPv6 addresses to the nodes.
ThreeGppHttpObjectTestCase(const std::string &name, uint32_t rngRun, const TypeId &tcpType, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6, std::optional< uint16_t > port)
Ptr< MinMaxAvgTotalCalculator< double > > m_delayCalculator
Keeps statistical information of one-trip delays (in seconds).
void ClientRxRttCallback(const Time &rtt, const Address &from)
Connected with RxRtt trace source of the client.
Ipv6Address AssignIpv6Address(Ptr< NetDevice > dev, bool logging=true)
Assign an IPv6 address to a device.
bool m_useIpv6
Whether to use IPv6 or IPv4.
Ptr< Node > CreateSimpleInternetNode(Ptr< SimpleChannel > channel)
Creates a Node, complete with a TCP/IP stack.
void ServerRxCallback(Ptr< const Packet > packet, const Address &from, const Address &to)
Connected with Rx trace source of the server.
Ipv4Address AssignIpv4Address(Ptr< NetDevice > dev, bool logging=true)
Assign an IPv4 address to a device.
Ptr< RateErrorModel > m_errorModel
Receive error model to be attached to the devices of both directions.
void ServerMainObjectCallback(uint32_t size)
Connected with MainObject trace source of the server.
ThreeGppHttpObjectTracker m_mainObjectTracker
Tracker of main objects.
a polymophic address class
holds a vector of ns3::Application pointers.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
uint16_t GetPort() const
Get the port.
static bool IsMatchingType(const Address &addr)
If the address match.
static bool IsMatchingType(const Address &address)
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
Keep track of a set of IPv6 interfaces.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
Describes an IPv6 prefix.
static Mac48Address Allocate()
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
TCP socket creation and multiplexing/demultiplexing.
static TypeId GetTypeId()
Get the type ID.
Duration
How long the test takes to execute.
std::string GetName() const
Helper to make it easier to instantiate an ThreeGppHttpClient on a set of nodes.
Model application which simulates the traffic of a web browser.
Helper to make it easier to instantiate an ThreeGppHttpServer on a set of nodes.
Model application which simulates the traffic of a web server.
static constexpr uint16_t HTTP_DEFAULT_PORT
default HTTP port
Simulation virtual time values and global simulation resolution.
bool IsPositive() const
Exactly equivalent to t >= 0.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
AttributeValue implementation for TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SetGlobal(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static ThreeGppHttpClientServerTestSuite g_httpClientServerTestSuiteInstance
The global instance of the three-gpp-http-client-server system test.