|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #include "ns3/simulator.h"
26 #include "ns3/lte-helper.h"
27 #include "ns3/point-to-point-epc-helper.h"
28 #include "ns3/packet-sink-helper.h"
29 #include "ns3/udp-client-server-helper.h"
30 #include "ns3/udp-echo-helper.h"
31 #include "ns3/point-to-point-helper.h"
32 #include "ns3/internet-stack-helper.h"
33 #include "ns3/ipv4-address-helper.h"
34 #include "ns3/inet-socket-address.h"
35 #include "ns3/packet-sink.h"
36 #include <ns3/ipv4-static-routing-helper.h>
37 #include <ns3/ipv4-static-routing.h>
38 #include "ns3/boolean.h"
39 #include "ns3/uinteger.h"
40 #include "ns3/double.h"
41 #include "ns3/abort.h"
42 #include "ns3/mobility-helper.h"
83 interPacketInterval (
Seconds (i))
96 std::vector<UeTestData>
ues;
121 virtual void DoRun (
void);
163 remoteHostContainer.
Create (1);
166 internet.
Install (remoteHostContainer);
175 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
202 uint16_t ulPort = 1000;
204 for (std::vector<EnbTestData>::iterator enbit =
m_enbTestData.begin ();
206 ++enbit, ++enbLteDevIt)
213 ues.
Create (enbit->ues.size ());
229 for (uint32_t u = 0; u < ues.
GetN (); ++u)
241 lteHelper->
Attach (ueLteDevice, *enbLteDevIt);
244 uint16_t dlPort = 2000;
245 for (uint32_t b = 0; b < enbit->ues.at (u).bearers.size (); ++b)
247 BearerTestData& bearerTestData = enbit->ues.at (u).bearers.at (b);
260 apps = client.Install (remoteHost);
276 apps = client.Install (ue);
281 EpsBearer epsBearer (EpsBearer::NGBR_VOICE_VIDEO_GAMING);
300 Config::Set (
"/NodeList/*/DeviceList/*/LteEnbRrc/UeMap/*/RadioBearerMap/*/LteRlc/MaxTxBufferSize",
302 Config::Set (
"/NodeList/*/DeviceList/*/LteUeRrc/RadioBearerMap/*/LteRlc/MaxTxBufferSize",
306 double statsStartTime = 0.040;
307 double statsDuration = 2.0;
315 Simulator::Stop (
Seconds (statsStartTime + statsDuration - 0.0001));
318 uint64_t imsiCounter = 0;
320 for (std::vector<EnbTestData>::iterator enbit =
m_enbTestData.begin ();
324 for (std::vector<UeTestData>::iterator ueit = enbit->ues.begin ();
325 ueit < enbit->ues.end ();
328 uint64_t imsi = ++imsiCounter;
329 for (uint32_t b = 0; b < ueit->bearers.size (); ++b)
334 uint32_t expectedPkts = ueit->bearers.at (b).numPkts;
335 uint32_t expectedBytes = (ueit->bearers.at (b).numPkts) * (ueit->bearers.at (b).pktSize);
336 uint32_t txPktsPdcpDl = lteHelper->
GetPdcpStats ()->GetDlTxPackets (imsi, lcid);
337 uint32_t rxPktsPdcpDl = lteHelper->
GetPdcpStats ()->GetDlRxPackets (imsi, lcid);
338 uint32_t txPktsPdcpUl = lteHelper->
GetPdcpStats ()->GetUlTxPackets (imsi, lcid);
339 uint32_t rxPktsPdcpUl = lteHelper->
GetPdcpStats ()->GetUlRxPackets (imsi, lcid);
340 uint32_t rxBytesDl = ueit->bearers.at (b).dlServerApp->GetTotalRx ();
341 uint32_t rxBytesUl = ueit->bearers.at (b).ulServerApp->GetTotalRx ();
346 "wrong TX PDCP packets in downlink for IMSI=" << imsi <<
" LCID=" << (uint16_t) lcid);
350 "wrong RX PDCP packets in downlink for IMSI=" << imsi <<
" LCID=" << (uint16_t) lcid);
353 "wrong TX PDCP packets in uplink for IMSI=" << imsi <<
" LCID=" << (uint16_t) lcid);
356 "wrong RX PDCP packets in uplink for IMSI=" << imsi <<
" LCID=" << (uint16_t) lcid);
360 "wrong total received bytes in downlink");
363 "wrong total received bytes in uplink");
368 Simulator::Destroy ();
391 std::vector<EnbTestData> v1;
396 e1.
ues.push_back (u1);
400 std::vector<EnbTestData> v2;
405 e2.
ues.push_back (u2_1);
409 e2.
ues.push_back (u2_2);
413 std::vector<EnbTestData> v3;
422 e4.
ues.push_back (u4_1);
426 e4.
ues.push_back (u4_2);
430 e4.
ues.push_back (u4_3);
431 std::vector<EnbTestData> v4;
441 e5.
ues.push_back (u5);
442 std::vector<EnbTestData> v5;
451 e6.
ues.push_back (u6);
452 std::vector<EnbTestData> v6;
462 e7.
ues.push_back (u7);
463 std::vector<EnbTestData> v7;
471 e8.
ues.push_back (u8);
472 std::vector<EnbTestData> v8;
481 e9.
ues.push_back (u9);
482 std::vector<EnbTestData> v9;
holds a vector of ns3::NetDevice pointers
static Vector GetPosition(Ptr< Node > node)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AttributeValue implementation for DataRate.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
uint16_t remotePortStart
start of the port number range of the remote host
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void Set(std::string path, const AttributeValue &value)
Ptr< Application > dlClientApp
the DL client app
AttributeValue implementation for Boolean.
virtual Ptr< Node > GetPgwNode() const
Get the PGW node.
BearerTestData(uint32_t n, uint32_t s, double i)
Constructor.
Test that e2e packet flow is correct.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Create a set of eNodeB devices.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Create an application which sends a UDP packet and waits for an echo of this packet.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
NetDeviceContainer InstallUeDevice(NodeContainer c)
Create a set of UE devices.
std::string GetName(void) const
uint16_t remotePortEnd
end of the port number range of the remote host
uint8_t Add(PacketFilter f)
add a PacketFilter to the Traffic Flow Template
NetDeviceContainer Install(NodeContainer c)
Ipv4 addresses are stored in host order in this class.
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< PacketSink > ulServerApp
the UL server app
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
virtual ~LteEpcE2eDataTestCase()
virtual Ipv4Address GetUeDefaultGatewayAddress()
Test that the S1-U interface implementation works correctly.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Access to the IPv4 forwarding table, interfaces, and configuration.
Helper class that adds ns3::Ipv4StaticRouting objects.
Class for representing data rates.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Ptr< RadioBearerStatsCalculator > GetPdcpStats(void)
void SetEpcHelper(Ptr< EpcHelper > h)
Set the EpcHelper to be used to setup the EPC network in conjunction with the setup of the LTE radio ...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
virtual Ipv4InterfaceContainer AssignUeIpv4Address(NetDeviceContainer ueDevices)
Assign IPv4 addresses to UE devices.
Time interPacketInterval
the inter packet interval time
uint32_t numPkts
the number of packets
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
std::vector< EnbTestData > m_enbTestData
the ENB test data
LteEpcE2eDataTestCase(std::string name, std::vector< EnbTestData > v)
Constructor.
uint8_t ActivateDedicatedEpsBearer(NetDeviceContainer ueDevices, EpsBearer bearer, Ptr< EpcTft > tft)
Activate a dedicated EPS bearer on a given set of UE devices.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
std::vector< UeTestData > ues
the list of UEs
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< Application > ulClientApp
the UL client app
LteEpcE2eDataTestSuite g_lteEpcE2eDataTestSuite
the test suite
Hold variables of type string.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
#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.
This class contains the specification of EPS Bearers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
void EnablePdcpTraces(void)
Enable trace sinks for PDCP layer.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
holds a vector of ns3::Application pointers.
uint32_t pktSize
packet size used for the simulation (in bytes)
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 ",...
Build a set of PointToPointNetDevice objects.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
a class to represent an Ipv4 address mask
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
void Attach(NetDeviceContainer ueDevices)
Enables automatic attachment of a set of UE devices to a suitable cell using Idle mode initial cell s...
Receive and consume traffic generated to an IP address and port.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
uint16_t localPortStart
start of the port number range of the UE
Hold an unsigned integer type.
uint32_t pktSize
the packet size
void SetDefault(std::string name, const AttributeValue &value)
Ptr< PacketSink > dlServerApp
the DL server app
aggregate IP/TCP/UDP functionality to existing Nodes.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Helper class used to assign positions and mobility models to nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
uint16_t localPortEnd
end of the port number range of the UE
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
std::vector< BearerTestData > bearers
the bearer test data