27 #include "ns3/simulator.h"
30 #include "ns3/epc-helper.h"
31 #include "ns3/epc-enb-application.h"
32 #include "ns3/packet-sink-helper.h"
33 #include "ns3/point-to-point-helper.h"
34 #include "ns3/csma-helper.h"
35 #include "ns3/internet-stack-helper.h"
36 #include "ns3/ipv4-address-helper.h"
37 #include "ns3/inet-socket-address.h"
38 #include "ns3/packet-sink.h"
39 #include <ns3/ipv4-static-routing-helper.h>
40 #include <ns3/ipv4-static-routing.h>
41 #include <ns3/ipv4-interface.h>
42 #include <ns3/mac48-address.h>
43 #include "ns3/seq-ts-header.h"
44 #include "ns3/eps-bearer-tag.h"
45 #include "ns3/arp-cache.h"
46 #include "ns3/boolean.h"
47 #include "ns3/uinteger.h"
48 #include "ns3/config.h"
49 #include "lte-test-entities.h"
92 void ScheduleTransmit (
Time dt);
113 EpsBearerTagUdpClient::GetTypeId (
void)
115 static TypeId tid =
TypeId (
"ns3::EpsBearerTagUdpClient")
117 .AddConstructor<EpsBearerTagUdpClient> ()
118 .AddAttribute (
"MaxPackets",
119 "The maximum number of packets the application will send",
121 MakeUintegerAccessor (&EpsBearerTagUdpClient::m_count),
122 MakeUintegerChecker<uint32_t> ())
123 .AddAttribute (
"Interval",
125 MakeTimeAccessor (&EpsBearerTagUdpClient::m_interval),
129 "The destination Ipv4Address of the outbound packets",
131 MakeIpv4AddressAccessor (&EpsBearerTagUdpClient::m_peerAddress),
132 MakeIpv4AddressChecker ())
133 .AddAttribute (
"RemotePort",
"The destination port of the outbound packets",
135 MakeUintegerAccessor (&EpsBearerTagUdpClient::m_peerPort),
136 MakeUintegerChecker<uint16_t> ())
137 .AddAttribute (
"PacketSize",
138 "Size of packets generated. The minimum packet size is 12 bytes which is the size of the header carrying the sequence number and the time stamp.",
140 MakeUintegerAccessor (&EpsBearerTagUdpClient::m_size),
141 MakeUintegerChecker<uint32_t> ())
146 EpsBearerTagUdpClient::EpsBearerTagUdpClient ()
153 m_sendEvent = EventId ();
156 EpsBearerTagUdpClient::EpsBearerTagUdpClient (uint16_t rnti, uint8_t bid)
163 m_sendEvent = EventId ();
166 EpsBearerTagUdpClient::~EpsBearerTagUdpClient ()
210 EpsBearerTagUdpClient::Send (
void)
217 p->AddHeader (seqTs);
220 p->AddPacketTag (tag);
222 if ((m_socket->
Send (p)) >= 0)
225 NS_LOG_INFO (
"TraceDelay TX " << m_size <<
" bytes to "
226 << m_peerAddress <<
" Uid: " << p->GetUid ()
232 NS_LOG_INFO (
"Error while sending " << m_size <<
" bytes to "
236 if (m_sent < m_count)
246 UeUlTestData (uint32_t n, uint32_t s, uint16_t r, uint8_t l);
257 UeUlTestData::UeUlTestData (uint32_t n, uint32_t s, uint16_t r, uint8_t l)
267 std::vector<UeUlTestData> ues;
278 virtual void DoRun (
void);
279 std::vector<EnbUlTestData> m_enbUlTestData;
283 EpcS1uUlTestCase::EpcS1uUlTestCase (std::string name, std::vector<EnbUlTestData> v)
289 EpcS1uUlTestCase::~EpcS1uUlTestCase ()
297 Ptr<Node> pgw = epcHelper->GetPgwNode ();
302 epcHelper->SetAttribute (
"S1uLinkMtu",
UintegerValue (30000));
306 remoteHostContainer.
Create (1);
309 internet.
Install (remoteHostContainer);
316 ipv4h.
SetBase (
"1.0.0.0",
"255.0.0.0");
324 remoteHostStaticRouting->AddNetworkRouteTo (
Ipv4Address (
"7.0.0.0"),
Ipv4Mask (
"255.255.255.0"), 1);
328 uint16_t udpSinkPort = 1234;
331 uint16_t cellIdCounter = 0;
333 for (std::vector<EnbUlTestData>::iterator enbit = m_enbUlTestData.begin ();
334 enbit < m_enbUlTestData.end ();
344 uint16_t cellId = ++cellIdCounter;
347 ues.
Create (enbit->ues.size ());
360 epcHelper->AddEnb (enb, enbDevice, cellId);
364 NS_ASSERT_MSG (enbApp != 0,
"cannot retrieve EpcEnbApplication");
366 rrc->SetS1SapProvider (enbApp->GetS1SapProvider ());
367 enbApp->SetS1SapUser (rrc->GetS1SapUser ());
374 for (uint32_t u = 0; u < ues.
GetN (); ++u)
385 ueIpv4->SetAttribute (
"IpForward",
BooleanValue (
false));
389 Ipv4Address gwAddr = epcHelper->GetUeDefaultGatewayAddress ();
391 ueStaticRouting->SetDefaultRoute (gwAddr, 1);
398 int32_t ueLteIpv4IfIndex = ueIpv4->GetInterfaceForDevice (ueLteDevice);
400 Ptr<Ipv4Interface> ueLteIpv4Iface = ueIpv4L3Protocol->GetInterface (ueLteIpv4IfIndex);
402 ueArpCache->SetAliveTimeout (
Seconds (1000));
413 enbit->ues[u].serverApp = sinkApp.
Get (0)->GetObject<
PacketSink> ();
418 client->SetAttribute (
"RemotePort",
UintegerValue (udpSinkPort));
419 client->SetAttribute (
"MaxPackets",
UintegerValue (enbit->ues[u].numPkts));
420 client->SetAttribute (
"Interval",
TimeValue (interPacketInterval));
421 client->SetAttribute (
"PacketSize",
UintegerValue (enbit->ues[u].pktSize));
424 clientApp.
Add (client);
427 enbit->ues[u].clientApp = client;
430 epcHelper->AddUe (ueLteDevice, imsi);
431 epcHelper->ActivateEpsBearer (ueLteDevice, imsi,
EpcTft::Default (),
EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT));
432 enbApp->GetS1SapProvider ()->InitialUeMessage (imsi, (uint16_t) imsi);
442 for (std::vector<EnbUlTestData>::iterator enbit = m_enbUlTestData.begin ();
443 enbit < m_enbUlTestData.end ();
446 for (std::vector<UeUlTestData>::iterator ueit = enbit->ues.begin ();
447 ueit < enbit->ues.end ();
450 NS_TEST_ASSERT_MSG_EQ (ueit->serverApp->GetTotalRx (), (ueit->numPkts) * (ueit->pktSize),
"wrong total received bytes");
469 } g_epcS1uUlTestSuiteInstance;
471 EpcS1uUlTestSuite::EpcS1uUlTestSuite ()
474 std::vector<EnbUlTestData> v1;
477 e1.ues.push_back (f1);
482 std::vector<EnbUlTestData> v2;
485 e2.ues.push_back (f2_1);
487 e2.ues.push_back (f2_2);
492 std::vector<EnbUlTestData> v3;
500 e3.ues.push_back (f3_1);
502 e3.ues.push_back (f3_2);
504 e3.ues.push_back (f3_2);
505 std::vector<EnbUlTestData> v4;
511 std::vector<EnbUlTestData> v5;
514 e5.ues.push_back (f5);
518 std::vector<EnbUlTestData> v6;
521 e6.ues.push_back (f6);
525 std::vector<EnbUlTestData> v7;
528 e7.ues.push_back (f7);
532 std::vector<EnbUlTestData> v8;
535 e8.ues.push_back (f8);
holds a vector of ns3::Application pointers.
uint32_t AddApplication(Ptr< Application > application)
static Ipv4Address GetAny(void)
ArpCache::Entry * Add(Ipv4Address to)
Add an Ipv4Address to this ARP cache.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
NetDeviceContainer Install(NodeContainer c)
a class to represent an Ipv4 address mask
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
static Ptr< EpcTft > Default()
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
aggregate IP/TCP/UDP functionality to existing Nodes.
NetDeviceContainer Install(Ptr< Node > node) const
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
static void Cancel(const EventId &id)
#define NS_LOG_FUNCTION_NOARGS()
Build a set of PointToPointNetDevice objects.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
virtual void StopApplication(void)
Application specific shutdown code.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
Class for representing data rates.
virtual void DoRun(void)
Implementation to actually run this test case.
Ptr< Application > GetApplication(uint32_t index) const
void SetRemote(Ipv4Address ip, uint16_t port)
set the remote address and port
The base class for all ns3 applications.
hold objects of type ns3::Time
void MarkWaitReply(Ptr< Packet > waiting)
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Ptr< Node > GetNode() const
static Mac48Address GetBroadcast(void)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
static void Destroy(void)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Access to the Ipv4 forwarding table, interfaces, and configuration.
virtual void DoDispose(void)
void SetDefault(std::string name, const AttributeValue &value)
Implement the Ipv4 layer.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
keep track of a set of node pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void MarkAlive(Address macAddress)
Callback< R > MakeNullCallback(void)
void Install(std::string nodeName) const
A record that that holds information about an ArpCache entry.
hold objects of type ns3::Ipv4Address
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
build a set of CsmaNetDevice objects
#define NS_ASSERT_MSG(condition, message)
Ipv4 addresses are stored in host order in this class.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
an identifier for simulation events.
Helper class that adds ns3::Ipv4StaticRouting objects.
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
ApplicationContainer Install(NodeContainer c) const
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Receive and consume traffic generated to an IP address and port.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
bool IsExpired(void) const
Ptr< T > GetObject(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
virtual void StartApplication(void)
Application specific startup code.
static TypeId LookupByName(std::string name)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
virtual void DoDispose(void)