A Discrete-Event Network Simulator
API
epc-pgw-application.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Manuel Requena <manuel.requena@cttc.es>
19  * (based on epc-sgw-pgw-application.cc)
20  */
21 
22 #include "ns3/log.h"
23 #include "ns3/abort.h"
24 #include "ns3/mac48-address.h"
25 #include "ns3/ipv4.h"
26 #include "ns3/ipv4-l3-protocol.h"
27 #include "ns3/ipv6.h"
28 #include "ns3/ipv6-header.h"
29 #include "ns3/ipv6-l3-protocol.h"
30 #include "ns3/inet-socket-address.h"
31 #include "ns3/epc-gtpu-header.h"
32 #include "ns3/epc-pgw-application.h"
33 
34 namespace ns3 {
35 
36 NS_LOG_COMPONENT_DEFINE ("EpcPgwApplication");
37 
38 
40 // UeInfo
42 
44 {
45  NS_LOG_FUNCTION (this);
46 }
47 
48 void
49 EpcPgwApplication::UeInfo::AddBearer (uint8_t bearerId, uint32_t teid, Ptr<EpcTft> tft)
50 {
51  NS_LOG_FUNCTION (this << (uint16_t) bearerId << teid << tft);
52  m_teidByBearerIdMap[bearerId] = teid;
53  return m_tftClassifier.Add (tft, teid);
54 }
55 
56 void
58 {
59  NS_LOG_FUNCTION (this << (uint16_t) bearerId);
60  std::map<uint8_t, uint32_t >::iterator it = m_teidByBearerIdMap.find (bearerId);
61  m_tftClassifier.Delete (it->second); //delete tft
62  m_teidByBearerIdMap.erase (bearerId);
63 }
64 
65 uint32_t
67 {
68  NS_LOG_FUNCTION (this << p);
69  // we hardcode DOWNLINK direction since the PGW is expected to
70  // classify only downlink packets (uplink packets will go to the
71  // internet without any classification).
72  return m_tftClassifier.Classify (p, EpcTft::DOWNLINK, protocolNumber);
73 }
74 
77 {
78  return m_sgwAddr;
79 }
80 
81 void
83 {
84  m_sgwAddr = sgwAddr;
85 }
86 
89 {
90  return m_ueAddr;
91 }
92 
93 void
95 {
96  m_ueAddr = ueAddr;
97 }
98 
101 {
102  return m_ueAddr6;
103 }
104 
105 void
107 {
108  m_ueAddr6 = ueAddr;
109 }
110 
112 // EpcPgwApplication
114 
115 TypeId
117 {
118  static TypeId tid = TypeId ("ns3::EpcPgwApplication")
119  .SetParent<Object> ()
120  .SetGroupName ("Lte")
121  .AddTraceSource ("RxFromTun",
122  "Receive data packets from internet in Tunnel NetDevice",
124  "ns3::EpcPgwApplication::RxTracedCallback")
125  .AddTraceSource ("RxFromS1u",
126  "Receive data packets from S5 Socket",
128  "ns3::EpcPgwApplication::RxTracedCallback")
129  ;
130  return tid;
131 }
132 
133 void
135 {
136  NS_LOG_FUNCTION (this);
138  m_s5uSocket = 0;
140  m_s5cSocket = 0;
141 }
142 
144  const Ptr<Socket> s5uSocket, const Ptr<Socket> s5cSocket)
145  : m_pgwS5Addr (s5Addr),
146  m_s5uSocket (s5uSocket),
147  m_s5cSocket (s5cSocket),
148  m_tunDevice (tunDevice),
149  m_gtpuUdpPort (2152), // fixed by the standard
150  m_gtpcUdpPort (2123) // fixed by the standard
151 {
152  NS_LOG_FUNCTION (this << tunDevice << s5Addr << s5uSocket << s5cSocket);
155 }
156 
158 {
159  NS_LOG_FUNCTION (this);
160 }
161 
162 bool
163 EpcPgwApplication::RecvFromTunDevice (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
164 {
165  NS_LOG_FUNCTION (this << source << dest << protocolNumber << packet << packet->GetSize ());
166  m_rxTunPktTrace (packet->Copy ());
167 
168  // get IP address of UE
169  if (protocolNumber == Ipv4L3Protocol::PROT_NUMBER)
170  {
171  Ipv4Header ipv4Header;
172  packet->PeekHeader (ipv4Header);
173  Ipv4Address ueAddr = ipv4Header.GetDestination ();
174  NS_LOG_LOGIC ("packet addressed to UE " << ueAddr);
175 
176  // find corresponding UeInfo address
177  std::map<Ipv4Address, Ptr<UeInfo> >::iterator it = m_ueInfoByAddrMap.find (ueAddr);
178  if (it == m_ueInfoByAddrMap.end ())
179  {
180  NS_LOG_WARN ("unknown UE address " << ueAddr);
181  }
182  else
183  {
184  Ipv4Address sgwAddr = it->second->GetSgwAddr ();
185  uint32_t teid = it->second->Classify (packet, protocolNumber);
186  if (teid == 0)
187  {
188  NS_LOG_WARN ("no matching bearer for this packet");
189  }
190  else
191  {
192  SendToS5uSocket (packet, sgwAddr, teid);
193  }
194  }
195  }
196  else if (protocolNumber == Ipv6L3Protocol::PROT_NUMBER)
197  {
198  Ipv6Header ipv6Header;
199  packet->PeekHeader (ipv6Header);
200  Ipv6Address ueAddr = ipv6Header.GetDestination ();
201  NS_LOG_LOGIC ("packet addressed to UE " << ueAddr);
202 
203  // find corresponding UeInfo address
204  std::map<Ipv6Address, Ptr<UeInfo> >::iterator it = m_ueInfoByAddrMap6.find (ueAddr);
205  if (it == m_ueInfoByAddrMap6.end ())
206  {
207  NS_LOG_WARN ("unknown UE address " << ueAddr);
208  }
209  else
210  {
211  Ipv4Address sgwAddr = it->second->GetSgwAddr ();
212  uint32_t teid = it->second->Classify (packet, protocolNumber);
213  if (teid == 0)
214  {
215  NS_LOG_WARN ("no matching bearer for this packet");
216  }
217  else
218  {
219  SendToS5uSocket (packet, sgwAddr, teid);
220  }
221  }
222  }
223  else
224  {
225  NS_ABORT_MSG ("Unknown IP type");
226  }
227 
228  // there is no reason why we should notify the TUN
229  // VirtualNetDevice that he failed to send the packet: if we receive
230  // any bogus packet, it will just be silently discarded.
231  const bool succeeded = true;
232  return succeeded;
233 }
234 
235 void
237 {
238  NS_LOG_FUNCTION (this << socket);
239  NS_ASSERT (socket == m_s5uSocket);
240  Ptr<Packet> packet = socket->Recv ();
241  m_rxS5PktTrace (packet->Copy ());
242 
243  GtpuHeader gtpu;
244  packet->RemoveHeader (gtpu);
245  uint32_t teid = gtpu.GetTeid ();
246 
247  SendToTunDevice (packet, teid);
248 }
249 
250 void
252 {
253  NS_LOG_FUNCTION (this << socket);
254  NS_ASSERT (socket == m_s5cSocket);
255  Ptr<Packet> packet = socket->Recv ();
256  GtpcHeader header;
257  packet->PeekHeader (header);
258  uint16_t msgType = header.GetMessageType ();
259 
260  switch (msgType)
261  {
264  break;
265 
267  DoRecvModifyBearerRequest (packet);
268  break;
269 
271  DoRecvDeleteBearerCommand (packet);
272  break;
273 
276  break;
277 
278  default:
279  NS_FATAL_ERROR ("GTP-C message not supported");
280  break;
281  }
282 }
283 
284 void
286 {
287  NS_LOG_FUNCTION (this);
288 
290  packet->RemoveHeader (msg);
291  uint64_t imsi = msg.GetImsi ();
292  uint16_t cellId = msg.GetUliEcgi ();
293  NS_LOG_DEBUG ("cellId " << cellId << " IMSI " << imsi);
294 
295  std::map<uint64_t, Ptr<UeInfo> >::iterator ueit = m_ueInfoByImsiMap.find (imsi);
296  NS_ASSERT_MSG (ueit != m_ueInfoByImsiMap.end (), "unknown IMSI " << imsi);
297  ueit->second->SetSgwAddr (m_sgwS5Addr);
298 
299  GtpcHeader::Fteid_t sgwS5cFteid = msg.GetSenderCpFteid ();
301  "Wrong interface type");
302 
304  msgOut.SetTeid (sgwS5cFteid.teid);
306 
307  GtpcHeader::Fteid_t pgwS5cFteid;
309  pgwS5cFteid.teid = sgwS5cFteid.teid;
310  pgwS5cFteid.addr = m_pgwS5Addr;
311  msgOut.SetSenderCpFteid (pgwS5cFteid);
312 
313  std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts =
315  NS_LOG_DEBUG ("BearerContextsToBeCreated size = " << bearerContexts.size ());
316 
317  std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContextsCreated;
318  for (auto &bearerContext : bearerContexts)
319  {
320  uint32_t teid = bearerContext.sgwS5uFteid.teid;
321  NS_LOG_DEBUG ("bearerId " << (uint16_t)bearerContext.epsBearerId <<
322  " SGW " << bearerContext.sgwS5uFteid.addr << " TEID " << teid);
323 
324  ueit->second->AddBearer (bearerContext.epsBearerId, teid, bearerContext.tft);
325 
327  bearerContextOut.fteid.interfaceType = GtpcHeader::S5_PGW_GTPU;
328  bearerContextOut.fteid.teid = teid;
329  bearerContextOut.fteid.addr = m_pgwS5Addr;
330  bearerContextOut.epsBearerId = bearerContext.epsBearerId;
331  bearerContextOut.bearerLevelQos = bearerContext.bearerLevelQos;
332  bearerContextOut.tft = bearerContext.tft;
333  bearerContextsCreated.push_back (bearerContextOut);
334  }
335 
336  NS_LOG_DEBUG ("BearerContextsCreated size = " << bearerContextsCreated.size ());
337  msgOut.SetBearerContextsCreated (bearerContextsCreated);
338  msgOut.SetTeid (sgwS5cFteid.teid);
339  msgOut.ComputeMessageLength ();
340 
341  Ptr<Packet> packetOut = Create <Packet> ();
342  packetOut->AddHeader (msgOut);
343  NS_LOG_DEBUG ("Send CreateSessionResponse to SGW " << sgwS5cFteid.addr);
344  m_s5cSocket->SendTo (packetOut, 0, InetSocketAddress (sgwS5cFteid.addr, m_gtpcUdpPort));
345 }
346 
347 void
349 {
350  NS_LOG_FUNCTION (this);
351 
353  packet->RemoveHeader (msg);
354  uint64_t imsi = msg.GetImsi ();
355  uint16_t cellId = msg.GetUliEcgi ();
356  NS_LOG_DEBUG ("cellId " << cellId << " IMSI " << imsi);
357 
358  std::map<uint64_t, Ptr<UeInfo> >::iterator ueit = m_ueInfoByImsiMap.find (imsi);
359  NS_ASSERT_MSG (ueit != m_ueInfoByImsiMap.end (), "unknown IMSI " << imsi);
360  ueit->second->SetSgwAddr (m_sgwS5Addr);
361 
362  std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts =
364  NS_LOG_DEBUG ("BearerContextsToBeModified size = " << bearerContexts.size ());
365 
366  for (auto &bearerContext : bearerContexts)
367  {
368  Ipv4Address sgwAddr = bearerContext.fteid.addr;
369  uint32_t teid = bearerContext.fteid.teid;
370  NS_LOG_DEBUG ("bearerId " << (uint16_t)bearerContext.epsBearerId <<
371  " SGW " << sgwAddr << " TEID " << teid);
372  }
373 
376  msgOut.SetTeid (imsi);
377  msgOut.ComputeMessageLength ();
378 
379  Ptr<Packet> packetOut = Create <Packet> ();
380  packetOut->AddHeader (msgOut);
381  NS_LOG_DEBUG ("Send ModifyBearerResponse to SGW " << m_sgwS5Addr);
383 }
384 
385 void
387 {
388  NS_LOG_FUNCTION (this);
389 
391  packet->RemoveHeader (msg);
392 
393  std::list<uint8_t> epsBearerIds;
394  for (auto &bearerContext : msg.GetBearerContexts ())
395  {
396  NS_LOG_DEBUG ("ebid " << (uint16_t) bearerContext.m_epsBearerId);
397  epsBearerIds.push_back (bearerContext.m_epsBearerId);
398  }
399 
401  msgOut.SetEpsBearerIds (epsBearerIds);
402  msgOut.SetTeid (msg.GetTeid ());
403  msgOut.ComputeMessageLength ();
404 
405  Ptr<Packet> packetOut = Create <Packet> ();
406  packetOut->AddHeader (msgOut);
407  NS_LOG_DEBUG ("Send DeleteBearerRequest to SGW " << m_sgwS5Addr);
409 }
410 
411 void
413 {
414  NS_LOG_FUNCTION (this);
415 
417  packet->RemoveHeader (msg);
418 
419  uint64_t imsi = msg.GetTeid ();
420  std::map<uint64_t, Ptr<UeInfo> >::iterator ueit = m_ueInfoByImsiMap.find (imsi);
421  NS_ASSERT_MSG (ueit != m_ueInfoByImsiMap.end (), "unknown IMSI " << imsi);
422 
423  for (auto &epsBearerId : msg.GetEpsBearerIds ())
424  {
425  // Remove de-activated bearer contexts from PGW side
426  NS_LOG_INFO ("PGW removing bearer " << (uint16_t) epsBearerId << " of IMSI " << imsi);
427  ueit->second->RemoveBearer (epsBearerId);
428  }
429 }
430 
431 
432 void
434 {
435  NS_LOG_FUNCTION (this << packet << teid);
436  NS_LOG_LOGIC ("packet size: " << packet->GetSize () << " bytes");
437 
438  uint8_t ipType;
439  packet->CopyData (&ipType, 1);
440  ipType = (ipType>>4) & 0x0f;
441 
442  uint16_t protocol = 0;
443  if (ipType == 0x04)
444  {
445  protocol = 0x0800;
446  }
447  else if (ipType == 0x06)
448  {
449  protocol = 0x86DD;
450  }
451  else
452  {
453  NS_ABORT_MSG ("Unknown IP type");
454  }
455 
457 }
458 
459 void
461 {
462  NS_LOG_FUNCTION (this << packet << sgwAddr << teid);
463 
464  GtpuHeader gtpu;
465  gtpu.SetTeid (teid);
466  // From 3GPP TS 29.281 v10.0.0 Section 5.1
467  // Length of the payload + the non obligatory GTP-U header
468  gtpu.SetLength (packet->GetSize () + gtpu.GetSerializedSize () - 8);
469  packet->AddHeader (gtpu);
470  uint32_t flags = 0;
471  m_s5uSocket->SendTo (packet, flags, InetSocketAddress (sgwAddr, m_gtpuUdpPort));
472 }
473 
474 
475 void
477 {
478  NS_LOG_FUNCTION (this << sgwS5Addr);
479  m_sgwS5Addr = sgwS5Addr;
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION (this << imsi);
486  Ptr<UeInfo> ueInfo = Create<UeInfo> ();
487  m_ueInfoByImsiMap[imsi] = ueInfo;
488 }
489 
490 void
492 {
493  NS_LOG_FUNCTION (this << imsi << ueAddr);
494  std::map<uint64_t, Ptr<UeInfo> >::iterator ueit = m_ueInfoByImsiMap.find (imsi);
495  NS_ASSERT_MSG (ueit != m_ueInfoByImsiMap.end (), "unknown IMSI" << imsi);
496  ueit->second->SetUeAddr (ueAddr);
497  m_ueInfoByAddrMap[ueAddr] = ueit->second;
498 }
499 
500 void
502 {
503  NS_LOG_FUNCTION (this << imsi << ueAddr);
504  std::map<uint64_t, Ptr<UeInfo> >::iterator ueit = m_ueInfoByImsiMap.find (imsi);
505  NS_ASSERT_MSG (ueit != m_ueInfoByImsiMap.end (), "unknown IMSI " << imsi);
506  m_ueInfoByAddrMap6[ueAddr] = ueit->second;
507  ueit->second->SetUeAddr6 (ueAddr);
508 }
509 
510 } // namespace ns3
ns3::EpcPgwApplication::AddUe
void AddUe(uint64_t imsi)
Let the PGW be aware of a new UE.
Definition: epc-pgw-application.cc:483
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::GtpcDeleteBearerCommandMessage
Definition: epc-gtpc-header.h:386
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::InetSocketAddress
an Inet address class
Definition: inet-socket-address.h:41
ns3::GtpcHeader::Fteid_t
FTEID structure.
Definition: epc-gtpc-header.h:118
ns3::GtpuHeader::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition: epc-gtpu-header.cc:71
NS_ASSERT
#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
ns3::EpcPgwApplication::DoRecvDeleteBearerCommand
void DoRecvDeleteBearerCommand(Ptr< Packet > packet)
Process Delete Bearer Command message.
Definition: epc-pgw-application.cc:386
ns3::GtpcModifyBearerResponseMessage
Definition: epc-gtpc-header.h:361
ns3::GtpcHeader::S5_SGW_GTPC
@ S5_SGW_GTPC
Definition: epc-gtpc-header.h:111
ns3::Packet::PeekHeader
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
ns3::EpcPgwApplication::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition: epc-pgw-application.cc:134
ns3::GtpcHeader::Fteid_t::addr
Ipv4Address addr
Definition: epc-gtpc-header.h:120
ns3::EpcPgwApplication::m_ueInfoByImsiMap
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
UeInfo stored by IMSI.
Definition: epc-pgw-application.h:313
ns3::EpcPgwApplication::UeInfo::Classify
uint32_t Classify(Ptr< Packet > p, uint16_t protocolNumber)
Classify the packet according to TFTs of this UE.
Definition: epc-pgw-application.cc:66
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
ns3::EpcPgwApplication::DoRecvDeleteBearerResponse
void DoRecvDeleteBearerResponse(Ptr< Packet > packet)
Process Delete Bearer Response message.
Definition: epc-pgw-application.cc:412
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
ns3::GtpuHeader::SetLength
void SetLength(uint16_t length)
Set the length in octets of the payload.
Definition: epc-gtpu-header.cc:206
ns3::GtpcModifyBearerRequestMessage::GetImsi
uint64_t GetImsi() const
Definition: epc-gtpc-header.cc:878
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::GtpcCreateSessionRequestMessage::GetBearerContextsToBeCreated
std::list< BearerContextToBeCreated > GetBearerContextsToBeCreated() const
Definition: epc-gtpc-header.cc:627
ns3::EpcPgwApplication::UeInfo::UeInfo
UeInfo()
Definition: epc-pgw-application.cc:43
ns3::GtpcDeleteBearerResponseMessage
Definition: epc-gtpc-header.h:441
ns3::GtpcHeader::CreateSessionRequest
@ CreateSessionRequest
Definition: epc-gtpc-header.h:128
ns3::EpcPgwApplication::m_rxTunPktTrace
TracedCallback< Ptr< Packet > > m_rxTunPktTrace
Callback to trace received data packets at Tun NetDevice from internet.
Definition: epc-pgw-application.h:333
ns3::GtpcHeader::GetTeid
uint32_t GetTeid() const
Get TEID.
Definition: epc-gtpc-header.cc:149
ns3::EpcPgwApplication::m_tunDevice
Ptr< VirtualNetDevice > m_tunDevice
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP...
Definition: epc-pgw-application.h:298
ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::bearerLevelQos
EpsBearer bearerLevelQos
Bearer QOS level.
Definition: epc-gtpc-header.h:306
ns3::GtpcModifyBearerRequestMessage::GetUliEcgi
uint32_t GetUliEcgi() const
Definition: epc-gtpc-header.cc:890
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
ns3::GtpcHeader::SetTeid
void SetTeid(uint32_t teid)
Set TEID.
Definition: epc-gtpc-header.cc:173
ns3::Packet::CopyData
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:378
ns3::EpcPgwApplication::m_sgwS5Addr
Ipv4Address m_sgwS5Addr
SGW address of the S5 interface.
Definition: epc-pgw-application.h:328
ns3::GtpcHeader::Fteid_t::teid
uint32_t teid
Definition: epc-gtpc-header.h:121
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::EpcPgwApplication::UeInfo::RemoveBearer
void RemoveBearer(uint8_t bearerId)
Delete context of bearer for this UE on PGW side.
Definition: epc-pgw-application.cc:57
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::EpcPgwApplication::UeInfo::GetUeAddr
Ipv4Address GetUeAddr()
Get the IPv4 address of the UE.
Definition: epc-pgw-application.cc:88
ns3::NetDevice::PACKET_HOST
@ PACKET_HOST
Packet addressed oo us.
Definition: net-device.h:298
ns3::EpcPgwApplication::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: epc-pgw-application.cc:116
ns3::EpcPgwApplication::m_ueInfoByAddrMap6
std::map< Ipv6Address, Ptr< UeInfo > > m_ueInfoByAddrMap6
UeInfo stored by UE IPv6 address.
Definition: epc-pgw-application.h:308
ns3::GtpcDeleteBearerRequestMessage::SetEpsBearerIds
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Definition: epc-gtpc-header.cc:1177
ns3::Socket::SendTo
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
ns3::VirtualNetDevice::GetAddress
virtual Address GetAddress(void) const
Definition: virtual-net-device.cc:190
ns3::Ipv6Header
Packet header for IPv6.
Definition: ipv6-header.h:36
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::MakeNullCallback
Callback< R, Ts... > MakeNullCallback(void)
Definition: callback.h:1682
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
ns3::EpcPgwApplication::DoRecvCreateSessionRequest
void DoRecvCreateSessionRequest(Ptr< Packet > packet)
Process Create Session Request message.
Definition: epc-pgw-application.cc:285
ns3::EpcPgwApplication::SendToTunDevice
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a data packet to the internet via the SGi interface of the PGW.
Definition: epc-pgw-application.cc:433
ns3::GtpcCreateSessionRequestMessage::GetSenderCpFteid
GtpcHeader::Fteid_t GetSenderCpFteid() const
Definition: epc-gtpc-header.cc:615
ns3::EpcPgwApplication::SendToS5uSocket
void SendToS5uSocket(Ptr< Packet > packet, Ipv4Address sgwS5uAddress, uint32_t teid)
Send a data packet to the SGW via the S5-U interface.
Definition: epc-pgw-application.cc:460
ns3::EpcPgwApplication::RecvFromS5uSocket
void RecvFromS5uSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-U socket.
Definition: epc-pgw-application.cc:236
ns3::EpcPgwApplication::RecvFromS5cSocket
void RecvFromS5cSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-C socket.
Definition: epc-pgw-application.cc:251
ns3::EpcPgwApplication::m_pgwS5Addr
Ipv4Address m_pgwS5Addr
PGW address of the S5 interface.
Definition: epc-pgw-application.h:282
ns3::GtpcModifyBearerRequestMessage
Definition: epc-gtpc-header.h:321
ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::tft
Ptr< EpcTft > tft
Bearer traffic flow template.
Definition: epc-gtpc-header.h:304
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::GtpcCreateSessionResponseMessage::SetSenderCpFteid
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Definition: epc-gtpc-header.cc:765
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::Socket::SetRecvCallback
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
ns3::EpcPgwApplication::UeInfo::AddBearer
void AddBearer(uint8_t bearerId, uint32_t teid, Ptr< EpcTft > tft)
Add a bearer for this UE on PGW side.
Definition: epc-pgw-application.cc:49
ns3::EpcPgwApplication::~EpcPgwApplication
virtual ~EpcPgwApplication(void)
Destructor.
Definition: epc-pgw-application.cc:157
ns3::GtpcHeader::S5_PGW_GTPU
@ S5_PGW_GTPU
Definition: epc-gtpc-header.h:110
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::GtpcHeader::ComputeMessageLength
void ComputeMessageLength(void)
Definition: epc-gtpc-header.cc:194
ns3::GtpcCreateSessionRequestMessage
Definition: epc-gtpc-header.h:232
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::EpcPgwApplication::UeInfo::SetUeAddr6
void SetUeAddr6(Ipv6Address addr)
Set the IPv6 address of the UE.
Definition: epc-pgw-application.cc:106
ns3::EpcPgwApplication::UeInfo::GetUeAddr6
Ipv6Address GetUeAddr6()
Get the IPv6 address of the UE.
Definition: epc-pgw-application.cc:100
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
ns3::GtpcHeader::S5_PGW_GTPC
@ S5_PGW_GTPC
Definition: epc-gtpc-header.h:112
ns3::GtpcCreateSessionResponseMessage::SetCause
void SetCause(Cause_t cause)
Definition: epc-gtpc-header.cc:753
ns3::EpcPgwApplication::m_gtpcUdpPort
uint16_t m_gtpcUdpPort
UDP port to be used for GTPv2-C.
Definition: epc-pgw-application.h:323
ns3::GtpuHeader::GetTeid
uint32_t GetTeid() const
Get a tunnel endpoint identificator (TEID)
Definition: epc-gtpu-header.cc:188
ns3::GtpcDeleteBearerResponseMessage::GetEpsBearerIds
std::list< uint8_t > GetEpsBearerIds() const
Definition: epc-gtpc-header.cc:1279
ns3::EpcPgwApplication::UeInfo::GetSgwAddr
Ipv4Address GetSgwAddr()
Get the address of the SGW to which the UE is connected.
Definition: epc-pgw-application.cc:76
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
ns3::GtpcCreateSessionResponseMessage::SetBearerContextsCreated
void SetBearerContextsCreated(std::list< BearerContextCreated > bearerContexts)
Definition: epc-gtpc-header.cc:777
ns3::EpcPgwApplication::UeInfo::SetUeAddr
void SetUeAddr(Ipv4Address addr)
Set the IPv4 address of the UE.
Definition: epc-pgw-application.cc:94
ns3::Ipv6L3Protocol::PROT_NUMBER
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
Definition: ipv6-l3-protocol.h:74
ns3::GtpcCreateSessionRequestMessage::GetUliEcgi
uint32_t GetUliEcgi() const
Definition: epc-gtpc-header.cc:603
ns3::GtpcDeleteBearerRequestMessage
Definition: epc-gtpc-header.h:416
ns3::EpcPgwApplication::SetUeAddress
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
Set the address of a previously added UE.
Definition: epc-pgw-application.cc:491
ns3::Ipv4L3Protocol::PROT_NUMBER
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Definition: ipv4-l3-protocol.h:88
ns3::MakeCallback
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
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
ns3::EpcPgwApplication::RecvFromTunDevice
bool RecvFromTunDevice(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Method to be assigned to the callback of the SGi TUN VirtualNetDevice.
Definition: epc-pgw-application.cc:163
ns3::GtpuHeader::SetTeid
void SetTeid(uint32_t teid)
Set TEID function.
Definition: epc-gtpu-header.cc:254
ns3::GtpcHeader::DeleteBearerCommand
@ DeleteBearerCommand
Definition: epc-gtpc-header.h:134
ns3::GtpcModifyBearerRequestMessage::GetBearerContextsToBeModified
std::list< BearerContextToBeModified > GetBearerContextsToBeModified() const
Definition: epc-gtpc-header.cc:902
ns3::GtpcDeleteBearerCommandMessage::GetBearerContexts
std::list< BearerContext > GetBearerContexts() const
Definition: epc-gtpc-header.cc:1079
ns3::GtpcCreateSessionRequestMessage::GetImsi
uint64_t GetImsi() const
Definition: epc-gtpc-header.cc:591
ns3::GtpcHeader::GetMessageType
uint8_t GetMessageType() const
Get message type.
Definition: epc-gtpc-header.cc:137
ns3::GtpcCreateSessionResponseMessage::BearerContextCreated
Definition: epc-gtpc-header.h:301
ns3::GtpcModifyBearerResponseMessage::SetCause
void SetCause(Cause_t cause)
Definition: epc-gtpc-header.cc:987
ns3::GtpcHeader::ModifyBearerRequest
@ ModifyBearerRequest
Definition: epc-gtpc-header.h:130
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::EpcPgwApplication::m_rxS5PktTrace
TracedCallback< Ptr< Packet > > m_rxS5PktTrace
Callback to trace received data packets from S5 socket.
Definition: epc-pgw-application.h:338
ns3::VirtualNetDevice::Receive
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Definition: virtual-net-device.cc:140
ns3::GtpcIes::REQUEST_ACCEPTED
@ REQUEST_ACCEPTED
Definition: epc-gtpc-header.h:188
ns3::EpcPgwApplication::m_s5uSocket
Ptr< Socket > m_s5uSocket
UDP socket to send/receive GTP-U packets to/from the S5 interface.
Definition: epc-pgw-application.h:287
ns3::Packet::Copy
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
ns3::GtpcHeader::DeleteBearerResponse
@ DeleteBearerResponse
Definition: epc-gtpc-header.h:136
ns3::EpcPgwApplication::SetUeAddress6
void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr)
set the address of a previously added UE
Definition: epc-pgw-application.cc:501
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::EpcPgwApplication::DoRecvModifyBearerRequest
void DoRecvModifyBearerRequest(Ptr< Packet > packet)
Process Modify Bearer Request message.
Definition: epc-pgw-application.cc:348
ns3::EpcPgwApplication::m_gtpuUdpPort
uint16_t m_gtpuUdpPort
UDP port to be used for GTP-U.
Definition: epc-pgw-application.h:318
ns3::Ipv6Header::GetDestination
Ipv6Address GetDestination(void) const
Get the "Destination address" field.
Definition: ipv6-header.cc:125
ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::epsBearerId
uint8_t epsBearerId
EPS bearer ID.
Definition: epc-gtpc-header.h:302
ns3::EpcPgwApplication::AddSgw
void AddSgw(Ipv4Address sgwS5Addr)
Let the PGW be aware of a new SGW.
Definition: epc-pgw-application.cc:476
ns3::EpcPgwApplication::UeInfo::SetSgwAddr
void SetSgwAddr(Ipv4Address addr)
Set the address of the eNB to which the UE is connected.
Definition: epc-pgw-application.cc:82
ns3::GtpuHeader
Implementation of the GPRS Tunnelling Protocol header according to GTPv1-U Release 10 as per 3Gpp TS ...
Definition: epc-gtpu-header.h:42
ns3::GtpcCreateSessionResponseMessage::BearerContextCreated::fteid
GtpcHeader::Fteid_t fteid
FTEID.
Definition: epc-gtpc-header.h:305
ns3::EpcPgwApplication::EpcPgwApplication
EpcPgwApplication(const Ptr< VirtualNetDevice > tunDevice, Ipv4Address s5Addr, const Ptr< Socket > s5uSocket, const Ptr< Socket > s5cSocket)
Constructor that binds the tap device to the callback methods.
Definition: epc-pgw-application.cc:143
ns3::EpcTft::DOWNLINK
@ DOWNLINK
Definition: epc-tft.h:57
ns3::EpcPgwApplication::m_ueInfoByAddrMap
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
UeInfo stored by UE IPv4 address.
Definition: epc-pgw-application.h:303
ns3::Ipv4Header::GetDestination
Ipv4Address GetDestination(void) const
Definition: ipv4-header.cc:304
ns3::GtpcHeader::Fteid_t::interfaceType
InterfaceType_t interfaceType
Definition: epc-gtpc-header.h:119
ns3::EpcPgwApplication::m_s5cSocket
Ptr< Socket > m_s5cSocket
UDP socket to send/receive GTPv2-C packets to/from the S5 interface.
Definition: epc-pgw-application.h:292
ns3::GtpcCreateSessionResponseMessage
Definition: epc-gtpc-header.h:278
ns3::GtpcHeader
Header of the GTPv2-C protocol.
Definition: epc-gtpc-header.h:39
ns3::Socket::Recv
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
NS_ABORT_MSG
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50