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
24namespace ns3 {
25
26NS_LOG_COMPONENT_DEFINE ("GtpcHeader");
27
29
31static const uint8_t VERSION = 2;
32
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
58{
59 return GetTypeId ();
60}
61
64{
65 return m_teidFlag ? 12 : 8;
66}
67
68void
70{
71 NS_FATAL_ERROR ("Serialize GTP-C header is forbidden");
72}
73
74void
76{
77 i.WriteU8 ((VERSION << 5) | (1 << 3));
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
89{
90 return PreDeserialize (start);
91}
92
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
123void
124GtpcHeader::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
132{
133 return 0;
134}
135
136uint8_t
138{
139 return m_messageType;
140}
141
142uint16_t
144{
145 return m_messageLength;
146}
147
150{
151 return m_teid;
152}
153
156{
157 return m_sequenceNumber;
158}
159
160void
161GtpcHeader::SetMessageType (uint8_t messageType)
162{
163 m_messageType = messageType;
164}
165
166void
167GtpcHeader::SetMessageLength (uint16_t messageLength)
168{
169 m_messageLength = messageLength;
170}
171
172void
174{
175 m_teidFlag = true;
176 m_teid = teid;
177 m_messageLength = m_teidFlag ? 8 : 4;
178}
179
180void
182{
183 m_sequenceNumber = sequenceNumber;
184}
185
186void
187GtpcHeader::SetIesLength (uint16_t iesLength)
188{
189 m_messageLength = iesLength;
190 m_messageLength += (m_teidFlag) ? 8 : 4;
191}
192
193void
195{
197}
199
200void
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
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
223void
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
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
248void
249GtpcIes::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
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
271void
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
281uint64_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
297void
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
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
329void
330GtpcIes::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
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
398GtpcIes::GetSerializedSizeBearerTft (std::list<EpcTft::PacketFilter> packetFilters) const
399{
400 return (5 + packetFilters.size () * serializedSizePacketFilter);
401}
402
403void
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
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
429}
430
431void
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
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
459void
461{
462 i.WriteU8 (93); // IE Type = Bearer Context
463 i.WriteU16 (length);
464 i.WriteU8 (0); // Spare + Instance
465}
466
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
481TypeId
483{
484 static TypeId tid = TypeId ("ns3::GtpcCreateSessionRequestMessage")
485 .SetParent<Header> ()
486 .SetGroupName ("Lte")
487 .AddConstructor<GtpcCreateSessionRequestMessage> ();
488 return tid;
489}
490
492{
495 m_imsi = 0;
496 m_uliEcgi = 0;
497}
498
500{
501}
502
503TypeId
505{
506 return GetTypeId ();
507}
508
511{
513 for (auto &bc : m_bearerContextsToBeCreated)
514 {
516 + GetSerializedSizeBearerTft (bc.tft->GetPacketFilters ())
518 }
519
520 return serializedSize;
521}
522
525{
527}
528
529void
531{
533
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
554{
557
561
563 while (i.GetRemainingSize () > 0)
564 {
565 uint16_t 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
584void
586{
587 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
588}
589
590uint64_t
592{
593 return m_imsi;
594}
595
596void
598{
599 m_imsi = imsi;
600}
601
604{
605 return m_uliEcgi;
606}
607
608void
610{
611 m_uliEcgi = uliEcgi;
612}
613
616{
617 return m_senderCpFteid;
618}
619
620void
622{
623 m_senderCpFteid = fteid;
624}
625
626std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated>
628{
630}
631
632void
633GtpcCreateSessionRequestMessage::SetBearerContextsToBeCreated (std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts)
634{
635 m_bearerContextsToBeCreated = bearerContexts;
636}
637
639
640TypeId
642{
643 static TypeId tid = TypeId ("ns3::GtpcCreateSessionResponseMessage")
644 .SetParent<Header> ()
645 .SetGroupName ("Lte")
646 .AddConstructor<GtpcCreateSessionResponseMessage> ();
647 return tid;
648}
649
651{
654 m_cause = Cause_t::RESERVED;
655}
656
658{
659}
660
661TypeId
663{
664 return GetTypeId ();
665}
666
669{
671 for (auto &bc : m_bearerContextsCreated)
672 {
674 + GetSerializedSizeBearerTft (bc.tft->GetPacketFilters ())
676 }
677
678 return serializedSize;
679}
680
683{
685}
686
687void
689{
691
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
711{
714
717
719 while (i.GetRemainingSize () > 0)
720 {
721 BearerContextCreated bearerContext;
722 uint16_t length;
723
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
740void
742{
743 os << " cause " << m_cause << " FTEID " << m_senderCpFteid.addr << "," << m_senderCpFteid.teid ;
744}
745
748{
749 return m_cause;
750}
751
752void
754{
755 m_cause = cause;
756}
757
760{
761 return m_senderCpFteid;
762}
763
764void
766{
767 m_senderCpFteid = fteid;
768}
769
770std::list<GtpcCreateSessionResponseMessage::BearerContextCreated>
772{
774}
775
776void
777GtpcCreateSessionResponseMessage::SetBearerContextsCreated (std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContexts)
778{
779 m_bearerContextsCreated = bearerContexts;
780}
781
783
784TypeId
786{
787 static TypeId tid = TypeId ("ns3::GtpcModifyBearerRequestMessage")
788 .SetParent<Header> ()
789 .SetGroupName ("Lte")
790 .AddConstructor<GtpcModifyBearerRequestMessage> ();
791 return tid;
792}
793
795{
798 m_imsi = 0;
799 m_uliEcgi = 0;
800}
801
803{
804}
805
806TypeId
808{
809 return GetTypeId ();
810}
811
814{
819 return serializedSize;
820}
821
824{
826}
827
828void
830{
832
836
837 for (auto &bc : m_bearerContextsToBeModified)
838 {
840
841 SerializeEbi (i, bc.epsBearerId);
842 SerializeFteid (i, bc.fteid);
843 }
844}
845
848{
851
854
855 while (i.GetRemainingSize () > 0)
856 {
857 BearerContextToBeModified bearerContext;
858 uint16_t length;
859
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
871void
873{
874 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
875}
876
877uint64_t
879{
880 return m_imsi;
881}
882
883void
885{
886 m_imsi = imsi;
887}
888
891{
892 return m_uliEcgi;
893}
894
895void
897{
898 m_uliEcgi = uliEcgi;
899}
900
901std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified>
903{
905}
906
907void
908GtpcModifyBearerRequestMessage::SetBearerContextsToBeModified (std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts)
909{
910 m_bearerContextsToBeModified = bearerContexts;
911}
912
914
915TypeId
917{
918 static TypeId tid = TypeId ("ns3::GtpcModifyBearerResponseMessage")
919 .SetParent<Header> ()
920 .SetGroupName ("Lte")
921 .AddConstructor<GtpcModifyBearerResponseMessage> ();
922 return tid;
923}
924
926{
929 m_cause = Cause_t::RESERVED;
930}
931
933{
934}
935
936TypeId
938{
939 return GetTypeId ();
940}
941
944{
945 return serializedSizeCause;
946}
947
950{
952}
953
954void
956{
958
961}
962
965{
968
970
971 return GetSerializedSize ();
972}
973
974void
976{
977 os << " cause " << (uint16_t)m_cause;
978}
979
982{
983 return m_cause;
984}
985
986void
988{
989 m_cause = cause;
990}
991
993
994TypeId
996{
997 static TypeId tid = TypeId ("ns3::GtpcDeleteBearerCommandMessage")
998 .SetParent<Header> ()
999 .SetGroupName ("Lte")
1000 .AddConstructor<GtpcDeleteBearerCommandMessage> ();
1001 return tid;
1002}
1003
1005{
1008}
1009
1011{
1012}
1013
1014TypeId
1016{
1017 return GetTypeId ();
1018}
1019
1022{
1023 uint32_t serializedSize = m_bearerContexts.size ()
1025 return serializedSize;
1026}
1027
1030{
1032}
1033
1034void
1036{
1038
1040 for (auto &bearerContext : m_bearerContexts)
1041 {
1043
1044 SerializeEbi (i, bearerContext.m_epsBearerId);
1045 }
1046}
1047
1050{
1053
1054 while (i.GetRemainingSize () > 0)
1055 {
1056 uint16_t length;
1058
1059 BearerContext bearerContext;
1060 DeserializeEbi (i, bearerContext.m_epsBearerId);
1061 m_bearerContexts.push_back (bearerContext);
1062 }
1063
1064 return GetSerializedSize ();
1065}
1066
1067void
1069{
1070 os << " bearerContexts [";
1071 for (auto &bearerContext : m_bearerContexts)
1072 {
1073 os << (uint16_t)bearerContext.m_epsBearerId << " ";
1074 }
1075 os << "]";
1076}
1077
1078std::list<GtpcDeleteBearerCommandMessage::BearerContext>
1080{
1081 return m_bearerContexts;
1082}
1083
1084void
1085GtpcDeleteBearerCommandMessage::SetBearerContexts (std::list<GtpcDeleteBearerCommandMessage::BearerContext> bearerContexts)
1086{
1087 m_bearerContexts = bearerContexts;
1088}
1089
1091
1092TypeId
1094{
1095 static TypeId tid = TypeId ("ns3::GtpcDeleteBearerRequestMessage")
1096 .SetParent<Header> ()
1097 .SetGroupName ("Lte")
1098 .AddConstructor<GtpcDeleteBearerRequestMessage> ();
1099 return tid;
1100}
1101
1103{
1106}
1107
1109{
1110}
1111
1112TypeId
1114{
1115 return GetTypeId ();
1116}
1117
1120{
1121 uint32_t serializedSize = m_epsBearerIds.size () * serializedSizeEbi;
1122 return serializedSize;
1123}
1124
1127{
1129}
1130
1131void
1133{
1135
1137 for (auto &epsBearerId : m_epsBearerIds)
1138 {
1139 SerializeEbi (i, epsBearerId);
1140 }
1141}
1142
1145{
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
1159void
1161{
1162 os << " epsBearerIds [";
1163 for (auto &epsBearerId : m_epsBearerIds)
1164 {
1165 os << (uint16_t)epsBearerId << " ";
1166 }
1167 os << "]";
1168}
1169
1170std::list<uint8_t>
1172{
1173 return m_epsBearerIds;
1174}
1175
1176void
1178{
1179 m_epsBearerIds = epsBearerId;
1180}
1181
1183
1184TypeId
1186{
1187 static TypeId tid = TypeId ("ns3::GtpcDeleteBearerResponseMessage")
1188 .SetParent<Header> ()
1189 .SetGroupName ("Lte")
1190 .AddConstructor<GtpcDeleteBearerResponseMessage> ();
1191 return tid;
1192}
1193
1195{
1198}
1199
1201{
1202}
1203
1204TypeId
1206{
1207 return GetTypeId ();
1208}
1209
1212{
1213 uint32_t serializedSize = serializedSizeCause + m_epsBearerIds.size () * serializedSizeEbi;
1214 return serializedSize;
1215}
1216
1219{
1221}
1222
1223void
1225{
1227
1230
1231 for (auto &epsBearerId : m_epsBearerIds)
1232 {
1233 SerializeEbi (i, epsBearerId);
1234 }
1235}
1236
1239{
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
1255void
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
1272void
1274{
1275 m_cause = cause;
1276}
1277
1278std::list<uint8_t>
1280{
1281 return m_epsBearerIds;
1282}
1283
1284void
1286{
1287 m_epsBearerIds = epsBearerId;
1288}
1289
1290} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
uint16_t ReadNtohU16(void)
Definition: buffer.h:946
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:941
uint64_t ReadNtohU64(void)
Definition: buffer.cc:1044
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint32_t GetRemainingSize(void) const
Definition: buffer.cc:1166
void Next(void)
go forward by one byte
Definition: buffer.h:845
void WriteU16(uint16_t data)
Definition: buffer.cc:871
uint8_t ReadU8(void)
Definition: buffer.h:1021
void WriteHtonU16(uint16_t data)
Definition: buffer.h:905
void WriteHtonU32(uint32_t data)
Definition: buffer.h:924
uint32_t ReadNtohU32(void)
Definition: buffer.h:970
Direction
Indicates the direction of the traffic that is to be classified.
Definition: epc-tft.h:57
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:92
enum ns3::EpsBearer::Qci qci
Qos class indicator.
GbrQosInformation gbrQosInfo
GBR QOS information.
Definition: eps-bearer.h:131
Qci
QoS Class Indicator.
Definition: eps-bearer.h:107
GTP-C Create Session Request Message.
std::list< BearerContextToBeCreated > m_bearerContextsToBeCreated
Bearer Context list.
uint64_t GetImsi() const
Get the IMSI.
void SetUliEcgi(uint32_t uliEcgi)
Set the UliEcgi.
GtpcHeader::Fteid_t GetSenderCpFteid() const
Get the Sender CpFteid.
uint32_t GetUliEcgi() const
Get the UliEcgi.
virtual uint32_t GetMessageSize(void) const
Get the message size.
virtual uint32_t GetSerializedSize(void) const
GtpcHeader::Fteid_t m_senderCpFteid
Sender CpFteid.
void SetBearerContextsToBeCreated(std::list< BearerContextToBeCreated > bearerContexts)
Set the Bearer Contexts.
std::list< BearerContextToBeCreated > GetBearerContextsToBeCreated() const
Get the Bearer Contexts.
virtual uint32_t Deserialize(Buffer::Iterator start)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
static TypeId GetTypeId(void)
Get the type ID.
virtual void Print(std::ostream &os) const
void SetImsi(uint64_t imsi)
Set the IMSI.
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Set the Sender CpFteid.
virtual void Serialize(Buffer::Iterator start) const
GTP-C Create Session Response Message.
virtual uint32_t GetMessageSize(void) const
Get the message size.
virtual uint32_t Deserialize(Buffer::Iterator start)
void SetCause(Cause_t cause)
Set the Cause.
void SetBearerContextsCreated(std::list< BearerContextCreated > bearerContexts)
Set the Bearer Contexts.
virtual uint32_t GetSerializedSize(void) const
virtual void Print(std::ostream &os) const
virtual void Serialize(Buffer::Iterator start) const
static TypeId GetTypeId(void)
Get the type ID.
Cause_t GetCause() const
Get the Cause.
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Set the Sender CpFteid.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
std::list< BearerContextCreated > m_bearerContextsCreated
Container of Bearer Contexts.
std::list< BearerContextCreated > GetBearerContextsCreated() const
Get the Container of Bearer Contexts.
GtpcHeader::Fteid_t m_senderCpFteid
Sender CpFteid.
GtpcHeader::Fteid_t GetSenderCpFteid() const
Get the Sender CpFteid.
GTP-C Delete Bearer Command Message.
static TypeId GetTypeId(void)
Get the type ID.
virtual void Print(std::ostream &os) const
virtual uint32_t Deserialize(Buffer::Iterator start)
std::list< BearerContext > GetBearerContexts() const
Get the Bearer contexts.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t GetSerializedSize(void) const
virtual void Serialize(Buffer::Iterator start) const
std::list< BearerContext > m_bearerContexts
Container of Bearer Contexts.
void SetBearerContexts(std::list< BearerContext > bearerContexts)
Set the Bearer contexts.
virtual uint32_t GetMessageSize(void) const
Get the message size.
GTP-C Delete Bearer Request Message.
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
Get the type ID.
virtual void Serialize(Buffer::Iterator start) const
virtual uint32_t Deserialize(Buffer::Iterator start)
std::list< uint8_t > m_epsBearerIds
Container of Bearers IDs.
virtual void Print(std::ostream &os) const
std::list< uint8_t > GetEpsBearerIds() const
Get the Bearers IDs.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t GetMessageSize(void) const
Get the message size.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Set the Bearers IDs.
GTP-C Delete Bearer Response Message.
virtual void Serialize(Buffer::Iterator start) const
virtual uint32_t GetSerializedSize(void) const
void SetCause(Cause_t cause)
Set the Cause.
static TypeId GetTypeId(void)
Get the type ID.
Cause_t GetCause() const
Get the Cause.
std::list< uint8_t > m_epsBearerIds
Container of Bearers IDs.
std::list< uint8_t > GetEpsBearerIds() const
Get the Bearers IDs.
virtual uint32_t Deserialize(Buffer::Iterator start)
virtual uint32_t GetMessageSize(void) const
Get the message size.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void Print(std::ostream &os) const
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Set the Bearers IDs.
Header of the GTPv2-C protocol.
virtual void Serialize(Buffer::Iterator start) const
void PreSerialize(Buffer::Iterator &i) const
Serialize the GTP-C header in the GTP-C messages.
uint16_t m_messageLength
Message length field.
void SetMessageLength(uint16_t messageLength)
Set message length.
uint16_t GetMessageLength() const
Get message length.
uint8_t m_messageType
Message type field.
void ComputeMessageLength(void)
Compute the message length according to the message type.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t GetMessageType() const
Get message type.
void SetMessageType(uint8_t messageType)
Set message type.
InterfaceType_t
Interface Type enumeration.
uint32_t GetSequenceNumber() const
Get sequence number.
virtual ~GtpcHeader()
uint32_t m_sequenceNumber
GTP Sequence number field.
virtual void Print(std::ostream &os) const
uint32_t m_teid
Tunnel Endpoint Identifier (TEID) field.
bool m_teidFlag
TEID flag.
void SetSequenceNumber(uint32_t sequenceNumber)
Set sequence number.
uint32_t PreDeserialize(Buffer::Iterator &i)
Deserialize the GTP-C header in the GTP-C messages.
virtual uint32_t Deserialize(Buffer::Iterator start)
void SetIesLength(uint16_t iesLength)
Set IEs length.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetSerializedSize(void) const
void SetTeid(uint32_t teid)
Set TEID.
virtual uint32_t GetMessageSize(void) const
Get the message size.
uint32_t GetTeid() const
Get TEID.
void SerializeEbi(Buffer::Iterator &i, uint8_t epsBearerId) const
Serialize the eps Bearer Id.
void SerializeBearerContextHeader(Buffer::Iterator &i, uint16_t length) const
Serialize the Bearer Context Header.
uint32_t DeserializeCause(Buffer::Iterator &i, Cause_t &cause)
Deserialize the Cause.
uint32_t DeserializeBearerContextHeader(Buffer::Iterator &i, uint16_t &length)
Deserialize the Bearer Context Header.
uint32_t DeserializeFteid(Buffer::Iterator &i, GtpcHeader::Fteid_t &fteid)
Deserialize the Fteid.
const uint32_t serializedSizeEbi
EBI serialized size.
void WriteHtonU40(Buffer::Iterator &i, uint64_t data) const
void SerializeImsi(Buffer::Iterator &i, uint64_t imsi) const
Serialize the IMSI.
const uint32_t serializedSizeBearerContextHeader
Fteid serialized size.
uint32_t GetSerializedSizeBearerTft(std::list< EpcTft::PacketFilter > packetFilters) const
void SerializeFteid(Buffer::Iterator &i, GtpcHeader::Fteid_t fteid) const
Serialize the Fteid_t.
const uint32_t serializedSizePacketFilter
Packet filter serialized size.
uint64_t ReadNtohU40(Buffer::Iterator &i)
uint32_t DeserializeBearerTft(Buffer::Iterator &i, Ptr< EpcTft > epcTft)
Deserialize the Bearer TFT.
void SerializeUliEcgi(Buffer::Iterator &i, uint32_t uliEcgi) const
Serialize the UliEcgi.
const uint32_t serializedSizeImsi
IMSI serialized size.
const uint32_t serializedSizeBearerQos
Bearer QoS serialized size.
const uint32_t serializedSizeCause
Cause serialized size.
void SerializeCause(Buffer::Iterator &i, Cause_t cause) const
Serialize the Cause.
uint32_t DeserializeImsi(Buffer::Iterator &i, uint64_t &imsi)
Deserialize the IMSI.
uint32_t DeserializeBearerQos(Buffer::Iterator &i, EpsBearer &bearerQos)
Deserialize the eps Bearer QoS.
void SerializeBearerQos(Buffer::Iterator &i, EpsBearer bearerQos) const
Serialize the eps Bearer QoS.
const uint32_t serializedSizeUliEcgi
UliEcgi serialized size.
const uint32_t serializedSizeFteid
Fteid serialized size.
uint32_t DeserializeEbi(Buffer::Iterator &i, uint8_t &epsBearerId)
Deserialize the eps Bearer Id.
uint32_t DeserializeUliEcgi(Buffer::Iterator &i, uint32_t &uliEcgi)
Deserialize the UliEcgi.
void SerializeBearerTft(Buffer::Iterator &i, std::list< EpcTft::PacketFilter > packetFilters) const
Serialize the Bearer TFT.
GTP-C Modify Bearer Request Message.
uint64_t GetImsi() const
Get the IMSI.
void SetBearerContextsToBeModified(std::list< BearerContextToBeModified > bearerContexts)
Set the Bearer Contexts.
uint32_t GetUliEcgi() const
Get the UliEcgi.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t Deserialize(Buffer::Iterator start)
virtual void Serialize(Buffer::Iterator start) const
void SetUliEcgi(uint32_t uliEcgi)
Set the UliEcgi.
std::list< BearerContextToBeModified > GetBearerContextsToBeModified() const
Get the Bearer Contexts.
virtual void Print(std::ostream &os) const
void SetImsi(uint64_t imsi)
Set the IMSI.
virtual uint32_t GetMessageSize(void) const
Get the message size.
std::list< BearerContextToBeModified > m_bearerContextsToBeModified
Bearer Context list.
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
Get the type ID.
GTP-C Modify Bearer Response Message.
virtual void Print(std::ostream &os) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void Serialize(Buffer::Iterator start) const
virtual uint32_t GetMessageSize(void) const
Get the message size.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetSerializedSize(void) const
void SetCause(Cause_t cause)
Set the Cause.
virtual uint32_t Deserialize(Buffer::Iterator start)
Cause_t GetCause() const
Get the Cause.
Protocol header serialization and deserialization.
Definition: header.h:43
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
uint32_t Get(void) const
Get the host-order 32-bit IP address.
void Set(uint32_t address)
input address is in host order.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#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
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
string version
Definition: conf.py:51
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint8_t VERSION
GTPv2-C protocol version number.
def start()
Definition: core.py:1852
uint8_t data[writeSize]
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:75
Ipv4Address localAddress
IPv4 address of the UE.
Definition: epc-tft.h:129
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:140
Ipv4Mask localMask
IPv4 address mask of the UE.
Definition: epc-tft.h:130
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:138
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
Direction direction
whether the filter needs to be applied to uplink / downlink only, or in both cases
Definition: epc-tft.h:124
Ipv4Mask remoteMask
IPv4 address mask of the remote host.
Definition: epc-tft.h:128
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:137
uint8_t typeOfService
type of service field
Definition: epc-tft.h:142
Ipv4Address remoteAddress
IPv4 address of the remote host
Definition: epc-tft.h:127
uint8_t typeOfServiceMask
type of service field mask
Definition: epc-tft.h:143
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:139
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:42
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:43
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition: eps-bearer.h:44
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition: eps-bearer.h:45
Ptr< EpcTft > tft
Bearer traffic flow template.
Ipv4Address addr
IPv4 address.
InterfaceType_t interfaceType
Interface type.