A Discrete-Event Network Simulator
API
three-gpp-http-client-server-test.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 Magister Solutions
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Budiarto Herman <budiarto.herman@magister.fi>
19  *
20  */
21 
22 #include <ns3/test.h>
23 #include <ns3/log.h>
24 #include <ns3/config.h>
25 #include <ns3/ptr.h>
26 #include <ns3/nstime.h>
27 #include <ns3/integer.h>
28 
29 #include <ns3/simple-channel.h>
30 #include <ns3/node.h>
31 #include <ns3/packet.h>
32 #include <ns3/mac48-address.h>
33 #include <ns3/simple-net-device.h>
34 #include <ns3/error-model.h>
35 #include <ns3/ipv4-address-helper.h>
36 #include <ns3/ipv6-address-helper.h>
37 #include <ns3/internet-stack-helper.h>
38 #include <ns3/tcp-l4-protocol.h>
39 
40 #include <ns3/tcp-congestion-ops.h>
41 
42 #include <ns3/three-gpp-http-client.h>
43 #include <ns3/three-gpp-http-server.h>
44 #include <ns3/three-gpp-http-helper.h>
45 #include <ns3/three-gpp-http-header.h>
46 
47 #include <ns3/basic-data-calculators.h>
48 #include <list>
49 #include <sstream>
50 
51 
52 NS_LOG_COMPONENT_DEFINE ("ThreeGppHttpClientServerTest");
53 
54 using namespace ns3;
55 
56 // HTTP OBJECT TEST CASE //////////////////////////////////////////////////////
57 
71 {
72 public:
90  ThreeGppHttpObjectTestCase (const std::string &name,
91  uint32_t rngRun,
92  const TypeId &tcpType,
93  const Time &channelDelay,
94  double bitErrorRate,
95  uint32_t mtuSize,
96  bool useIpv6);
97 
98 private:
109  Ptr<Node> CreateSimpleInternetNode (Ptr<SimpleChannel> channel,
110  Address &assignedAddress);
111 
112  // Inherited from TestCase base class.
113  virtual void DoRun ();
114  virtual void DoTeardown ();
115 
123  {
124 public:
131  void ObjectSent (uint32_t size);
137  void PartReceived (uint32_t size);
149  bool ObjectReceived (uint32_t &txSize, uint32_t &rxSize);
151  bool IsEmpty () const;
153  uint16_t GetNumOfObjectsReceived () const;
154 private:
161  std::list<uint32_t> m_objectsSize;
163  uint32_t m_rxBuffer;
166  };
167 
168  // The following defines one tracker for each HTTP object type.
172 
173  // CALLBACK TO TRACE SOURCES.
174 
180  void ClientTxMainObjectRequestCallback (Ptr<const Packet> packet);
186  void ClientTxEmbeddedObjectRequestCallback (Ptr<const Packet> packet);
194  void ServerRxCallback (Ptr<const Packet> packet, const Address &from);
200  void ServerMainObjectCallback (uint32_t size);
206  void ClientRxMainObjectPacketCallback (Ptr<const Packet> packet);
213  void ClientRxMainObjectCallback (Ptr<const ThreeGppHttpClient> httpClient, Ptr<const Packet> packet);
219  void ServerEmbeddedObjectCallback (uint32_t size);
225  void ClientRxEmbeddedObjectPacketCallback (Ptr<const Packet> packet);
232  void ClientRxEmbeddedObjectCallback (Ptr<const ThreeGppHttpClient> httpClient, Ptr<const Packet> packet);
239  void ClientStateTransitionCallback (const std::string &oldState,
240  const std::string &newState);
247  void ClientRxDelayCallback (const Time &delay, const Address &from);
254  void ClientRxRttCallback (const Time &rtt, const Address &from);
260  void DeviceDropCallback (Ptr<const Packet> packet);
264  void ProgressCallback ();
265 
266  // THE PARAMETERS OF THE TEST CASE.
267 
268  uint32_t m_rngRun;
271  uint32_t m_mtuSize;
272  bool m_useIpv6;
273 
274  // OTHER MEMBER VARIABLES.
275 
292 
293 }; // end of `class HttpClientServerTestCase`
294 
296  uint32_t rngRun,
297  const TypeId &tcpType,
298  const Time &channelDelay,
299  double bitErrorRate,
300  uint32_t mtuSize,
301  bool useIpv6)
302  : TestCase (name),
303  m_rngRun (rngRun),
304  m_tcpType (tcpType),
305  m_channelDelay (channelDelay),
306  m_mtuSize (mtuSize),
307  m_useIpv6 (useIpv6),
308  m_numOfPagesReceived (0),
309  m_numOfPacketDrops (0)
310 {
311  NS_LOG_FUNCTION (this << GetName ());
312 
313  //NS_ASSERT (tcpType.IsChildOf (TypeId::LookupByName ("ns3::TcpSocketBase")));
314  NS_ASSERT (channelDelay.IsPositive ());
315 
316  m_errorModel = CreateObject<RateErrorModel> ();
317  m_errorModel->SetRate (bitErrorRate);
318  m_errorModel->SetUnit (RateErrorModel::ERROR_UNIT_BIT);
319 
321  Ipv4Mask ("255.0.0.0"),
322  Ipv4Address ("0.0.0.1"));
324  Ipv6Prefix (64),
325  Ipv6Address ("::1"));
326 
327  m_delayCalculator = CreateObject<MinMaxAvgTotalCalculator<double> > ();
328  m_rttCalculator = CreateObject<MinMaxAvgTotalCalculator<double> > ();
329 }
330 
331 Ptr<Node>
333  Address &assignedAddress)
334 {
335  NS_LOG_FUNCTION (this << channel);
336 
337  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
338  dev->SetAddress (Mac48Address::Allocate ());
339  dev->SetChannel (channel);
341 
342  Ptr<Node> node = CreateObject<Node> ();
343  node->AddDevice (dev);
345 
346  // Assign IP address according to the selected Ip version.
347  if (m_useIpv6)
348  {
349  Ipv6InterfaceContainer ipv6Ifs
351  NS_ASSERT (ipv6Ifs.GetN () == 1);
352  assignedAddress = ipv6Ifs.GetAddress (0, 0);
353  }
354  else
355  {
356  Ipv4InterfaceContainer ipv4Ifs
358  NS_ASSERT (ipv4Ifs.GetN () == 1);
359  assignedAddress = ipv4Ifs.GetAddress (0, 0);
360  }
361 
362  NS_LOG_DEBUG (this << " node is assigned to " << assignedAddress << ".");
363 
364  // Set the TCP algorithm.
366  tcp->SetAttribute ("SocketType", TypeIdValue (m_tcpType));
367 
368  // Connect with the trace source that informs about packet drop due to error.
370  "PhyRxDrop",
372 
373  return node;
374 }
375 
376 void
378 {
379  NS_LOG_FUNCTION (this << GetName ());
381  NS_LOG_INFO (this << " Running test case " << GetName ());
382 
383  /*
384  * Create topology:
385  *
386  * Server Node Client Node
387  * +-----------------+ +-----------------+
388  * | HTTP Server | | HTTP Client |
389  * | Application | | Application |
390  * +-----------------+ +-----------------+
391  * | TCP | | TCP |
392  * +-----------------+ +-----------------+
393  * | IPv4/v6 | | IPv4/v6 |
394  * +-----------------+ +-----------------+
395  * | Simple NetDev | | Simple NetDev |
396  * +-----------------+ +-----------------+
397  * | |
398  * | |
399  * +----------------------------+
400  * Simple Channel
401  */
402 
403  // Channel.
404  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel> ();
405  channel->SetAttribute ("Delay", TimeValue (m_channelDelay));
406 
407  // Server node.
408  Address serverAddress;
409  Ptr<Node> serverNode = CreateSimpleInternetNode (channel, serverAddress);
410  ThreeGppHttpServerHelper serverHelper (serverAddress);
411  ApplicationContainer serverApplications = serverHelper.Install (serverNode);
412  NS_TEST_ASSERT_MSG_EQ (serverApplications.GetN (), 1,
413  "Invalid number of HTTP servers has been installed");
414  Ptr<ThreeGppHttpServer> httpServer = serverApplications.Get (0)->GetObject<ThreeGppHttpServer> ();
415  NS_TEST_ASSERT_MSG_NE (httpServer, 0,
416  "HTTP server installation fails to produce a proper type");
417  httpServer->SetMtuSize (m_mtuSize);
418 
419  // Client node.
420  Address clientAddress;
421  Ptr<Node> clientNode = CreateSimpleInternetNode (channel, clientAddress);
422  ThreeGppHttpClientHelper clientHelper (serverAddress);
423  ApplicationContainer clientApplications = clientHelper.Install (clientNode);
424  NS_TEST_ASSERT_MSG_EQ (clientApplications.GetN (), 1,
425  "Invalid number of HTTP clients has been installed");
426  Ptr<ThreeGppHttpClient> httpClient = clientApplications.Get (0)->GetObject<ThreeGppHttpClient> ();
427  NS_TEST_ASSERT_MSG_NE (httpClient, 0,
428  "HTTP client installation fails to produce a proper type");
429 
430  // Uplink (requests) trace sources.
431  bool traceSourceConnected = httpClient->TraceConnectWithoutContext (
432  "TxMainObjectRequest",
434  this));
435  NS_ASSERT (traceSourceConnected);
436  traceSourceConnected = httpClient->TraceConnectWithoutContext (
437  "TxEmbeddedObjectRequest",
439  this));
440  NS_ASSERT (traceSourceConnected);
441  traceSourceConnected = httpServer->TraceConnectWithoutContext (
442  "Rx",
444  this));
445  NS_ASSERT (traceSourceConnected);
446 
447  // Downlink (main objects) trace sources.
448  traceSourceConnected = httpServer->TraceConnectWithoutContext (
449  "MainObject",
451  this));
452  NS_ASSERT (traceSourceConnected);
453  traceSourceConnected = httpClient->TraceConnectWithoutContext (
454  "RxMainObjectPacket",
456  this));
457  NS_ASSERT (traceSourceConnected);
458  traceSourceConnected = httpClient->TraceConnectWithoutContext (
459  "RxMainObject",
461  this));
462  NS_ASSERT (traceSourceConnected);
463 
464  // Downlink (embedded objects) trace sources.
465  traceSourceConnected = httpServer->TraceConnectWithoutContext (
466  "EmbeddedObject",
468  this));
469  NS_ASSERT (traceSourceConnected);
470 
471  traceSourceConnected = httpClient->TraceConnectWithoutContext (
472  "RxEmbeddedObjectPacket",
474  this));
475  NS_ASSERT (traceSourceConnected);
476 
477  traceSourceConnected = httpClient->TraceConnectWithoutContext (
478  "RxEmbeddedObject",
480  this));
481  NS_ASSERT (traceSourceConnected);
482 
483  // Other trace sources.
484  traceSourceConnected = httpClient->TraceConnectWithoutContext (
485  "StateTransition",
487  this));
488  NS_ASSERT (traceSourceConnected);
489  traceSourceConnected = httpClient->TraceConnectWithoutContext (
490  "RxDelay",
492  this));
493  NS_ASSERT (traceSourceConnected);
494  traceSourceConnected = httpClient->TraceConnectWithoutContext (
495  "RxRtt",
497  this));
498  NS_ASSERT (traceSourceConnected);
499 
500  Simulator::Schedule (Seconds (1.0), &ThreeGppHttpObjectTestCase::ProgressCallback, this);
501 
502  /*
503  * Here we don't set the simulation stop time. During the run, the simulation
504  * will stop immediately after the client has completely received the third
505  * web page.
506  */
507  Simulator::Run ();
508 
509  // Dump some statistical information about the simulation.
510  NS_LOG_INFO (this << " Total request objects received: "
512  << " object(s).");
513  NS_LOG_INFO (this << " Total main objects received: "
515  << " object(s).");
516  NS_LOG_INFO (this << " Total embedded objects received: "
518  << " object(s).");
519  NS_LOG_INFO (this << " One-trip delays:"
520  << " average=" << m_delayCalculator->getMean ()
521  << " min=" << m_delayCalculator->getMin ()
522  << " max=" << m_delayCalculator->getMax ());
523  NS_LOG_INFO (this << " Round-trip delays:"
524  << " average=" << m_rttCalculator->getMean ()
525  << " min=" << m_rttCalculator->getMin ()
526  << " max=" << m_rttCalculator->getMax ());
527  NS_LOG_INFO (this << " Number of packets dropped by the devices: "
528  << m_numOfPacketDrops << " packet(s).");
529 
530  // Some post-simulation tests.
532  "Unexpected number of web pages processed.");
534  "Tracker of request objects detected irrelevant packet(s).");
536  "Tracker of main objects detected irrelevant packet(s).");
538  "Tracker of embedded objects detected irrelevant packet(s).");
539 
540  Simulator::Destroy ();
541 
542 } // end of `void HttpClientServerTestCase::DoRun ()`
543 
544 void
546 {
547  NS_LOG_FUNCTION (this << GetName ());
548 }
549 
551  : m_rxBuffer (0),
552  m_numOfObjectsReceived (0)
553 {
554  NS_LOG_FUNCTION (this);
555 }
556 
557 void
559 {
560  NS_LOG_FUNCTION (this << size);
561  m_objectsSize.push_back (size);
562 }
563 
564 void
566 {
567  NS_LOG_FUNCTION (this << size);
568  m_rxBuffer += size;
569 }
570 
571 bool
573  uint32_t &rxSize)
574 {
575  NS_LOG_FUNCTION (this);
576 
577  if (m_objectsSize.empty ())
578  {
579  return false;
580  }
581 
582  // Set output values.
583  txSize = m_objectsSize.front ();
584  rxSize = m_rxBuffer;
585 
586  // Reset counters.
587  m_objectsSize.pop_front ();
588  m_rxBuffer = 0;
589  m_numOfObjectsReceived++;
590 
591  return true;
592 }
593 
594 bool
596 {
597  return (m_objectsSize.empty () && (m_rxBuffer == 0));
598 }
599 
600 uint16_t
602 {
603  return m_numOfObjectsReceived;
604 }
605 
606 void
608 {
609  NS_LOG_FUNCTION (this << packet << packet->GetSize ());
611 }
612 
613 void
615 {
616  NS_LOG_FUNCTION (this << packet << packet->GetSize ());
618 }
619 
620 void
622  const Address &from)
623 {
624  NS_LOG_FUNCTION (this << packet << packet->GetSize () << from);
625 
626  // Check the header in packet
627  Ptr<Packet> copy = packet->Copy ();
628  ThreeGppHttpHeader httpHeader;
629  NS_TEST_ASSERT_MSG_EQ (copy->RemoveHeader (httpHeader), 22,
630  "Error finding ThreeGppHttpHeader in a packet received by the server");
631  NS_TEST_ASSERT_MSG_GT (httpHeader.GetClientTs (), Seconds (0.0),
632  "Request object's client TS is unexpectedly non-positive");
633 
635 
636  /*
637  * Request objects are assumed to be small and to not typically split. So we
638  * immediately follow by concluding the receive of a whole request object.
639  */
640  uint32_t txSize;
641  uint32_t rxSize;
642  bool isSent = m_requestObjectTracker.ObjectReceived (txSize, rxSize);
643  NS_TEST_ASSERT_MSG_EQ (isSent, true,
644  "Server receives one too many request object");
645  NS_TEST_ASSERT_MSG_EQ (txSize, rxSize,
646  "Transmitted size and received size of request object differ");
647 }
648 
649 void
651 {
652  NS_LOG_FUNCTION (this << size);
654 }
655 
656 void
658 {
659  NS_LOG_FUNCTION (this << packet << packet->GetSize ());
661 }
662 
663 void
665  Ptr<const Packet> packet)
666 {
667  NS_LOG_FUNCTION (this << httpClient << httpClient->GetNode ()->GetId ());
668 
669  // Verify the header in the packet.
670  Ptr<Packet> copy = packet->Copy ();
671  ThreeGppHttpHeader httpHeader;
672  NS_TEST_ASSERT_MSG_EQ (copy->RemoveHeader (httpHeader), 22,
673  "Error finding ThreeGppHttpHeader in a packet received by the server");
674  NS_TEST_ASSERT_MSG_EQ (httpHeader.GetContentType (), ThreeGppHttpHeader::MAIN_OBJECT,
675  "Invalid content type in the received packet");
676  NS_TEST_ASSERT_MSG_GT (httpHeader.GetClientTs (), Seconds (0.0),
677  "Main object's client TS is unexpectedly non-positive");
678  NS_TEST_ASSERT_MSG_GT (httpHeader.GetServerTs (), Seconds (0.0),
679  "Main object's server TS is unexpectedly non-positive");
680  uint32_t txSize;
681  uint32_t rxSize;
682  bool isSent = m_mainObjectTracker.ObjectReceived (txSize, rxSize);
683  NS_TEST_ASSERT_MSG_EQ (isSent, true,
684  "Client receives one too many main object");
685  NS_TEST_ASSERT_MSG_EQ (txSize, rxSize,
686  "Transmitted size and received size of main object differ");
687  NS_TEST_ASSERT_MSG_EQ (httpHeader.GetContentLength (), rxSize,
688  "Actual main object packet size and received size of main object differ");
689 }
690 
691 void
693 {
694  NS_LOG_FUNCTION (this << size);
696 }
697 
698 void
700 {
701  NS_LOG_FUNCTION (this << packet << packet->GetSize ());
703 }
704 
705 void
707  Ptr<const Packet> packet)
708 {
709  NS_LOG_FUNCTION (this << httpClient << httpClient->GetNode ()->GetId ());
710 
711  // Verify the header in the packet.
712  Ptr<Packet> copy = packet->Copy ();
713  ThreeGppHttpHeader httpHeader;
714  NS_TEST_ASSERT_MSG_EQ (copy->RemoveHeader (httpHeader), 22,
715  "Error finding ThreeGppHttpHeader in a packet received by the server");
716  NS_TEST_ASSERT_MSG_EQ (httpHeader.GetContentType (), ThreeGppHttpHeader::EMBEDDED_OBJECT,
717  "Invalid content type in the received packet");
718  NS_TEST_ASSERT_MSG_GT (httpHeader.GetClientTs (), Seconds (0.0),
719  "Embedded object's client TS is unexpectedly non-positive");
720  NS_TEST_ASSERT_MSG_GT (httpHeader.GetServerTs (), Seconds (0.0),
721  "Embedded object's server TS is unexpectedly non-positive");
722 
723  uint32_t txSize;
724  uint32_t rxSize;
725  bool isSent = m_embeddedObjectTracker.ObjectReceived (txSize, rxSize);
726  NS_TEST_ASSERT_MSG_EQ (isSent, true,
727  "Client receives one too many embedded object");
728  NS_TEST_ASSERT_MSG_EQ (txSize, rxSize,
729  "Transmitted size and received size of embedded object differ");
730  NS_TEST_ASSERT_MSG_EQ (httpHeader.GetContentLength (), rxSize,
731  "Actual embedded object packet size and received size of embedded object differ");
732 }
733 
734 void
736  const std::string &newState)
737 {
738  NS_LOG_FUNCTION (this << oldState << newState);
739 
740  if (newState == "READING")
741  {
743 
744  if (m_numOfPagesReceived >= 3)
745  {
746  // We have processed 3 web pages and that should be enough for this test.
747  NS_LOG_LOGIC (this << " Test is stopping now.");
748  Simulator::Stop ();
749  }
750  }
751 }
752 
753 void
755 {
756  NS_LOG_INFO ("Simulator time now: " << Simulator::Now ().As (Time::S) << ".");
757  Simulator::Schedule (Seconds (1.0), &ThreeGppHttpObjectTestCase::ProgressCallback, this);
758 }
759 
760 void
762  const Address &from)
763 {
764  NS_LOG_FUNCTION (this << delay.As (Time::S) << from);
765  m_delayCalculator->Update (delay.GetSeconds ());
766 }
767 
768 void
770  const Address &from)
771 {
772  NS_LOG_FUNCTION (this << rtt.As (Time::S) << from);
774 }
775 
776 void
778 {
779  NS_LOG_FUNCTION (this << packet << packet->GetSize ());
781 }
782 
783 
784 // TEST SUITE /////////////////////////////////////////////////////////////////
785 
803 {
804 public:
806  ThreeGppHttpClientServerTestSuite () : TestSuite ("three-gpp-http-client-server-test", SYSTEM)
807  {
808  // LogComponentEnable ("ThreeGppHttpClientServerTest", LOG_INFO);
809  // LogComponentEnable ("ThreeGppHttpClient", LOG_INFO);
810  // LogComponentEnable ("ThreeGppHttpServer", LOG_INFO);
811  // LogComponentEnableAll (LOG_PREFIX_ALL);
812 
813  Time channelDelay[] = {
814  MilliSeconds (3),
815  MilliSeconds (30),
816  MilliSeconds (300)
817  };
818  double bitErrorRate[] = {0.0, 5.0e-6};
819  uint32_t mtuSize[] = {536, 1460};
820 
821  uint32_t run = 1;
822  while (run <= 100)
823  {
824  for (uint32_t i1 = 0; i1 < 3; i1++)
825  {
826  for (uint32_t i2 = 0; i2 < 2; i2++)
827  {
828  for (uint32_t i3 = 0; i3 < 2; i3++)
829  {
830  AddHttpObjectTestCase (run++,
831  channelDelay[i1],
832  bitErrorRate[i2],
833  mtuSize[i3],
834  false);
835  AddHttpObjectTestCase (run++,
836  channelDelay[i1],
837  bitErrorRate[i2],
838  mtuSize[i3],
839  true);
840  }
841  }
842  }
843  }
844  }
845 
846 private:
862  void AddHttpObjectTestCase (uint32_t rngRun,
863  const Time &channelDelay,
864  double bitErrorRate,
865  uint32_t mtuSize,
866  bool useIpv6)
867  {
868  std::ostringstream name;
869  name << "Run #" << rngRun;
870  name << " delay=" << channelDelay.As (Time::MS);
871  name << " ber=" << bitErrorRate;
872  name << " mtu=" << mtuSize;
873 
874  if (useIpv6)
875  {
876  name << " IPv6";
877  }
878  else
879  {
880  name << " IPv4";
881  }
882 
883  // Assign higher fullness for tests with higher RngRun.
884  TestCase::TestDuration testDuration = TestCase::QUICK;
885  if (rngRun > 20)
886  {
887  testDuration = TestCase::EXTENSIVE;
888  }
889  if (rngRun > 50)
890  {
891  testDuration = TestCase::TAKES_FOREVER;
892  }
893 
894  AddTestCase (new ThreeGppHttpObjectTestCase (name.str (),
895  rngRun,
896  TcpNewReno::GetTypeId (),
897  channelDelay,
898  bitErrorRate,
899  mtuSize,
900  useIpv6),
901  testDuration);
902  }
903 
904 }; // end of class `ThreeGppHttpClientServerTestSuite`
905 
908 
uint16_t m_numOfPagesReceived
Begins with 0. Simulation stops if this reaches 3.
holds a vector of ns3::Application pointers.
void ClientRxDelayCallback(const Time &delay, const Address &from)
Connected with RxDelay trace source of the client.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
ContentType_t GetContentType() const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
ApplicationContainer Install(NodeContainer c) const
Install an ThreeGppHttpServer on each node of the input container configured with all the attributes ...
Helper to make it easier to instantiate an ThreeGppHttpClient on a set of nodes.
uint32_t GetId(void) const
Definition: node.cc:109
Keep track of a set of IPv6 interfaces.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
A test class for running several system tests which validate the web browsing traffic model...
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
Model application which simulates the traffic of a web server.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:269
uint16_t m_numOfPacketDrops
Number of packets dropped because of m_errorModel.
A suite of tests to run.
Definition: test.h:1343
uint32_t m_rngRun
Determines the set of random values generated.
ThreeGppHttpObjectTracker()
Creates a new instance with all counters begin at zero.
static ThreeGppHttpClientServerTestSuite g_httpClientServerTestSuiteInstance
The global instance of the three-gpp-http-client-server system test.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
ThreeGppHttpObjectTracker m_mainObjectTracker
Tracker of main objects.
void AddHttpObjectTestCase(uint32_t rngRun, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6)
Creates a test case with the given parameters.
uint16_t m_numOfObjectsReceived
Number of whole objects that have been received so far.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
double getMin() const
Returns the minimum value.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1286
Helper to make it easier to instantiate an ThreeGppHttpServer on a set of nodes.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
Ptr< MinMaxAvgTotalCalculator< double > > m_delayCalculator
Keeps statistical information of one-trip delays (in seconds).
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Header used by web browsing applications to transmit information about content type, content length and timestamps for delay statistics.
void ObjectSent(uint32_t size)
Shall be invoked when a whole object has been transmitted.
uint32_t m_rxBuffer
The accumulated size (in bytes) of parts of a whole object.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
void ClientStateTransitionCallback(const std::string &oldState, const std::string &newState)
Connected with StateTransition trace source of the client.
encapsulates test code
Definition: test.h:1153
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:389
void ClientRxRttCallback(const Time &rtt, const Address &from)
Connected with RxRtt trace source of the client.
virtual void DoTeardown()
Implementation to do any local setup required for this TestCase.
Ptr< Node > CreateSimpleInternetNode(Ptr< SimpleChannel > channel, Address &assignedAddress)
Creates a Node, complete with a TCP/IP stack and address assignment.
ThreeGppHttpObjectTracker m_requestObjectTracker
Tracker of request objects.
ThreeGppHttpObjectTestCase(const std::string &name, uint32_t rngRun, const TypeId &tcpType, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6)
a polymophic address class
Definition: address.h:90
channel
Definition: third.py:92
TCP socket creation and multiplexing/demultiplexing.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Time m_channelDelay
Time needed by a packet to propagate.
void ClientRxEmbeddedObjectPacketCallback(Ptr< const Packet > packet)
Connected with RxEmbeddedObjectPacket trace source of the client.
bool m_useIpv6
Whether to use IPv6 or IPv4.
double getMax() const
Returns the maximum value.
A test class which verifies that each HTTP object sent is also received the same size.
void ClientRxMainObjectPacketCallback(Ptr< const Packet > packet)
Connected with RxMainObjectPacket trace source of the client.
Ptr< MinMaxAvgTotalCalculator< double > > m_rttCalculator
Keeps statistical information of round-trip delays (in seconds).
bool ObjectReceived(uint32_t &txSize, uint32_t &rxSize)
Shall be invoked after all parts of a complete object have been received.
ThreeGppHttpClientServerTestSuite()
Instantiate the test suite.
ThreeGppHttpObjectTracker m_embeddedObjectTracker
Tracker of embedded objects.
ApplicationContainer Install(NodeContainer c) const
Install a ThreeGppHttpClient on each node of the input container configured with all the attributes s...
void PartReceived(uint32_t size)
Shall be invoked when an object part has been received.
AttributeValue implementation for Time.
Definition: nstime.h:1342
Ptr< RateErrorModel > m_errorModel
Receive error model to be attached to the devices of both directions.
Ipv6AddressHelper m_ipv6AddressHelper
Assigns IPv6 addresses to the nodes.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Model application which simulates the traffic of a web browser.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
InternetStackHelper m_internetStackHelper
Installs TCP/IP stack on the nodes.
Hold an unsigned integer type.
Definition: uinteger.h:44
#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.
Definition: test.h:166
void SetRate(double rate)
Definition: error-model.cc:208
holds a vector of ns3::NetDevice pointers
AttributeValue implementation for TypeId.
Definition: type-id.h:595
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
void ClientRxMainObjectCallback(Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
Connected with RxMainObject trace source of the client.
void ClientTxMainObjectRequestCallback(Ptr< const Packet > packet)
Connected with TxMainObjectRequest trace source of the client.
Ptr< Node > GetNode() const
Definition: application.cc:104
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
TestDuration
How long the test takes to execute.
Definition: test.h:1157
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t m_mtuSize
Maximum transmission unit (in bytes).
void ServerRxCallback(Ptr< const Packet > packet, const Address &from)
Connected with Rx trace source of the server.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
void Update(const T i)
Updates all variables of MinMaxAvgTotalCalculator.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
Helper class to auto-assign global IPv6 unicast addresses.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetUnit(enum ErrorUnit error_unit)
Definition: error-model.cc:194
Describes an IPv6 address.
Definition: ipv6-address.h:49
void ClientTxEmbeddedObjectRequestCallback(Ptr< const Packet > packet)
Connected with TxEmbeddedObjectRequest trace source of the client.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
std::string GetName(void) const
Definition: test.cc:370
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
void ServerEmbeddedObjectCallback(uint32_t size)
Connected with EmbeddedObject trace source of the server.
#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...
Definition: test.h:622
void SetGlobal(std::string name, const AttributeValue &value)
Definition: config.cc:889
bool IsPositive(void) const
Exactly equivalent to t >= 0.
Definition: nstime.h:316
std::list< uint32_t > m_objectsSize
Each entry is the size (in bytes) of object transmitted.
virtual void SetAddress(Address address)
Set the address of this interface.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1278
virtual void DoRun()
Implementation to actually run this TestCase.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
double getMean() const
Returns the mean value.
#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.
Definition: test.h:995
void ServerMainObjectCallback(uint32_t size)
Connected with MainObject trace source of the server.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
a unique identifier for an interface.
Definition: type-id.h:58
void ClientRxEmbeddedObjectCallback(Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
Connected with RxEmbeddedObject trace source of the client.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
uint32_t GetN(void) const
Get the number of Ptr<Application> stored in this container.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void DeviceDropCallback(Ptr< const Packet > packet)
Connected with PhyRxDrop trace source of both the client&#39;s and server&#39;s devices.
Ipv4AddressHelper m_ipv4AddressHelper
Assigns IPv4 addresses to the nodes.