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
a polymophic address class
Definition: address.h:91
Ipv6Address GetUeAddr6()
Get the IPv6 address of the UE.
uint32_t Classify(Ptr< Packet > p, uint16_t protocolNumber)
Classify the packet according to TFTs of this UE.
void SetUeAddr(Ipv4Address addr)
Set the IPv4 address of the UE.
Ipv4Address GetSgwAddr()
Get the address of the SGW to which the UE is connected.
void RemoveBearer(uint8_t bearerId)
Delete context of bearer for this UE on PGW side.
Ipv4Address GetUeAddr()
Get the IPv4 address of the UE.
void SetUeAddr6(Ipv6Address addr)
Set the IPv6 address of the UE.
void SetSgwAddr(Ipv4Address addr)
Set the address of the eNB to which the UE is connected.
void AddBearer(uint8_t bearerId, uint32_t teid, Ptr< EpcTft > tft)
Add a bearer for this UE on PGW side.
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.
void SendToS5uSocket(Ptr< Packet > packet, Ipv4Address sgwS5uAddress, uint32_t teid)
Send a data packet to the SGW via the S5-U interface.
void SetUeAddress6(uint64_t imsi, Ipv6Address ueAddr)
set the address of a previously added UE
void SendToTunDevice(Ptr< Packet > packet, uint32_t teid)
Send a data packet to the internet via the SGi interface of the PGW.
void AddSgw(Ipv4Address sgwS5Addr)
Let the PGW be aware of a new SGW.
TracedCallback< Ptr< Packet > > m_rxTunPktTrace
Callback to trace received data packets at Tun NetDevice from internet.
TracedCallback< Ptr< Packet > > m_rxS5PktTrace
Callback to trace received data packets from S5 socket.
std::map< Ipv6Address, Ptr< UeInfo > > m_ueInfoByAddrMap6
UeInfo stored by UE IPv6 address.
void RecvFromS5uSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-U socket.
void DoRecvDeleteBearerResponse(Ptr< Packet > packet)
Process Delete Bearer Response message.
void RecvFromS5cSocket(Ptr< Socket > socket)
Method to be assigned to the receiver callback of the S5-C socket.
virtual ~EpcPgwApplication(void)
Destructor.
void DoRecvDeleteBearerCommand(Ptr< Packet > packet)
Process Delete Bearer Command message.
void AddUe(uint64_t imsi)
Let the PGW be aware of a new UE.
Ptr< Socket > m_s5uSocket
UDP socket to send/receive GTP-U packets to/from the S5 interface.
static TypeId GetTypeId(void)
Get the type ID.
uint16_t m_gtpuUdpPort
UDP port to be used for GTP-U.
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.
std::map< uint64_t, Ptr< UeInfo > > m_ueInfoByImsiMap
UeInfo stored by IMSI.
Ipv4Address m_pgwS5Addr
PGW address of the S5 interface.
Ipv4Address m_sgwS5Addr
SGW address of the S5 interface.
Ptr< VirtualNetDevice > m_tunDevice
TUN VirtualNetDevice used for tunneling/detunneling IP packets from/to the internet over GTP-U/UDP/IP...
void DoRecvModifyBearerRequest(Ptr< Packet > packet)
Process Modify Bearer Request message.
void DoRecvCreateSessionRequest(Ptr< Packet > packet)
Process Create Session Request message.
uint16_t m_gtpcUdpPort
UDP port to be used for GTPv2-C.
Ptr< Socket > m_s5cSocket
UDP socket to send/receive GTPv2-C packets to/from the S5 interface.
std::map< Ipv4Address, Ptr< UeInfo > > m_ueInfoByAddrMap
UeInfo stored by UE IPv4 address.
void SetUeAddress(uint64_t imsi, Ipv4Address ueAddr)
Set the address of a previously added UE.
virtual void DoDispose()
Destructor implementation.
@ DOWNLINK
Definition: epc-tft.h:57
GTP-C Create Session Request Message.
uint64_t GetImsi() const
Get the IMSI.
GtpcHeader::Fteid_t GetSenderCpFteid() const
Get the Sender CpFteid.
uint32_t GetUliEcgi() const
Get the UliEcgi.
std::list< BearerContextToBeCreated > GetBearerContextsToBeCreated() const
Get the Bearer Contexts.
GTP-C Create Session Response Message.
void SetCause(Cause_t cause)
Set the Cause.
void SetBearerContextsCreated(std::list< BearerContextCreated > bearerContexts)
Set the Bearer Contexts.
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Set the Sender CpFteid.
GTP-C Delete Bearer Command Message.
std::list< BearerContext > GetBearerContexts() const
Get the Bearer contexts.
GTP-C Delete Bearer Request Message.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Set the Bearers IDs.
GTP-C Delete Bearer Response Message.
std::list< uint8_t > GetEpsBearerIds() const
Get the Bearers IDs.
Header of the GTPv2-C protocol.
void ComputeMessageLength(void)
Compute the message length according to the message type.
uint8_t GetMessageType() const
Get message type.
void SetTeid(uint32_t teid)
Set TEID.
uint32_t GetTeid() const
Get TEID.
GTP-C Modify Bearer Request Message.
uint64_t GetImsi() const
Get the IMSI.
uint32_t GetUliEcgi() const
Get the UliEcgi.
std::list< BearerContextToBeModified > GetBearerContextsToBeModified() const
Get the Bearer Contexts.
GTP-C Modify Bearer Response Message.
void SetCause(Cause_t cause)
Set the Cause.
Implementation of the GPRS Tunnelling Protocol header according to GTPv1-U Release 10 as per 3Gpp TS ...
void SetTeid(uint32_t teid)
Set TEID function.
virtual uint32_t GetSerializedSize(void) const
uint32_t GetTeid() const
Get a tunnel endpoint identificator (TEID)
void SetLength(uint16_t length)
Set the length in octets of the payload.
an Inet address class
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
Ipv4Address GetDestination(void) const
Definition: ipv4-header.cc:304
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Describes an IPv6 address.
Definition: ipv6-address.h:50
Packet header for IPv6.
Definition: ipv6-header.h:36
Ipv6Address GetDestination(void) const
Get the "Destination address" field.
Definition: ipv6-header.cc:125
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
@ PACKET_HOST
Packet addressed oo us.
Definition: net-device.h:298
A base class which provides memory management and object aggregation.
Definition: object.h:88
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:378
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
virtual Address GetAddress(void) const
#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
#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
Callback< R, Ts... > MakeNullCallback(void)
Definition: callback.h:1688
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:1648
Ptr< EpcTft > tft
Bearer traffic flow template.
Ipv4Address addr
IPv4 address.
InterfaceType_t interfaceType
Interface type.