A Discrete-Event Network Simulator
API
epc-pgw-application.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Manuel Requena <manuel.requena@cttc.es>
18  * (based on epc-sgw-pgw-application.cc)
19  */
20 
21 #include "ns3/epc-pgw-application.h"
22 
23 #include "ns3/abort.h"
24 #include "ns3/epc-gtpu-header.h"
25 #include "ns3/inet-socket-address.h"
26 #include "ns3/ipv4-l3-protocol.h"
27 #include "ns3/ipv4.h"
28 #include "ns3/ipv6-header.h"
29 #include "ns3/ipv6-l3-protocol.h"
30 #include "ns3/ipv6.h"
31 #include "ns3/log.h"
32 #include "ns3/mac48-address.h"
33 
34 namespace ns3
35 {
36 
37 NS_LOG_COMPONENT_DEFINE("EpcPgwApplication");
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 =
119  TypeId("ns3::EpcPgwApplication")
120  .SetParent<Object>()
121  .SetGroupName("Lte")
122  .AddTraceSource("RxFromTun",
123  "Receive data packets from internet in Tunnel NetDevice",
125  "ns3::EpcPgwApplication::RxTracedCallback")
126  .AddTraceSource("RxFromS1u",
127  "Receive data packets from S5 Socket",
129  "ns3::EpcPgwApplication::RxTracedCallback");
130  return tid;
131 }
132 
133 void
135 {
136  NS_LOG_FUNCTION(this);
138  m_s5uSocket = nullptr;
140  m_s5cSocket = nullptr;
141 }
142 
144  Ipv4Address s5Addr,
145  const Ptr<Socket> s5uSocket,
146  const Ptr<Socket> s5cSocket)
147  : m_pgwS5Addr(s5Addr),
148  m_s5uSocket(s5uSocket),
149  m_s5cSocket(s5cSocket),
150  m_tunDevice(tunDevice),
151  m_gtpuUdpPort(2152), // fixed by the standard
152  m_gtpcUdpPort(2123) // fixed by the standard
153 {
154  NS_LOG_FUNCTION(this << tunDevice << s5Addr << s5uSocket << s5cSocket);
157 }
158 
160 {
161  NS_LOG_FUNCTION(this);
162 }
163 
164 bool
166  const Address& source,
167  const Address& dest,
168  uint16_t protocolNumber)
169 {
170  NS_LOG_FUNCTION(this << source << dest << protocolNumber << packet << packet->GetSize());
171  m_rxTunPktTrace(packet->Copy());
172 
173  // get IP address of UE
174  if (protocolNumber == Ipv4L3Protocol::PROT_NUMBER)
175  {
176  Ipv4Header ipv4Header;
177  packet->PeekHeader(ipv4Header);
178  Ipv4Address ueAddr = ipv4Header.GetDestination();
179  NS_LOG_LOGIC("packet addressed to UE " << ueAddr);
180 
181  // find corresponding UeInfo address
182  std::map<Ipv4Address, Ptr<UeInfo>>::iterator it = m_ueInfoByAddrMap.find(ueAddr);
183  if (it == m_ueInfoByAddrMap.end())
184  {
185  NS_LOG_WARN("unknown UE address " << ueAddr);
186  }
187  else
188  {
189  Ipv4Address sgwAddr = it->second->GetSgwAddr();
190  uint32_t teid = it->second->Classify(packet, protocolNumber);
191  if (teid == 0)
192  {
193  NS_LOG_WARN("no matching bearer for this packet");
194  }
195  else
196  {
197  SendToS5uSocket(packet, sgwAddr, teid);
198  }
199  }
200  }
201  else if (protocolNumber == Ipv6L3Protocol::PROT_NUMBER)
202  {
203  Ipv6Header ipv6Header;
204  packet->PeekHeader(ipv6Header);
205  Ipv6Address ueAddr = ipv6Header.GetDestination();
206  NS_LOG_LOGIC("packet addressed to UE " << ueAddr);
207 
208  // find corresponding UeInfo address
209  std::map<Ipv6Address, Ptr<UeInfo>>::iterator it = m_ueInfoByAddrMap6.find(ueAddr);
210  if (it == m_ueInfoByAddrMap6.end())
211  {
212  NS_LOG_WARN("unknown UE address " << ueAddr);
213  }
214  else
215  {
216  Ipv4Address sgwAddr = it->second->GetSgwAddr();
217  uint32_t teid = it->second->Classify(packet, protocolNumber);
218  if (teid == 0)
219  {
220  NS_LOG_WARN("no matching bearer for this packet");
221  }
222  else
223  {
224  SendToS5uSocket(packet, sgwAddr, teid);
225  }
226  }
227  }
228  else
229  {
230  NS_ABORT_MSG("Unknown IP type");
231  }
232 
233  // there is no reason why we should notify the TUN
234  // VirtualNetDevice that he failed to send the packet: if we receive
235  // any bogus packet, it will just be silently discarded.
236  const bool succeeded = true;
237  return succeeded;
238 }
239 
240 void
242 {
243  NS_LOG_FUNCTION(this << socket);
244  NS_ASSERT(socket == m_s5uSocket);
245  Ptr<Packet> packet = socket->Recv();
246  m_rxS5PktTrace(packet->Copy());
247 
248  GtpuHeader gtpu;
249  packet->RemoveHeader(gtpu);
250  uint32_t teid = gtpu.GetTeid();
251 
252  SendToTunDevice(packet, teid);
253 }
254 
255 void
257 {
258  NS_LOG_FUNCTION(this << socket);
259  NS_ASSERT(socket == m_s5cSocket);
260  Ptr<Packet> packet = socket->Recv();
261  GtpcHeader header;
262  packet->PeekHeader(header);
263  uint16_t msgType = header.GetMessageType();
264 
265  switch (msgType)
266  {
269  break;
270 
273  break;
274 
277  break;
278 
281  break;
282 
283  default:
284  NS_FATAL_ERROR("GTP-C message not supported");
285  break;
286  }
287 }
288 
289 void
291 {
292  NS_LOG_FUNCTION(this);
293 
295  packet->RemoveHeader(msg);
296  uint64_t imsi = msg.GetImsi();
297  uint16_t cellId = msg.GetUliEcgi();
298  NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi);
299 
300  std::map<uint64_t, Ptr<UeInfo>>::iterator ueit = m_ueInfoByImsiMap.find(imsi);
301  NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi);
302  ueit->second->SetSgwAddr(m_sgwS5Addr);
303 
304  GtpcHeader::Fteid_t sgwS5cFteid = msg.GetSenderCpFteid();
305  NS_ASSERT_MSG(sgwS5cFteid.interfaceType == GtpcHeader::S5_SGW_GTPC, "Wrong interface type");
306 
308  msgOut.SetTeid(sgwS5cFteid.teid);
310 
311  GtpcHeader::Fteid_t pgwS5cFteid;
313  pgwS5cFteid.teid = sgwS5cFteid.teid;
314  pgwS5cFteid.addr = m_pgwS5Addr;
315  msgOut.SetSenderCpFteid(pgwS5cFteid);
316 
317  std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts =
319  NS_LOG_DEBUG("BearerContextsToBeCreated size = " << bearerContexts.size());
320 
321  std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContextsCreated;
322  for (auto& bearerContext : bearerContexts)
323  {
324  uint32_t teid = bearerContext.sgwS5uFteid.teid;
325  NS_LOG_DEBUG("bearerId " << (uint16_t)bearerContext.epsBearerId << " SGW "
326  << bearerContext.sgwS5uFteid.addr << " TEID " << teid);
327 
328  ueit->second->AddBearer(bearerContext.epsBearerId, teid, bearerContext.tft);
329 
331  bearerContextOut.fteid.interfaceType = GtpcHeader::S5_PGW_GTPU;
332  bearerContextOut.fteid.teid = teid;
333  bearerContextOut.fteid.addr = m_pgwS5Addr;
334  bearerContextOut.epsBearerId = bearerContext.epsBearerId;
335  bearerContextOut.bearerLevelQos = bearerContext.bearerLevelQos;
336  bearerContextOut.tft = bearerContext.tft;
337  bearerContextsCreated.push_back(bearerContextOut);
338  }
339 
340  NS_LOG_DEBUG("BearerContextsCreated size = " << bearerContextsCreated.size());
341  msgOut.SetBearerContextsCreated(bearerContextsCreated);
342  msgOut.SetTeid(sgwS5cFteid.teid);
343  msgOut.ComputeMessageLength();
344 
345  Ptr<Packet> packetOut = Create<Packet>();
346  packetOut->AddHeader(msgOut);
347  NS_LOG_DEBUG("Send CreateSessionResponse to SGW " << sgwS5cFteid.addr);
348  m_s5cSocket->SendTo(packetOut, 0, InetSocketAddress(sgwS5cFteid.addr, m_gtpcUdpPort));
349 }
350 
351 void
353 {
354  NS_LOG_FUNCTION(this);
355 
357  packet->RemoveHeader(msg);
358  uint64_t imsi = msg.GetImsi();
359  uint16_t cellId = msg.GetUliEcgi();
360  NS_LOG_DEBUG("cellId " << cellId << " IMSI " << imsi);
361 
362  std::map<uint64_t, Ptr<UeInfo>>::iterator ueit = m_ueInfoByImsiMap.find(imsi);
363  NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi);
364  ueit->second->SetSgwAddr(m_sgwS5Addr);
365 
366  std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts =
368  NS_LOG_DEBUG("BearerContextsToBeModified size = " << bearerContexts.size());
369 
370  for (auto& bearerContext : bearerContexts)
371  {
372  Ipv4Address sgwAddr = bearerContext.fteid.addr;
373  uint32_t teid = bearerContext.fteid.teid;
374  NS_LOG_DEBUG("bearerId " << (uint16_t)bearerContext.epsBearerId << " SGW " << sgwAddr
375  << " TEID " << teid);
376  }
377 
380  msgOut.SetTeid(imsi);
381  msgOut.ComputeMessageLength();
382 
383  Ptr<Packet> packetOut = Create<Packet>();
384  packetOut->AddHeader(msgOut);
385  NS_LOG_DEBUG("Send ModifyBearerResponse to SGW " << m_sgwS5Addr);
387 }
388 
389 void
391 {
392  NS_LOG_FUNCTION(this);
393 
395  packet->RemoveHeader(msg);
396 
397  std::list<uint8_t> epsBearerIds;
398  for (auto& bearerContext : msg.GetBearerContexts())
399  {
400  NS_LOG_DEBUG("ebid " << (uint16_t)bearerContext.m_epsBearerId);
401  epsBearerIds.push_back(bearerContext.m_epsBearerId);
402  }
403 
405  msgOut.SetEpsBearerIds(epsBearerIds);
406  msgOut.SetTeid(msg.GetTeid());
407  msgOut.ComputeMessageLength();
408 
409  Ptr<Packet> packetOut = Create<Packet>();
410  packetOut->AddHeader(msgOut);
411  NS_LOG_DEBUG("Send DeleteBearerRequest to SGW " << m_sgwS5Addr);
413 }
414 
415 void
417 {
418  NS_LOG_FUNCTION(this);
419 
421  packet->RemoveHeader(msg);
422 
423  uint64_t imsi = msg.GetTeid();
424  std::map<uint64_t, Ptr<UeInfo>>::iterator ueit = m_ueInfoByImsiMap.find(imsi);
425  NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi);
426 
427  for (auto& epsBearerId : msg.GetEpsBearerIds())
428  {
429  // Remove de-activated bearer contexts from PGW side
430  NS_LOG_INFO("PGW removing bearer " << (uint16_t)epsBearerId << " of IMSI " << imsi);
431  ueit->second->RemoveBearer(epsBearerId);
432  }
433 }
434 
435 void
437 {
438  NS_LOG_FUNCTION(this << packet << teid);
439  NS_LOG_LOGIC("packet size: " << packet->GetSize() << " bytes");
440 
441  uint8_t ipType;
442  packet->CopyData(&ipType, 1);
443  ipType = (ipType >> 4) & 0x0f;
444 
445  uint16_t protocol = 0;
446  if (ipType == 0x04)
447  {
448  protocol = 0x0800;
449  }
450  else if (ipType == 0x06)
451  {
452  protocol = 0x86DD;
453  }
454  else
455  {
456  NS_ABORT_MSG("Unknown IP type");
457  }
458 
459  m_tunDevice->Receive(packet,
460  protocol,
464 }
465 
466 void
468 {
469  NS_LOG_FUNCTION(this << packet << sgwAddr << teid);
470 
471  GtpuHeader gtpu;
472  gtpu.SetTeid(teid);
473  // From 3GPP TS 29.281 v10.0.0 Section 5.1
474  // Length of the payload + the non obligatory GTP-U header
475  gtpu.SetLength(packet->GetSize() + gtpu.GetSerializedSize() - 8);
476  packet->AddHeader(gtpu);
477  uint32_t flags = 0;
478  m_s5uSocket->SendTo(packet, flags, InetSocketAddress(sgwAddr, m_gtpuUdpPort));
479 }
480 
481 void
483 {
484  NS_LOG_FUNCTION(this << sgwS5Addr);
485  m_sgwS5Addr = sgwS5Addr;
486 }
487 
488 void
490 {
491  NS_LOG_FUNCTION(this << imsi);
492  Ptr<UeInfo> ueInfo = Create<UeInfo>();
493  m_ueInfoByImsiMap[imsi] = ueInfo;
494 }
495 
496 void
498 {
499  NS_LOG_FUNCTION(this << imsi << ueAddr);
500  std::map<uint64_t, Ptr<UeInfo>>::iterator ueit = m_ueInfoByImsiMap.find(imsi);
501  NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI" << imsi);
502  ueit->second->SetUeAddr(ueAddr);
503  m_ueInfoByAddrMap[ueAddr] = ueit->second;
504 }
505 
506 void
508 {
509  NS_LOG_FUNCTION(this << imsi << ueAddr);
510  std::map<uint64_t, Ptr<UeInfo>>::iterator ueit = m_ueInfoByImsiMap.find(imsi);
511  NS_ASSERT_MSG(ueit != m_ueInfoByImsiMap.end(), "unknown IMSI " << imsi);
512  m_ueInfoByAddrMap6[ueAddr] = ueit->second;
513  ueit->second->SetUeAddr6(ueAddr);
514 }
515 
516 } // namespace ns3
a polymophic address class
Definition: address.h:100
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.
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.
void DoDispose() override
Destructor implementation.
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.
~EpcPgwApplication() override
Destructor.
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.
static TypeId GetTypeId()
Get the type ID.
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.
@ DOWNLINK
Definition: epc-tft.h:52
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.
uint8_t GetMessageType() const
Get message type.
void ComputeMessageLength()
Compute the message length according to the 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.
uint32_t GetSerializedSize() const override
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:43
Packet header for IPv4.
Definition: ipv4-header.h:34
Ipv4Address GetDestination() const
Definition: ipv4-header.cc:316
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() const
Get the "Destination address" field.
Definition: ipv6-header.cc:124
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
@ PACKET_HOST
Packet addressed to us.
Definition: net-device.h:301
A base class which provides memory management and object aggregation.
Definition: object.h:89
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:863
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:400
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:305
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:126
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
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:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Address GetAddress() const override
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#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:86
Callback< R, Args... > MakeNullCallback()
Definition: callback.h:750
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:49
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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:261
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
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, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:707
Ptr< EpcTft > tft
Bearer traffic flow template.
Ipv4Address addr
IPv4 address.
InterfaceType_t interfaceType
Interface type.