|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
24 #include <ns3/config.h>
26 #include <ns3/nstime.h>
27 #include <ns3/integer.h>
29 #include <ns3/simple-channel.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>
40 #include <ns3/tcp-congestion-ops.h>
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>
47 #include <ns3/basic-data-calculators.h>
95 const Time &channelDelay,
115 virtual void DoRun ();
116 virtual void DoTeardown ();
133 void ObjectSent (uint32_t size);
139 void PartReceived (uint32_t size);
151 bool ObjectReceived (uint32_t &txSize, uint32_t &rxSize);
153 bool IsEmpty ()
const;
155 uint16_t GetNumOfObjectsReceived ()
const;
202 void ServerMainObjectCallback (uint32_t size);
221 void ServerEmbeddedObjectCallback (uint32_t size);
241 void ClientStateTransitionCallback (
const std::string &oldState,
242 const std::string &newState);
249 void ClientRxDelayCallback (
const Time &delay,
const Address &from);
256 void ClientRxRttCallback (
const Time &rtt,
const Address &from);
266 void ProgressCallback ();
300 const Time &channelDelay,
307 m_channelDelay (channelDelay),
310 m_numOfPagesReceived (0),
311 m_numOfPacketDrops (0)
364 NS_LOG_DEBUG (
this <<
" node is assigned to " << assignedAddress <<
".");
415 "Invalid number of HTTP servers has been installed");
418 "HTTP server installation fails to produce a proper type");
427 "Invalid number of HTTP clients has been installed");
430 "HTTP client installation fails to produce a proper type");
434 "TxMainObjectRequest",
439 "TxEmbeddedObjectRequest",
456 "RxMainObjectPacket",
474 "RxEmbeddedObjectPacket",
512 NS_LOG_INFO (
this <<
" Total request objects received: "
515 NS_LOG_INFO (
this <<
" Total main objects received: "
518 NS_LOG_INFO (
this <<
" Total embedded objects received: "
529 NS_LOG_INFO (
this <<
" Number of packets dropped by the devices: "
534 "Unexpected number of web pages processed.");
536 "Tracker of request objects detected irrelevant packet(s).");
538 "Tracker of main objects detected irrelevant packet(s).");
540 "Tracker of embedded objects detected irrelevant packet(s).");
542 Simulator::Destroy ();
554 m_numOfObjectsReceived (0)
563 m_objectsSize.push_back (size);
579 if (m_objectsSize.empty ())
585 txSize = m_objectsSize.front ();
589 m_objectsSize.pop_front ();
591 m_numOfObjectsReceived++;
599 return (m_objectsSize.empty () && (m_rxBuffer == 0));
605 return m_numOfObjectsReceived;
632 "Error finding ThreeGppHttpHeader in a packet received by the server");
634 "Request object's client TS is unexpectedly non-positive");
646 "Server receives one too many request object");
648 "Transmitted size and received size of request object differ");
675 "Error finding ThreeGppHttpHeader in a packet received by the server");
677 "Invalid content type in the received packet");
679 "Main object's client TS is unexpectedly non-positive");
681 "Main object's server TS is unexpectedly non-positive");
686 "Client receives one too many main object");
688 "Transmitted size and received size of main object differ");
690 "Actual main object packet size and received size of main object differ");
717 "Error finding ThreeGppHttpHeader in a packet received by the server");
719 "Invalid content type in the received packet");
721 "Embedded object's client TS is unexpectedly non-positive");
723 "Embedded object's server TS is unexpectedly non-positive");
729 "Client receives one too many embedded object");
731 "Transmitted size and received size of embedded object differ");
733 "Actual embedded object packet size and received size of embedded object differ");
738 const std::string &newState)
742 if (newState ==
"READING")
817 Time channelDelay[] = {
822 double bitErrorRate[] = {0.0, 5.0e-6};
823 uint32_t mtuSize[] = {536, 1460};
828 for (uint32_t i1 = 0; i1 < 3; i1++)
830 for (uint32_t i2 = 0; i2 < 2; i2++)
832 for (uint32_t i3 = 0; i3 < 2; i3++)
834 AddHttpObjectTestCase (run++,
839 AddHttpObjectTestCase (run++,
867 const Time &channelDelay,
872 std::ostringstream name;
873 name <<
"Run #" << rngRun;
874 name <<
" delay=" << channelDelay.
As (Time::MS);
875 name <<
" ber=" << bitErrorRate;
876 name <<
" mtu=" << mtuSize;
891 testDuration = TestCase::EXTENSIVE;
895 testDuration = TestCase::TAKES_FOREVER;
900 TcpNewReno::GetTypeId (),
holds a vector of ns3::NetDevice pointers
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
static ThreeGppHttpClientServerTestSuite g_httpClientServerTestSuiteInstance
The global instance of the three-gpp-http-client-server system test.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
uint32_t m_rngRun
Determines the set of random values generated.
uint16_t m_numOfPagesReceived
Begins with 0. Simulation stops if this reaches 3.
void ClientRxEmbeddedObjectPacketCallback(Ptr< const Packet > packet)
Connected with RxEmbeddedObjectPacket trace source of the client.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t GetId(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ThreeGppHttpServer on each node of the input container configured with all the attributes ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Helper to make it easier to instantiate an ThreeGppHttpServer on a set of nodes.
virtual void DoRun()
Implementation to actually run this TestCase.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
TypeId m_tcpType
TCP algorithm used.
void SetUnit(enum ErrorUnit error_unit)
void SetMtuSize(uint32_t mtuSize)
Sets the maximum transmission unit (MTU) size used by the application.
Ptr< MinMaxAvgTotalCalculator< double > > m_delayCalculator
Keeps statistical information of one-trip delays (in seconds).
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ptr< Node > CreateSimpleInternetNode(Ptr< SimpleChannel > channel, Address &assignedAddress)
Creates a Node, complete with a TCP/IP stack and address assignment.
std::string GetName(void) const
A test class for running several system tests which validate the web browsing traffic model.
double getMax() const
Returns the maximum value.
bool ObjectReceived(uint32_t &txSize, uint32_t &rxSize)
Shall be invoked after all parts of a complete object have been received.
std::list< uint32_t > m_objectsSize
Each entry is the size (in bytes) of object transmitted.
void ClientRxMainObjectPacketCallback(Ptr< const Packet > packet)
Connected with RxMainObjectPacket trace source of the client.
ApplicationContainer Install(NodeContainer c) const
Install a ThreeGppHttpClient on each node of the input container configured with all the attributes s...
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
void ClientRxDelayCallback(const Time &delay, const Address &from)
Connected with RxDelay trace source of the client.
void ClientTxMainObjectRequestCallback(Ptr< const Packet > packet)
Connected with TxMainObjectRequest trace source of the client.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
ThreeGppHttpObjectTracker m_embeddedObjectTracker
Tracker of embedded objects.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void ClientRxEmbeddedObjectCallback(Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
Connected with RxEmbeddedObject trace source of the client.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Ipv4AddressHelper m_ipv4AddressHelper
Assigns IPv4 addresses to the nodes.
Helper class to auto-assign global IPv6 unicast addresses.
Model application which simulates the traffic of a web browser.
#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.
void AddHttpObjectTestCase(uint32_t rngRun, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6)
Creates a test case with the given parameters.
virtual void SetAddress(Address address)
Set the address of this interface.
uint32_t GetN(void) const
void ClientRxRttCallback(const Time &rtt, const Address &from)
Connected with RxRtt trace source of the client.
void ClientStateTransitionCallback(const std::string &oldState, const std::string &newState)
Connected with StateTransition trace source of the client.
bool m_useIpv6
Whether to use IPv6 or IPv4.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint16_t m_numOfObjectsReceived
Number of whole objects that have been received so far.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
ThreeGppHttpClientServerTestSuite()
Instantiate the test suite.
TestDuration
How long the test takes to execute.
uint32_t GetN(void) const
ThreeGppHttpObjectTracker m_requestObjectTracker
Tracker of request objects.
double getMin() const
Returns the minimum value.
AttributeValue implementation for TypeId.
void ClientRxMainObjectCallback(Ptr< const ThreeGppHttpClient > httpClient, Ptr< const Packet > packet)
Connected with RxMainObject trace source of the client.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void ClientTxEmbeddedObjectRequestCallback(Ptr< const Packet > packet)
Connected with TxEmbeddedObjectRequest trace source of the client.
a polymophic address class
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void ProgressCallback()
Dummy event.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void PartReceived(uint32_t size)
Shall be invoked when an object part has been received.
Keep track of a set of IPv6 interfaces.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Simulation virtual time values and global simulation resolution.
Ptr< MinMaxAvgTotalCalculator< double > > m_rttCalculator
Keeps statistical information of round-trip delays (in seconds).
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
virtual void DoTeardown()
Implementation to do any local setup required for this TestCase.
uint16_t GetNumOfObjectsReceived() const
Ptr< RateErrorModel > m_errorModel
Receive error model to be attached to the devices of both directions.
void ServerRxCallback(Ptr< const Packet > packet, const Address &from)
Connected with Rx trace source of the server.
void ServerEmbeddedObjectCallback(uint32_t size)
Connected with EmbeddedObject trace source of the server.
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...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint32_t m_rxBuffer
The accumulated size (in bytes) of parts of a whole object.
uint32_t GetN(void) const
Get the number of Ptr<Application> stored in this container.
void ServerMainObjectCallback(uint32_t size)
Connected with MainObject trace source of the server.
void SetRate(double rate)
bool IsPositive(void) const
Exactly equivalent to t >= 0.
void DeviceDropCallback(Ptr< const Packet > packet)
Connected with PhyRxDrop trace source of both the client's and server's devices.
#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.
Model application which simulates the traffic of a web server.
Ipv6AddressHelper m_ipv6AddressHelper
Assigns IPv6 addresses to the nodes.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
InternetStackHelper m_internetStackHelper
Installs TCP/IP stack on the nodes.
void ObjectSent(uint32_t size)
Shall be invoked when a whole object has been transmitted.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
#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.
holds a vector of ns3::Application pointers.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
A test class which verifies that each HTTP object sent is also received the same size.
a class to represent an Ipv4 address mask
void SetGlobal(std::string name, const AttributeValue &value)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
TCP socket creation and multiplexing/demultiplexing.
uint32_t m_mtuSize
Maximum transmission unit (in bytes).
Hold an unsigned integer type.
Ptr< Node > GetNode() const
ThreeGppHttpObjectTracker m_mainObjectTracker
Tracker of main objects.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
double getMean() const
Returns the mean value.
ThreeGppHttpObjectTestCase(const std::string &name, uint32_t rngRun, const TypeId &tcpType, const Time &channelDelay, double bitErrorRate, uint32_t mtuSize, bool useIpv6)
Helper to make it easier to instantiate an ThreeGppHttpClient on a set of nodes.
Describes an IPv6 prefix.
aggregate IP/TCP/UDP functionality to existing Nodes.
ThreeGppHttpObjectTracker()
Creates a new instance with all counters begin at zero.
void Update(const T i)
Updates all variables of MinMaxAvgTotalCalculator.
uint16_t m_numOfPacketDrops
Number of packets dropped because of m_errorModel.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time m_channelDelay
Time needed by a packet to propagate.