A Discrete-Event Network Simulator
API
epc-gtpc-header.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  */
20 
21 #include "ns3/epc-gtpc-header.h"
22 #include "ns3/log.h"
23 
24 namespace ns3 {
25 
26 NS_LOG_COMPONENT_DEFINE ("GtpcHeader");
27 
28 NS_OBJECT_ENSURE_REGISTERED (GtpcHeader);
29 
31 static const uint8_t VERSION = 2;
32 
33 TypeId
35 {
36  static TypeId tid = TypeId ("ns3::GtpcHeader")
37  .SetParent<Header> ()
38  .SetGroupName ("Lte")
39  .AddConstructor<GtpcHeader> ();
40  return tid;
41 }
42 
44  : m_teidFlag (false),
45  m_messageType (0),
46  m_messageLength (4),
47  m_teid (0),
48  m_sequenceNumber (0)
49 {
50 }
51 
53 {
54 }
55 
56 TypeId
58 {
59  return GetTypeId ();
60 }
61 
62 uint32_t
64 {
65  return m_teidFlag ? 12 : 8;
66 }
67 
68 void
70 {
71  NS_FATAL_ERROR ("Serialize GTP-C header is forbidden");
72 }
73 
74 void
76 {
77  i.WriteU8 ((VERSION << 5) | (1 << 3));
80  i.WriteHtonU32 (m_teid);
81  i.WriteU8 ((m_sequenceNumber & 0x00ff0000) >> 16);
82  i.WriteU8 ((m_sequenceNumber & 0x0000ff00) >> 8);
83  i.WriteU8 (m_sequenceNumber & 0x000000ff);
84  i.WriteU8 (0);
85 }
86 
87 uint32_t
89 {
90  return PreDeserialize (start);
91 }
92 
93 uint32_t
95 {
96  uint8_t firstByte = i.ReadU8 ();
97  uint8_t version = (firstByte >> 5) & 0x07;
98  if (version != 2)
99  {
100  NS_FATAL_ERROR ("GTP-C version not supported");
101  return 0;
102  }
103 
104  m_teidFlag = ((firstByte >> 3) & 0x01) == 1;
105  if (!m_teidFlag)
106  {
107  NS_FATAL_ERROR ("TEID is missing");
108  return 0;
109  }
110 
111  m_messageType = i.ReadU8 ();
113  if (m_teidFlag)
114  {
115  m_teid = i.ReadNtohU32 ();
116  }
117  m_sequenceNumber = i.ReadU8 () << 16 | i.ReadU8 () << 8 | i.ReadU8 ();
118  i.ReadU8();
119 
121 }
122 
123 void
124 GtpcHeader::Print (std::ostream &os) const
125 {
126  os << " messageType " << (uint32_t) m_messageType << " messageLength " << m_messageLength;
127  os << " TEID " << m_teid << " sequenceNumber " << m_sequenceNumber;
128 }
129 
130 uint32_t
132 {
133  return 0;
134 }
135 
136 uint8_t
138 {
139  return m_messageType;
140 }
141 
142 uint16_t
144 {
145  return m_messageLength;
146 }
147 
148 uint32_t
150 {
151  return m_teid;
152 }
153 
154 uint32_t
156 {
157  return m_sequenceNumber;
158 }
159 
160 void
161 GtpcHeader::SetMessageType (uint8_t messageType)
162 {
163  m_messageType = messageType;
164 }
165 
166 void
167 GtpcHeader::SetMessageLength (uint16_t messageLength)
168 {
169  m_messageLength = messageLength;
170 }
171 
172 void
173 GtpcHeader::SetTeid (uint32_t teid)
174 {
175  m_teidFlag = true;
176  m_teid = teid;
177  m_messageLength = m_teidFlag ? 8 : 4;
178 }
179 
180 void
181 GtpcHeader::SetSequenceNumber (uint32_t sequenceNumber)
182 {
183  m_sequenceNumber = sequenceNumber;
184 }
185 
186 void
187 GtpcHeader::SetIesLength (uint16_t iesLength)
188 {
189  m_messageLength = iesLength;
190  m_messageLength += (m_teidFlag) ? 8 : 4;
191 }
192 
193 void
195 {
197 }
199 
200 void
201 GtpcIes::SerializeImsi (Buffer::Iterator &i, uint64_t imsi) const
202 {
203  i.WriteU8 (1); // IE Type = IMSI
204  i.WriteHtonU16 (8); // Length
205  i.WriteU8 (0); // Spare + Instance
206  i.WriteHtonU64 (imsi);
207 }
208 
209 uint32_t
211 {
212  uint8_t type = i.ReadU8 ();
213  NS_ASSERT_MSG (type == 1, "Wrong IMSI IE type = " << (uint16_t) type);
214  uint16_t length = i.ReadNtohU16 ();
215  NS_ASSERT_MSG (length == 8, "Wrong IMSI IE length");
216  uint8_t instance = i.ReadU8 () & 0x0f;
217  NS_ASSERT_MSG (instance == 0, "Wrong IMSI IE instance");
218  imsi = i.ReadNtohU64 ();
219 
220  return serializedSizeImsi;
221 }
222 
223 void
225 {
226  i.WriteU8 (2); // IE Type = Cause
227  i.WriteHtonU16 (2); // Length
228  i.WriteU8 (0); // Spare + Instance
229  i.WriteU8 (cause); // Cause value
230  i.WriteU8 (0); // Spare + CS
231 }
232 
233 uint32_t
235 {
236  uint8_t type = i.ReadU8 ();
237  NS_ASSERT_MSG (type == 2, "Wrong Cause IE type = " << (uint16_t) type);
238  uint16_t length = i.ReadNtohU16 ();
239  NS_ASSERT_MSG (length == 2, "Wrong Cause IE length");
240  uint8_t instance = i.ReadU8 () & 0x0f;
241  NS_ASSERT_MSG (instance == 0, "Wrong Cause IE instance");
242  cause = Cause_t (i.ReadU8 ());
243  i.ReadU8 ();
244 
245  return serializedSizeCause;
246 }
247 
248 void
249 GtpcIes::SerializeEbi (Buffer::Iterator &i, uint8_t epsBearerId) const
250 {
251  i.WriteU8 (73); // IE Type = EPS Bearer ID (EBI)
252  i.WriteHtonU16 (1); // Length
253  i.WriteU8 (0); // Spare + Instance
254  i.WriteU8 (epsBearerId & 0x0f);
255 }
256 
257 uint32_t
258 GtpcIes::DeserializeEbi (Buffer::Iterator &i, uint8_t &epsBearerId)
259 {
260  uint8_t type = i.ReadU8 ();
261  NS_ASSERT_MSG (type == 73, "Wrong EBI IE type = " << (uint16_t) type);
262  uint16_t length = i.ReadNtohU16 ();
263  NS_ASSERT_MSG (length == 1, "Wrong EBI IE length");
264  uint8_t instance = i.ReadU8 ();
265  NS_ASSERT_MSG (instance == 0, "Wrong EBI IE instance");
266  epsBearerId = i.ReadU8 () & 0x0f;
267 
268  return serializedSizeEbi;
269 }
270 
271 void
273 {
274  i.WriteU8 ((data >> 32) & 0xff);
275  i.WriteU8 ((data >> 24) & 0xff);
276  i.WriteU8 ((data >> 16) & 0xff);
277  i.WriteU8 ((data >> 8) & 0xff);
278  i.WriteU8 ((data >> 0) & 0xff);
279 }
280 
281 uint64_t
283 {
284  uint64_t retval = 0;
285  retval |= i.ReadU8 ();
286  retval <<= 8;
287  retval |= i.ReadU8 ();
288  retval <<= 8;
289  retval |= i.ReadU8 ();
290  retval <<= 8;
291  retval |= i.ReadU8 ();
292  retval <<= 8;
293  retval |= i.ReadU8 ();
294  return retval;
295 }
296 
297 void
299 {
300  i.WriteU8 (80); // IE Type = Bearer QoS
301  i.WriteHtonU16 (22); // Length
302  i.WriteU8 (0); // Spare + Instance
303  i.WriteU8 (0); // MRE TODO: bearerQos.arp
304  i.WriteU8 (bearerQos.qci);
305  WriteHtonU40 (i, bearerQos.gbrQosInfo.mbrUl);
306  WriteHtonU40 (i, bearerQos.gbrQosInfo.mbrDl);
307  WriteHtonU40 (i, bearerQos.gbrQosInfo.gbrUl);
308  WriteHtonU40 (i, bearerQos.gbrQosInfo.gbrDl);
309 }
310 
311 uint32_t
313 {
314  uint8_t type = i.ReadU8 ();
315  NS_ASSERT_MSG (type == 80, "Wrong Bearer QoS IE type = " << (uint16_t) type);
316  uint16_t length = i.ReadNtohU16 ();
317  NS_ASSERT_MSG (length == 22, "Wrong Bearer QoS IE length");
318  uint8_t instance = i.ReadU8 ();
319  NS_ASSERT_MSG (instance == 0, "Wrong Bearer QoS IE instance");
320  i.ReadU8 ();
321  bearerQos.qci = EpsBearer::Qci (i.ReadU8 ());
322  bearerQos.gbrQosInfo.mbrUl = ReadNtohU40 (i);
323  bearerQos.gbrQosInfo.mbrDl = ReadNtohU40 (i);
324  bearerQos.gbrQosInfo.gbrUl = ReadNtohU40 (i);
325  bearerQos.gbrQosInfo.gbrDl = ReadNtohU40 (i);
327 }
328 
329 void
330 GtpcIes::SerializeBearerTft (Buffer::Iterator &i, std::list<EpcTft::PacketFilter> packetFilters) const
331 {
332  i.WriteU8 (84); // IE Type = EPS Bearer Level Fraffic Flow Template (Bearer TFT)
333  i.WriteHtonU16 (1 + packetFilters.size () * serializedSizePacketFilter);
334  i.WriteU8 (0); // Spare + Instance
335  i.WriteU8 (0x20 + (packetFilters.size () & 0x0f)); // Create new TFT + Number of packet filters
336 
337  for (auto &pf : packetFilters)
338  {
339  i.WriteU8 ((pf.direction << 4) & 0x30);
340  i.WriteU8 (pf.precedence);
341  i.WriteU8 (serializedSizePacketFilter - 3); // Length of Packet filter contents
342 
343  i.WriteU8 (0x10); // IPv4 remote address type
344  i.WriteHtonU32 (pf.remoteAddress.Get ());
345  i.WriteHtonU32 (pf.remoteMask.Get ());
346  i.WriteU8 (0x11); // IPv4 local address type
347  i.WriteHtonU32 (pf.localAddress.Get ());
348  i.WriteHtonU32 (pf.localMask.Get ());
349  i.WriteU8 (0x41); // Local port range type
350  i.WriteHtonU16 (pf.localPortStart);
351  i.WriteHtonU16 (pf.localPortEnd);
352  i.WriteU8 (0x51); // Remote port range type
353  i.WriteHtonU16 (pf.remotePortStart);
354  i.WriteHtonU16 (pf.remotePortEnd);
355  i.WriteU8 (0x70); // Type of service
356  i.WriteU8 (pf.typeOfService);
357  i.WriteU8 (pf.typeOfServiceMask);
358  }
359 }
360 
361 uint32_t
363 {
364  uint8_t type = i.ReadU8 ();
365  NS_ASSERT_MSG (type == 84, "Wrong Bearer TFT IE type = " << (uint16_t) type);
366  i.ReadNtohU16 ();
367  i.ReadU8 ();
368  uint8_t numberOfPacketFilters = i.ReadU8 () & 0x0f;
369 
370  for (uint8_t pf = 0; pf < numberOfPacketFilters; ++pf)
371  {
372  EpcTft::PacketFilter packetFilter;
373  packetFilter.direction = EpcTft::Direction ((i.ReadU8 () & 0x30) >> 4);
374  packetFilter.precedence = i.ReadU8 ();
375  i.ReadU8 (); // Length of Packet filter contents
376  i.ReadU8 ();
377  packetFilter.remoteAddress = Ipv4Address (i.ReadNtohU32 ());
378  packetFilter.remoteMask = Ipv4Mask (i.ReadNtohU32 ());
379  i.ReadU8 ();
380  packetFilter.localAddress = Ipv4Address (i.ReadNtohU32 ());
381  packetFilter.localMask = Ipv4Mask (i.ReadNtohU32 ());
382  i.ReadU8 ();
383  packetFilter.localPortStart = i.ReadNtohU16 ();
384  packetFilter.localPortEnd = i.ReadNtohU16 ();
385  i.ReadU8 ();
386  packetFilter.remotePortStart = i.ReadNtohU16 ();
387  packetFilter.remotePortEnd = i.ReadNtohU16 ();
388  i.ReadU8 ();
389  packetFilter.typeOfService = i.ReadU8 ();
390  packetFilter.typeOfServiceMask = i.ReadU8 ();
391  epcTft->Add (packetFilter);
392  }
393 
394  return GetSerializedSizeBearerTft (epcTft->GetPacketFilters ());
395 }
396 
397 uint32_t
398 GtpcIes::GetSerializedSizeBearerTft (std::list<EpcTft::PacketFilter> packetFilters) const
399 {
400  return (5 + packetFilters.size () * serializedSizePacketFilter);
401 }
402 
403 void
404 GtpcIes::SerializeUliEcgi (Buffer::Iterator &i, uint32_t uliEcgi) const
405 {
406  i.WriteU8 (86); // IE Type = ULI (ECGI)
407  i.WriteHtonU16 (8); // Length
408  i.WriteU8 (0); // Spare + Instance
409  i.WriteU8 (0x10); // ECGI flag
410  i.WriteU8 (0); // Dummy MCC and MNC
411  i.WriteU8 (0); // Dummy MCC and MNC
412  i.WriteU8 (0); // Dummy MCC and MNC
413  i.WriteHtonU32 (uliEcgi);
414 }
415 
416 uint32_t
418 {
419  uint8_t type = i.ReadU8 ();
420  NS_ASSERT_MSG (type == 86, "Wrong ULI ECGI IE type = " << (uint16_t) type);
421  uint16_t length = i.ReadNtohU16 ();
422  NS_ASSERT_MSG (length == 8, "Wrong ULI ECGI IE length");
423  uint8_t instance = i.ReadU8 () & 0x0f;
424  NS_ASSERT_MSG (instance == 0, "Wrong ULI ECGI IE instance");
425  i.Next (4);
426  uliEcgi = i.ReadNtohU32 () & 0x0fffffff;
427 
428  return serializedSizeUliEcgi;
429 }
430 
431 void
433 {
434  i.WriteU8 (87); // IE Type = Fully Qualified TEID (F-TEID)
435  i.WriteHtonU16 (9); // Length
436  i.WriteU8 (0); // Spare + Instance
437  i.WriteU8 (0x80 | ((uint8_t) fteid.interfaceType & 0x1f)); // IP version flag + Iface type
438  i.WriteHtonU32 (fteid.teid); // TEID
439  i.WriteHtonU32 (fteid.addr.Get ()); // IPv4 address
440 }
441 
442 uint32_t
444 {
445  uint8_t type = i.ReadU8 ();
446  NS_ASSERT_MSG (type == 87, "Wrong FTEID IE type = " << (uint16_t) type);
447  uint16_t length = i.ReadNtohU16 ();
448  NS_ASSERT_MSG (length == 9, "Wrong FTEID IE length");
449  uint8_t instance = i.ReadU8 () & 0x0f;
450  NS_ASSERT_MSG (instance == 0, "Wrong FTEID IE instance");
451  uint8_t flags = i.ReadU8 (); // IP version flag + Iface type
452  fteid.interfaceType = GtpcHeader::InterfaceType_t (flags & 0x1f);
453  fteid.teid = i.ReadNtohU32 (); // TEID
454  fteid.addr.Set (i.ReadNtohU32 ()); // IPv4 address
455 
456  return serializedSizeFteid;
457 }
458 
459 void
461 {
462  i.WriteU8 (93); // IE Type = Bearer Context
463  i.WriteU16 (length);
464  i.WriteU8 (0); // Spare + Instance
465 }
466 
467 uint32_t
469 {
470  uint8_t type = i.ReadU8 ();
471  NS_ASSERT_MSG (type == 93, "Wrong Bearer Context IE type = " << (uint16_t) type);
472  length = i.ReadNtohU16 ();
473  uint8_t instance = i.ReadU8 () & 0x0f;
474  NS_ASSERT_MSG (instance == 0, "Wrong Bearer Context IE instance");
475 
477 }
478 
480 
481 TypeId
483 {
484  static TypeId tid = TypeId ("ns3::GtpcCreateSessionRequestMessage")
485  .SetParent<Header> ()
486  .SetGroupName ("Lte")
487  .AddConstructor<GtpcCreateSessionRequestMessage> ();
488  return tid;
489 }
490 
492 {
494  SetSequenceNumber (0);
495  m_imsi = 0;
496  m_uliEcgi = 0;
497 }
498 
500 {
501 }
502 
503 TypeId
505 {
506  return GetTypeId ();
507 }
508 
509 uint32_t
511 {
512  uint32_t serializedSize = serializedSizeImsi + serializedSizeUliEcgi + serializedSizeFteid;
513  for (auto &bc : m_bearerContextsToBeCreated)
514  {
516  + GetSerializedSizeBearerTft (bc.tft->GetPacketFilters ())
518  }
519 
520  return serializedSize;
521 }
522 
523 uint32_t
525 {
527 }
528 
529 void
531 {
533 
535  SerializeImsi (i, m_imsi);
538 
539  for (auto &bc : m_bearerContextsToBeCreated)
540  {
541  std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters ();
542 
544 
545  SerializeEbi (i, bc.epsBearerId);
546  SerializeBearerTft (i, packetFilters);
547  SerializeFteid (i, bc.sgwS5uFteid);
548  SerializeBearerQos (i, bc.bearerLevelQos);
549  }
550 }
551 
552 uint32_t
554 {
557 
558  DeserializeImsi (i, m_imsi);
561 
563  while (i.GetRemainingSize () > 0)
564  {
565  uint16_t length;
566  DeserializeBearerContextHeader (i, length);
567 
568  BearerContextToBeCreated bearerContext;
569  DeserializeEbi (i, bearerContext.epsBearerId);
570 
571  Ptr<EpcTft> epcTft = Create<EpcTft> ();
572  DeserializeBearerTft (i, epcTft);
573  bearerContext.tft = epcTft;
574 
575  DeserializeFteid (i, bearerContext.sgwS5uFteid);
576  DeserializeBearerQos (i, bearerContext.bearerLevelQos);
577 
578  m_bearerContextsToBeCreated.push_back (bearerContext);
579  }
580 
581  return GetSerializedSize ();
582 }
583 
584 void
586 {
587  os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
588 }
589 
590 uint64_t
592 {
593  return m_imsi;
594 }
595 
596 void
598 {
599  m_imsi = imsi;
600 }
601 
602 uint32_t
604 {
605  return m_uliEcgi;
606 }
607 
608 void
610 {
611  m_uliEcgi = uliEcgi;
612 }
613 
616 {
617  return m_senderCpFteid;
618 }
619 
620 void
622 {
623  m_senderCpFteid = fteid;
624 }
625 
626 std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated>
628 {
630 }
631 
632 void
633 GtpcCreateSessionRequestMessage::SetBearerContextsToBeCreated (std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts)
634 {
635  m_bearerContextsToBeCreated = bearerContexts;
636 }
637 
639 
640 TypeId
642 {
643  static TypeId tid = TypeId ("ns3::GtpcCreateSessionResponseMessage")
644  .SetParent<Header> ()
645  .SetGroupName ("Lte")
646  .AddConstructor<GtpcCreateSessionResponseMessage> ();
647  return tid;
648 }
649 
651 {
653  SetSequenceNumber (0);
654  m_cause = Cause_t::RESERVED;
655 }
656 
658 {
659 }
660 
661 TypeId
663 {
664  return GetTypeId ();
665 }
666 
667 uint32_t
669 {
670  uint32_t serializedSize = serializedSizeCause + serializedSizeFteid;
671  for (auto &bc : m_bearerContextsCreated)
672  {
674  + GetSerializedSizeBearerTft (bc.tft->GetPacketFilters ())
676  }
677 
678  return serializedSize;
679 }
680 
681 uint32_t
683 {
685 }
686 
687 void
689 {
691 
693  SerializeCause (i, m_cause);
695 
696  for (auto &bc : m_bearerContextsCreated)
697  {
698  std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters ();
699 
701 
702  SerializeEbi (i, bc.epsBearerId);
703  SerializeBearerTft (i, packetFilters);
704  SerializeFteid (i, bc.fteid);
705  SerializeBearerQos (i, bc.bearerLevelQos);
706  }
707 }
708 
709 uint32_t
711 {
714 
717 
718  m_bearerContextsCreated.clear ();
719  while (i.GetRemainingSize () > 0)
720  {
721  BearerContextCreated bearerContext;
722  uint16_t length;
723 
724  DeserializeBearerContextHeader (i, length);
725  DeserializeEbi (i, bearerContext.epsBearerId);
726 
727  Ptr<EpcTft> epcTft = Create<EpcTft> ();
728  DeserializeBearerTft (i, epcTft);
729  bearerContext.tft = epcTft;
730 
731  DeserializeFteid (i, bearerContext.fteid);
732  DeserializeBearerQos (i, bearerContext.bearerLevelQos);
733 
734  m_bearerContextsCreated.push_back (bearerContext);
735  }
736 
737  return GetSerializedSize ();
738 }
739 
740 void
742 {
743  os << " cause " << m_cause << " FTEID " << m_senderCpFteid.addr << "," << m_senderCpFteid.teid ;
744 }
745 
748 {
749  return m_cause;
750 }
751 
752 void
754 {
755  m_cause = cause;
756 }
757 
760 {
761  return m_senderCpFteid;
762 }
763 
764 void
766 {
767  m_senderCpFteid = fteid;
768 }
769 
770 std::list<GtpcCreateSessionResponseMessage::BearerContextCreated>
772 {
774 }
775 
776 void
777 GtpcCreateSessionResponseMessage::SetBearerContextsCreated (std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContexts)
778 {
779  m_bearerContextsCreated = bearerContexts;
780 }
781 
783 
784 TypeId
786 {
787  static TypeId tid = TypeId ("ns3::GtpcModifyBearerRequestMessage")
788  .SetParent<Header> ()
789  .SetGroupName ("Lte")
790  .AddConstructor<GtpcModifyBearerRequestMessage> ();
791  return tid;
792 }
793 
795 {
797  SetSequenceNumber (0);
798  m_imsi = 0;
799  m_uliEcgi = 0;
800 }
801 
803 {
804 }
805 
806 TypeId
808 {
809  return GetTypeId ();
810 }
811 
812 uint32_t
814 {
815  uint32_t serializedSize = serializedSizeImsi + serializedSizeUliEcgi
819  return serializedSize;
820 }
821 
822 uint32_t
824 {
826 }
827 
828 void
830 {
832 
834  SerializeImsi (i, m_imsi);
836 
837  for (auto &bc : m_bearerContextsToBeModified)
838  {
840 
841  SerializeEbi (i, bc.epsBearerId);
842  SerializeFteid (i, bc.fteid);
843  }
844 }
845 
846 uint32_t
848 {
851 
852  DeserializeImsi (i, m_imsi);
854 
855  while (i.GetRemainingSize () > 0)
856  {
857  BearerContextToBeModified bearerContext;
858  uint16_t length;
859 
860  DeserializeBearerContextHeader (i, length);
861 
862  DeserializeEbi (i, bearerContext.epsBearerId);
863  DeserializeFteid (i, bearerContext.fteid);
864 
865  m_bearerContextsToBeModified.push_back (bearerContext);
866  }
867 
868  return GetSerializedSize ();
869 }
870 
871 void
873 {
874  os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
875 }
876 
877 uint64_t
879 {
880  return m_imsi;
881 }
882 
883 void
885 {
886  m_imsi = imsi;
887 }
888 
889 uint32_t
891 {
892  return m_uliEcgi;
893 }
894 
895 void
897 {
898  m_uliEcgi = uliEcgi;
899 }
900 
901 std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified>
903 {
905 }
906 
907 void
908 GtpcModifyBearerRequestMessage::SetBearerContextsToBeModified (std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts)
909 {
910  m_bearerContextsToBeModified = bearerContexts;
911 }
912 
914 
915 TypeId
917 {
918  static TypeId tid = TypeId ("ns3::GtpcModifyBearerResponseMessage")
919  .SetParent<Header> ()
920  .SetGroupName ("Lte")
921  .AddConstructor<GtpcModifyBearerResponseMessage> ();
922  return tid;
923 }
924 
926 {
928  SetSequenceNumber (0);
929  m_cause = Cause_t::RESERVED;
930 }
931 
933 {
934 }
935 
936 TypeId
938 {
939  return GetTypeId ();
940 }
941 
942 uint32_t
944 {
945  return serializedSizeCause;
946 }
947 
948 uint32_t
950 {
952 }
953 
954 void
956 {
958 
960  SerializeCause (i, m_cause);
961 }
962 
963 uint32_t
965 {
968 
970 
971  return GetSerializedSize ();
972 }
973 
974 void
976 {
977  os << " cause " << (uint16_t)m_cause;
978 }
979 
982 {
983  return m_cause;
984 }
985 
986 void
988 {
989  m_cause = cause;
990 }
991 
993 
994 TypeId
996 {
997  static TypeId tid = TypeId ("ns3::GtpcDeleteBearerCommandMessage")
998  .SetParent<Header> ()
999  .SetGroupName ("Lte")
1000  .AddConstructor<GtpcDeleteBearerCommandMessage> ();
1001  return tid;
1002 }
1003 
1005 {
1007  SetSequenceNumber (0);
1008 }
1009 
1011 {
1012 }
1013 
1014 TypeId
1016 {
1017  return GetTypeId ();
1018 }
1019 
1020 uint32_t
1022 {
1023  uint32_t serializedSize = m_bearerContexts.size ()
1025  return serializedSize;
1026 }
1027 
1028 uint32_t
1030 {
1032 }
1033 
1034 void
1036 {
1037  Buffer::Iterator i = start;
1038 
1040  for (auto &bearerContext : m_bearerContexts)
1041  {
1043 
1044  SerializeEbi (i, bearerContext.m_epsBearerId);
1045  }
1046 }
1047 
1048 uint32_t
1050 {
1051  Buffer::Iterator i = start;
1053 
1054  while (i.GetRemainingSize () > 0)
1055  {
1056  uint16_t length;
1057  DeserializeBearerContextHeader (i, length);
1058 
1059  BearerContext bearerContext;
1060  DeserializeEbi (i, bearerContext.m_epsBearerId);
1061  m_bearerContexts.push_back (bearerContext);
1062  }
1063 
1064  return GetSerializedSize ();
1065 }
1066 
1067 void
1069 {
1070  os << " bearerContexts [";
1071  for (auto &bearerContext : m_bearerContexts)
1072  {
1073  os << (uint16_t)bearerContext.m_epsBearerId << " ";
1074  }
1075  os << "]";
1076 }
1077 
1078 std::list<GtpcDeleteBearerCommandMessage::BearerContext>
1080 {
1081  return m_bearerContexts;
1082 }
1083 
1084 void
1085 GtpcDeleteBearerCommandMessage::SetBearerContexts (std::list<GtpcDeleteBearerCommandMessage::BearerContext> bearerContexts)
1086 {
1087  m_bearerContexts = bearerContexts;
1088 }
1089 
1091 
1092 TypeId
1094 {
1095  static TypeId tid = TypeId ("ns3::GtpcDeleteBearerRequestMessage")
1096  .SetParent<Header> ()
1097  .SetGroupName ("Lte")
1098  .AddConstructor<GtpcDeleteBearerRequestMessage> ();
1099  return tid;
1100 }
1101 
1103 {
1105  SetSequenceNumber (0);
1106 }
1107 
1109 {
1110 }
1111 
1112 TypeId
1114 {
1115  return GetTypeId ();
1116 }
1117 
1118 uint32_t
1120 {
1121  uint32_t serializedSize = m_epsBearerIds.size () * serializedSizeEbi;
1122  return serializedSize;
1123 }
1124 
1125 uint32_t
1127 {
1129 }
1130 
1131 void
1133 {
1134  Buffer::Iterator i = start;
1135 
1137  for (auto &epsBearerId : m_epsBearerIds)
1138  {
1139  SerializeEbi (i, epsBearerId);
1140  }
1141 }
1142 
1143 uint32_t
1145 {
1146  Buffer::Iterator i = start;
1148 
1149  while (i.GetRemainingSize () > 0)
1150  {
1151  uint8_t epsBearerId;
1152  DeserializeEbi (i, epsBearerId);
1153  m_epsBearerIds.push_back (epsBearerId);
1154  }
1155 
1156  return GetSerializedSize ();
1157 }
1158 
1159 void
1161 {
1162  os << " epsBearerIds [";
1163  for (auto &epsBearerId : m_epsBearerIds)
1164  {
1165  os << (uint16_t)epsBearerId << " ";
1166  }
1167  os << "]";
1168 }
1169 
1170 std::list<uint8_t>
1172 {
1173  return m_epsBearerIds;
1174 }
1175 
1176 void
1177 GtpcDeleteBearerRequestMessage::SetEpsBearerIds (std::list<uint8_t> epsBearerId)
1178 {
1179  m_epsBearerIds = epsBearerId;
1180 }
1181 
1183 
1184 TypeId
1186 {
1187  static TypeId tid = TypeId ("ns3::GtpcDeleteBearerResponseMessage")
1188  .SetParent<Header> ()
1189  .SetGroupName ("Lte")
1190  .AddConstructor<GtpcDeleteBearerResponseMessage> ();
1191  return tid;
1192 }
1193 
1195 {
1197  SetSequenceNumber (0);
1198 }
1199 
1201 {
1202 }
1203 
1204 TypeId
1206 {
1207  return GetTypeId ();
1208 }
1209 
1210 uint32_t
1212 {
1213  uint32_t serializedSize = serializedSizeCause + m_epsBearerIds.size () * serializedSizeEbi;
1214  return serializedSize;
1215 }
1216 
1217 uint32_t
1219 {
1221 }
1222 
1223 void
1225 {
1226  Buffer::Iterator i = start;
1227 
1229  SerializeCause (i, m_cause);
1230 
1231  for (auto &epsBearerId : m_epsBearerIds)
1232  {
1233  SerializeEbi (i, epsBearerId);
1234  }
1235 }
1236 
1237 uint32_t
1239 {
1240  Buffer::Iterator i = start;
1242 
1244 
1245  while (i.GetRemainingSize () > 0)
1246  {
1247  uint8_t epsBearerId;
1248  DeserializeEbi (i, epsBearerId);
1249  m_epsBearerIds.push_back (epsBearerId);
1250  }
1251 
1252  return GetSerializedSize ();
1253 }
1254 
1255 void
1257 {
1258  os << " cause " << (uint16_t)m_cause << " epsBearerIds [";
1259  for (auto &epsBearerId : m_epsBearerIds)
1260  {
1261  os << (uint16_t)epsBearerId << " ";
1262  }
1263  os << "]";
1264 }
1265 
1268 {
1269  return m_cause;
1270 }
1271 
1272 void
1274 {
1275  m_cause = cause;
1276 }
1277 
1278 std::list<uint8_t>
1280 {
1281  return m_epsBearerIds;
1282 }
1283 
1284 void
1286 {
1287  m_epsBearerIds = epsBearerId;
1288 }
1289 
1290 } // namespace ns3
std::list< BearerContextToBeCreated > m_bearerContextsToBeCreated
Protocol header serialization and deserialization.
Definition: header.h:42
static TypeId GetTypeId(void)
Get the type ID.
void SetMessageLength(uint16_t messageLength)
Set message length.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t GetMessageSize(void) const
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:940
Direction
Indicates the direction of the traffic that is to be classified.
Definition: epc-tft.h:57
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
uint16_t GetMessageLength() const
Get message length.
std::list< BearerContextToBeModified > GetBearerContextsToBeModified() const
void SerializeEbi(Buffer::Iterator &i, uint8_t epsBearerId) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
static TypeId GetTypeId(void)
Get the type ID.
string version
Definition: conf.py:51
static TypeId GetTypeId(void)
Get the type ID.
Direction direction
whether the filter needs to be applied to uplink / downlink only, or in both cases ...
Definition: epc-tft.h:124
static const uint8_t VERSION
GTPv2-C protocol version number.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
InterfaceType_t
Interface Type enumeration.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:269
virtual uint32_t GetMessageSize(void) const
void SetBearerContextsToBeCreated(std::list< BearerContextToBeCreated > bearerContexts)
std::list< BearerContextToBeCreated > GetBearerContextsToBeCreated() const
uint32_t GetRemainingSize(void) const
Definition: buffer.cc:1165
def start()
Definition: core.py:1855
uint32_t DeserializeFteid(Buffer::Iterator &i, GtpcHeader::Fteid_t &fteid)
virtual void Print(std::ostream &os) const
virtual uint32_t GetSerializedSize(void) const
uint64_t ReadNtohU64(void)
Definition: buffer.cc:1043
virtual uint32_t GetSerializedSize(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
static TypeId GetTypeId(void)
Get the type ID.
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:140
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
virtual void Print(std::ostream &os) const
virtual uint32_t GetMessageSize(void) const
void SerializeCause(Buffer::Iterator &i, Cause_t cause) const
void ComputeMessageLength(void)
virtual uint32_t Deserialize(Buffer::Iterator start)
virtual uint32_t GetMessageSize(void) const
uint32_t DeserializeUliEcgi(Buffer::Iterator &i, uint32_t &uliEcgi)
std::list< BearerContext > m_bearerContexts
virtual uint32_t GetMessageSize(void) const
uint32_t ReadNtohU32(void)
Definition: buffer.h:970
virtual uint32_t Deserialize(Buffer::Iterator start)
virtual void Print(std::ostream &os) const
virtual void Print(std::ostream &os) const
virtual uint32_t GetSerializedSize(void) const
uint32_t DeserializeEbi(Buffer::Iterator &i, uint8_t &epsBearerId)
iterator in a Buffer instance
Definition: buffer.h:98
std::list< BearerContext > GetBearerContexts() const
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:43
virtual void Print(std::ostream &os) const
void SerializeBearerQos(Buffer::Iterator &i, EpsBearer bearerQos) const
virtual uint32_t GetMessageSize(void) const
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t Deserialize(Buffer::Iterator start)
const uint32_t serializedSizeFteid
virtual void Serialize(Buffer::Iterator start) const
uint32_t DeserializeCause(Buffer::Iterator &i, Cause_t &cause)
uint64_t ReadNtohU40(Buffer::Iterator &i)
virtual void Serialize(Buffer::Iterator start) const
static TypeId GetTypeId(void)
Get the type ID.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
uint32_t PreDeserialize(Buffer::Iterator &i)
Deserialize the GTP-C header in the GTP-C messages.
uint8_t data[writeSize]
uint32_t DeserializeBearerQos(Buffer::Iterator &i, EpsBearer &bearerQos)
void WriteU16(uint16_t data)
Definition: buffer.cc:870
virtual void Serialize(Buffer::Iterator start) const
Ipv4Mask localMask
IPv4 address mask of the UE.
Definition: epc-tft.h:130
uint32_t DeserializeBearerContextHeader(Buffer::Iterator &i, uint16_t &length)
void WriteHtonU16(uint16_t data)
Definition: buffer.h:905
std::list< BearerContextCreated > GetBearerContextsCreated() const
const uint32_t serializedSizeEbi
uint32_t m_sequenceNumber
GTP Sequence number field.
void Next(void)
go forward by one byte
Definition: buffer.h:845
virtual void Print(std::ostream &os) const
const uint32_t serializedSizePacketFilter
void PreSerialize(Buffer::Iterator &i) const
Serialize the GTP-C header in the GTP-C messages.
void SerializeBearerContextHeader(Buffer::Iterator &i, uint16_t length) const
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:42
virtual void Serialize(Buffer::Iterator start) const
const uint32_t serializedSizeUliEcgi
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t Deserialize(Buffer::Iterator start)
void SetIesLength(uint16_t iesLength)
Set IEs length.
InterfaceType_t interfaceType
virtual void Print(std::ostream &os) const
Ipv4Address remoteAddress
IPv4 address of the remote host.
Definition: epc-tft.h:127
void WriteHtonU40(Buffer::Iterator &i, uint64_t data) const
virtual uint32_t GetSerializedSize(void) const
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:138
static TypeId GetTypeId(void)
Get the type ID.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetBearerContexts(std::list< BearerContext > bearerContexts)
void SerializeImsi(Buffer::Iterator &i, uint64_t imsi) const
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:45
virtual uint32_t Deserialize(Buffer::Iterator start)
GtpcHeader::Fteid_t GetSenderCpFteid() const
uint8_t typeOfService
type of service field
Definition: epc-tft.h:142
Ipv4Address localAddress
IPv4 address of the UE.
Definition: epc-tft.h:129
static TypeId GetTypeId(void)
Get the type ID.
const uint32_t serializedSizeBearerContextHeader
virtual uint32_t Deserialize(Buffer::Iterator start)
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
void SetSequenceNumber(uint32_t sequenceNumber)
Set sequence number.
uint8_t GetMessageType() const
Get message type.
virtual uint32_t GetMessageSize(void) const
void WriteHtonU32(uint32_t data)
Definition: buffer.h:924
void SerializeUliEcgi(Buffer::Iterator &i, uint32_t uliEcgi) const
uint8_t m_messageType
Message type field.
enum ns3::EpsBearer::Qci qci
Qos class indicator.
Ptr< EpcTft > tft
Bearer traffic flow template.
virtual void Serialize(Buffer::Iterator start) const
virtual void Serialize(Buffer::Iterator start) const
#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
virtual uint32_t GetSerializedSize(void) const
void Set(uint32_t address)
input address is in host order.
virtual ~GtpcHeader()
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t Deserialize(Buffer::Iterator start)
virtual uint32_t GetSerializedSize(void) const
const uint32_t serializedSizeCause
uint8_t precedence
used to specify the precedence for the packet filter among all packet filters in the TFT; higher valu...
Definition: epc-tft.h:118
void WriteU8(uint8_t data)
Definition: buffer.h:869
std::list< BearerContextToBeModified > m_bearerContextsToBeModified
GbrQosInformation gbrQosInfo
GBR QOS information.
Definition: eps-bearer.h:131
void SetTeid(uint32_t teid)
Set TEID.
uint32_t DeserializeImsi(Buffer::Iterator &i, uint64_t &imsi)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
static TypeId GetTypeId(void)
Get the type ID.
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
virtual uint32_t GetSerializedSize(void) const
const uint32_t serializedSizeImsi
Ipv4Mask remoteMask
IPv4 address mask of the remote host.
Definition: epc-tft.h:128
uint32_t DeserializeBearerTft(Buffer::Iterator &i, Ptr< EpcTft > epcTft)
virtual uint32_t GetMessageSize(void) const
virtual void Serialize(Buffer::Iterator start) const
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t m_teid
Tunnel Endpoint Identifier (TEID) field.
std::list< BearerContextCreated > m_bearerContextsCreated
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
virtual void Print(std::ostream &os) const
virtual void Serialize(Buffer::Iterator start) const
void SerializeBearerTft(Buffer::Iterator &i, std::list< EpcTft::PacketFilter > packetFilters) const
uint32_t GetSequenceNumber() const
Get sequence number.
uint32_t Get(void) const
Get the host-order 32-bit IP address.
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:44
virtual uint32_t Deserialize(Buffer::Iterator start)
Header of the GTPv2-C protocol.
void SetBearerContextsCreated(std::list< BearerContextCreated > bearerContexts)
uint16_t ReadNtohU16(void)
Definition: buffer.h:946
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint32_t GetTeid() const
Get TEID.
uint8_t typeOfServiceMask
type of service field mask
Definition: epc-tft.h:143
std::list< uint8_t > GetEpsBearerIds() const
std::list< uint8_t > GetEpsBearerIds() const
a unique identifier for an interface.
Definition: type-id.h:58
void SerializeFteid(Buffer::Iterator &i, GtpcHeader::Fteid_t fteid) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
GtpcHeader::Fteid_t GetSenderCpFteid() const
void SetMessageType(uint8_t messageType)
Set message type.
const uint32_t serializedSizeBearerQos
void SetBearerContextsToBeModified(std::list< BearerContextToBeModified > bearerContexts)
bool m_teidFlag
TEID flag.
uint16_t m_messageLength
Message length field.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:137
uint32_t GetSerializedSizeBearerTft(std::list< EpcTft::PacketFilter > packetFilters) const
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:74
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:139
virtual uint32_t GetSerializedSize(void) const