A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
epc-gtpc-header.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 */
19
20#include "epc-gtpc-header.h"
21
22#include "ns3/log.h"
23
24namespace ns3
25{
26
27NS_LOG_COMPONENT_DEFINE("GtpcHeader");
28
30
31/// GTPv2-C protocol version number
32static const uint8_t VERSION = 2;
33
36{
37 static TypeId tid = TypeId("ns3::GtpcHeader")
39 .SetGroupName("Lte")
40 .AddConstructor<GtpcHeader>();
41 return tid;
42}
43
45 : m_teidFlag(false),
46 m_messageType(0),
47 m_messageLength(4),
48 m_teid(0),
49 m_sequenceNumber(0)
50{
51}
52
54{
55}
56
59{
60 return GetTypeId();
61}
62
65{
66 return m_teidFlag ? 12 : 8;
67}
68
69void
71{
72 NS_FATAL_ERROR("Serialize GTP-C header is forbidden");
73}
74
75void
77{
78 i.WriteU8((VERSION << 5) | (1 << 3));
82 i.WriteU8((m_sequenceNumber & 0x00ff0000) >> 16);
83 i.WriteU8((m_sequenceNumber & 0x0000ff00) >> 8);
84 i.WriteU8(m_sequenceNumber & 0x000000ff);
85 i.WriteU8(0);
86}
87
90{
91 return PreDeserialize(start);
92}
93
96{
97 uint8_t firstByte = i.ReadU8();
98 uint8_t version = (firstByte >> 5) & 0x07;
99 if (version != 2)
100 {
101 NS_FATAL_ERROR("GTP-C version not supported");
102 return 0;
103 }
104
105 m_teidFlag = ((firstByte >> 3) & 0x01) == 1;
106 if (!m_teidFlag)
107 {
108 NS_FATAL_ERROR("TEID is missing");
109 return 0;
110 }
111
112 m_messageType = i.ReadU8();
114 if (m_teidFlag)
115 {
116 m_teid = i.ReadNtohU32();
117 }
118 m_sequenceNumber = i.ReadU8() << 16 | i.ReadU8() << 8 | i.ReadU8();
119 i.ReadU8();
120
122}
123
124void
125GtpcHeader::Print(std::ostream& os) const
126{
127 os << " messageType " << (uint32_t)m_messageType << " messageLength " << m_messageLength;
128 os << " TEID " << m_teid << " sequenceNumber " << m_sequenceNumber;
129}
130
133{
134 return 0;
135}
136
137uint8_t
139{
140 return m_messageType;
141}
142
143uint16_t
145{
146 return m_messageLength;
147}
148
151{
152 return m_teid;
153}
154
157{
158 return m_sequenceNumber;
159}
160
161void
162GtpcHeader::SetMessageType(uint8_t messageType)
163{
164 m_messageType = messageType;
165}
166
167void
168GtpcHeader::SetMessageLength(uint16_t messageLength)
169{
170 m_messageLength = messageLength;
171}
172
173void
175{
176 m_teidFlag = true;
177 m_teid = teid;
178 m_messageLength = m_teidFlag ? 8 : 4;
179}
180
181void
183{
184 m_sequenceNumber = sequenceNumber;
185}
186
187void
188GtpcHeader::SetIesLength(uint16_t iesLength)
189{
190 m_messageLength = iesLength;
191 m_messageLength += (m_teidFlag) ? 8 : 4;
192}
193
194void
196{
198}
199
200/////////////////////////////////////////////////////////////////////
201
202void
204{
205 i.WriteU8(1); // IE Type = IMSI
206 i.WriteHtonU16(8); // Length
207 i.WriteU8(0); // Spare + Instance
208 i.WriteHtonU64(imsi);
209}
210
213{
214 uint8_t type = i.ReadU8();
215 NS_ASSERT_MSG(type == 1, "Wrong IMSI IE type = " << (uint16_t)type);
216 uint16_t length = i.ReadNtohU16();
217 NS_ASSERT_MSG(length == 8, "Wrong IMSI IE length");
218 uint8_t instance = i.ReadU8() & 0x0f;
219 NS_ASSERT_MSG(instance == 0, "Wrong IMSI IE instance");
220 imsi = i.ReadNtohU64();
221
222 return serializedSizeImsi;
223}
224
225void
227{
228 i.WriteU8(2); // IE Type = Cause
229 i.WriteHtonU16(2); // Length
230 i.WriteU8(0); // Spare + Instance
231 i.WriteU8(cause); // Cause value
232 i.WriteU8(0); // Spare + CS
233}
234
237{
238 uint8_t type = i.ReadU8();
239 NS_ASSERT_MSG(type == 2, "Wrong Cause IE type = " << (uint16_t)type);
240 uint16_t length = i.ReadNtohU16();
241 NS_ASSERT_MSG(length == 2, "Wrong Cause IE length");
242 uint8_t instance = i.ReadU8() & 0x0f;
243 NS_ASSERT_MSG(instance == 0, "Wrong Cause IE instance");
244 cause = Cause_t(i.ReadU8());
245 i.ReadU8();
246
247 return serializedSizeCause;
248}
249
250void
251GtpcIes::SerializeEbi(Buffer::Iterator& i, uint8_t epsBearerId) const
252{
253 i.WriteU8(73); // IE Type = EPS Bearer ID (EBI)
254 i.WriteHtonU16(1); // Length
255 i.WriteU8(0); // Spare + Instance
256 i.WriteU8(epsBearerId & 0x0f);
257}
258
260GtpcIes::DeserializeEbi(Buffer::Iterator& i, uint8_t& epsBearerId) const
261{
262 uint8_t type = i.ReadU8();
263 NS_ASSERT_MSG(type == 73, "Wrong EBI IE type = " << (uint16_t)type);
264 uint16_t length = i.ReadNtohU16();
265 NS_ASSERT_MSG(length == 1, "Wrong EBI IE length");
266 uint8_t instance = i.ReadU8();
267 NS_ASSERT_MSG(instance == 0, "Wrong EBI IE instance");
268 epsBearerId = i.ReadU8() & 0x0f;
269
270 return serializedSizeEbi;
271}
272
273void
275{
276 i.WriteU8((data >> 32) & 0xff);
277 i.WriteU8((data >> 24) & 0xff);
278 i.WriteU8((data >> 16) & 0xff);
279 i.WriteU8((data >> 8) & 0xff);
280 i.WriteU8((data >> 0) & 0xff);
281}
282
283uint64_t
285{
286 uint64_t retval = 0;
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 retval <<= 8;
295 retval |= i.ReadU8();
296 return retval;
297}
298
299void
301{
302 i.WriteU8(80); // IE Type = Bearer QoS
303 i.WriteHtonU16(22); // Length
304 i.WriteU8(0); // Spare + Instance
305 i.WriteU8(0); // MRE TODO: bearerQos.arp
306 i.WriteU8(bearerQos.qci);
307 WriteHtonU40(i, bearerQos.gbrQosInfo.mbrUl);
308 WriteHtonU40(i, bearerQos.gbrQosInfo.mbrDl);
309 WriteHtonU40(i, bearerQos.gbrQosInfo.gbrUl);
310 WriteHtonU40(i, bearerQos.gbrQosInfo.gbrDl);
311}
312
315{
316 uint8_t type = i.ReadU8();
317 NS_ASSERT_MSG(type == 80, "Wrong Bearer QoS IE type = " << (uint16_t)type);
318 uint16_t length = i.ReadNtohU16();
319 NS_ASSERT_MSG(length == 22, "Wrong Bearer QoS IE length");
320 uint8_t instance = i.ReadU8();
321 NS_ASSERT_MSG(instance == 0, "Wrong Bearer QoS IE instance");
322 i.ReadU8();
323 bearerQos.qci = EpsBearer::Qci(i.ReadU8());
324 bearerQos.gbrQosInfo.mbrUl = ReadNtohU40(i);
325 bearerQos.gbrQosInfo.mbrDl = ReadNtohU40(i);
326 bearerQos.gbrQosInfo.gbrUl = ReadNtohU40(i);
327 bearerQos.gbrQosInfo.gbrDl = ReadNtohU40(i);
329}
330
331void
333 std::list<EpcTft::PacketFilter> packetFilters) const
334{
335 i.WriteU8(84); // IE Type = EPS Bearer Level Fraffic Flow Template (Bearer TFT)
336 i.WriteHtonU16(1 + packetFilters.size() * serializedSizePacketFilter);
337 i.WriteU8(0); // Spare + Instance
338 i.WriteU8(0x20 + (packetFilters.size() & 0x0f)); // Create new TFT + Number of packet filters
339
340 for (auto& pf : packetFilters)
341 {
342 i.WriteU8((pf.direction << 4) & 0x30);
343 i.WriteU8(pf.precedence);
344 i.WriteU8(serializedSizePacketFilter - 3); // Length of Packet filter contents
345
346 i.WriteU8(0x10); // IPv4 remote address type
347 i.WriteHtonU32(pf.remoteAddress.Get());
348 i.WriteHtonU32(pf.remoteMask.Get());
349 i.WriteU8(0x11); // IPv4 local address type
350 i.WriteHtonU32(pf.localAddress.Get());
351 i.WriteHtonU32(pf.localMask.Get());
352 i.WriteU8(0x41); // Local port range type
353 i.WriteHtonU16(pf.localPortStart);
354 i.WriteHtonU16(pf.localPortEnd);
355 i.WriteU8(0x51); // Remote port range type
356 i.WriteHtonU16(pf.remotePortStart);
357 i.WriteHtonU16(pf.remotePortEnd);
358 i.WriteU8(0x70); // Type of service
359 i.WriteU8(pf.typeOfService);
360 i.WriteU8(pf.typeOfServiceMask);
361 }
362}
363
366{
367 uint8_t type = i.ReadU8();
368 NS_ASSERT_MSG(type == 84, "Wrong Bearer TFT IE type = " << (uint16_t)type);
369 i.ReadNtohU16();
370 i.ReadU8();
371 uint8_t numberOfPacketFilters = i.ReadU8() & 0x0f;
372
373 for (uint8_t pf = 0; pf < numberOfPacketFilters; ++pf)
374 {
375 EpcTft::PacketFilter packetFilter;
376 packetFilter.direction = EpcTft::Direction((i.ReadU8() & 0x30) >> 4);
377 packetFilter.precedence = i.ReadU8();
378 i.ReadU8(); // Length of Packet filter contents
379 i.ReadU8();
380 packetFilter.remoteAddress = Ipv4Address(i.ReadNtohU32());
381 packetFilter.remoteMask = Ipv4Mask(i.ReadNtohU32());
382 i.ReadU8();
383 packetFilter.localAddress = Ipv4Address(i.ReadNtohU32());
384 packetFilter.localMask = Ipv4Mask(i.ReadNtohU32());
385 i.ReadU8();
386 packetFilter.localPortStart = i.ReadNtohU16();
387 packetFilter.localPortEnd = i.ReadNtohU16();
388 i.ReadU8();
389 packetFilter.remotePortStart = i.ReadNtohU16();
390 packetFilter.remotePortEnd = i.ReadNtohU16();
391 i.ReadU8();
392 packetFilter.typeOfService = i.ReadU8();
393 packetFilter.typeOfServiceMask = i.ReadU8();
394 epcTft->Add(packetFilter);
395 }
396
397 return GetSerializedSizeBearerTft(epcTft->GetPacketFilters());
398}
399
401GtpcIes::GetSerializedSizeBearerTft(std::list<EpcTft::PacketFilter> packetFilters) const
402{
403 return (5 + packetFilters.size() * serializedSizePacketFilter);
404}
405
406void
408{
409 i.WriteU8(86); // IE Type = ULI (ECGI)
410 i.WriteHtonU16(8); // Length
411 i.WriteU8(0); // Spare + Instance
412 i.WriteU8(0x10); // ECGI flag
413 i.WriteU8(0); // Dummy MCC and MNC
414 i.WriteU8(0); // Dummy MCC and MNC
415 i.WriteU8(0); // Dummy MCC and MNC
416 i.WriteHtonU32(uliEcgi);
417}
418
421{
422 uint8_t type = i.ReadU8();
423 NS_ASSERT_MSG(type == 86, "Wrong ULI ECGI IE type = " << (uint16_t)type);
424 uint16_t length = i.ReadNtohU16();
425 NS_ASSERT_MSG(length == 8, "Wrong ULI ECGI IE length");
426 uint8_t instance = i.ReadU8() & 0x0f;
427 NS_ASSERT_MSG(instance == 0, "Wrong ULI ECGI IE instance");
428 i.Next(4);
429 uliEcgi = i.ReadNtohU32() & 0x0fffffff;
430
432}
433
434void
436{
437 i.WriteU8(87); // IE Type = Fully Qualified TEID (F-TEID)
438 i.WriteHtonU16(9); // Length
439 i.WriteU8(0); // Spare + Instance
440 i.WriteU8(0x80 | ((uint8_t)fteid.interfaceType & 0x1f)); // IP version flag + Iface type
441 i.WriteHtonU32(fteid.teid); // TEID
442 i.WriteHtonU32(fteid.addr.Get()); // IPv4 address
443}
444
447{
448 uint8_t type = i.ReadU8();
449 NS_ASSERT_MSG(type == 87, "Wrong FTEID IE type = " << (uint16_t)type);
450 uint16_t length = i.ReadNtohU16();
451 NS_ASSERT_MSG(length == 9, "Wrong FTEID IE length");
452 uint8_t instance = i.ReadU8() & 0x0f;
453 NS_ASSERT_MSG(instance == 0, "Wrong FTEID IE instance");
454 uint8_t flags = i.ReadU8(); // IP version flag + Iface type
455 fteid.interfaceType = GtpcHeader::InterfaceType_t(flags & 0x1f);
456 fteid.teid = i.ReadNtohU32(); // TEID
457 fteid.addr.Set(i.ReadNtohU32()); // IPv4 address
458
459 return serializedSizeFteid;
460}
461
462void
464{
465 i.WriteU8(93); // IE Type = Bearer Context
466 i.WriteU16(length);
467 i.WriteU8(0); // Spare + Instance
468}
469
472{
473 uint8_t type = i.ReadU8();
474 NS_ASSERT_MSG(type == 93, "Wrong Bearer Context IE type = " << (uint16_t)type);
475 length = i.ReadNtohU16();
476 uint8_t instance = i.ReadU8() & 0x0f;
477 NS_ASSERT_MSG(instance == 0, "Wrong Bearer Context IE instance");
478
480}
481
482/////////////////////////////////////////////////////////////////////
483
484TypeId
486{
487 static TypeId tid = TypeId("ns3::GtpcCreateSessionRequestMessage")
488 .SetParent<Header>()
489 .SetGroupName("Lte")
490 .AddConstructor<GtpcCreateSessionRequestMessage>();
491 return tid;
492}
493
495{
498 m_imsi = 0;
499 m_uliEcgi = 0;
500}
501
503{
504}
505
506TypeId
508{
509 return GetTypeId();
510}
511
514{
516 for (auto& bc : m_bearerContextsToBeCreated)
517 {
519 GetSerializedSizeBearerTft(bc.tft->GetPacketFilters()) +
521 }
522
523 return serializedSize;
524}
525
528{
530}
531
532void
534{
535 Buffer::Iterator i = start;
536
541
542 for (auto& bc : m_bearerContextsToBeCreated)
543 {
544 std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters();
545
549
550 SerializeEbi(i, bc.epsBearerId);
551 SerializeBearerTft(i, packetFilters);
552 SerializeFteid(i, bc.sgwS5uFteid);
553 SerializeBearerQos(i, bc.bearerLevelQos);
554 }
555}
556
559{
560 Buffer::Iterator i = start;
562
566
568 while (i.GetRemainingSize() > 0)
569 {
570 uint16_t length;
572
573 BearerContextToBeCreated bearerContext;
574 DeserializeEbi(i, bearerContext.epsBearerId);
575
576 Ptr<EpcTft> epcTft = Create<EpcTft>();
577 DeserializeBearerTft(i, epcTft);
578 bearerContext.tft = epcTft;
579
580 DeserializeFteid(i, bearerContext.sgwS5uFteid);
581 DeserializeBearerQos(i, bearerContext.bearerLevelQos);
582
583 m_bearerContextsToBeCreated.push_back(bearerContext);
584 }
585
586 return GetSerializedSize();
587}
588
589void
591{
592 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
593}
594
595uint64_t
597{
598 return m_imsi;
599}
600
601void
603{
604 m_imsi = imsi;
605}
606
609{
610 return m_uliEcgi;
611}
612
613void
615{
616 m_uliEcgi = uliEcgi;
617}
618
621{
622 return m_senderCpFteid;
623}
624
625void
627{
628 m_senderCpFteid = fteid;
629}
630
631std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated>
633{
635}
636
637void
639 std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts)
640{
641 m_bearerContextsToBeCreated = bearerContexts;
642}
643
644/////////////////////////////////////////////////////////////////////
645
646TypeId
648{
649 static TypeId tid = TypeId("ns3::GtpcCreateSessionResponseMessage")
650 .SetParent<Header>()
651 .SetGroupName("Lte")
652 .AddConstructor<GtpcCreateSessionResponseMessage>();
653 return tid;
654}
655
657{
661}
662
664{
665}
666
667TypeId
669{
670 return GetTypeId();
671}
672
675{
677 for (auto& bc : m_bearerContextsCreated)
678 {
680 GetSerializedSizeBearerTft(bc.tft->GetPacketFilters()) +
682 }
683
684 return serializedSize;
685}
686
689{
691}
692
693void
695{
696 Buffer::Iterator i = start;
697
701
702 for (auto& bc : m_bearerContextsCreated)
703 {
704 std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters();
705
709
710 SerializeEbi(i, bc.epsBearerId);
711 SerializeBearerTft(i, packetFilters);
712 SerializeFteid(i, bc.fteid);
713 SerializeBearerQos(i, bc.bearerLevelQos);
714 }
715}
716
719{
720 Buffer::Iterator i = start;
722
725
727 while (i.GetRemainingSize() > 0)
728 {
729 BearerContextCreated bearerContext;
730 uint16_t length;
731
733 DeserializeEbi(i, bearerContext.epsBearerId);
734
735 Ptr<EpcTft> epcTft = Create<EpcTft>();
736 DeserializeBearerTft(i, epcTft);
737 bearerContext.tft = epcTft;
738
739 DeserializeFteid(i, bearerContext.fteid);
740 DeserializeBearerQos(i, bearerContext.bearerLevelQos);
741
742 m_bearerContextsCreated.push_back(bearerContext);
743 }
744
745 return GetSerializedSize();
746}
747
748void
750{
751 os << " cause " << m_cause << " FTEID " << m_senderCpFteid.addr << "," << m_senderCpFteid.teid;
752}
753
756{
757 return m_cause;
758}
759
760void
762{
763 m_cause = cause;
764}
765
768{
769 return m_senderCpFteid;
770}
771
772void
774{
775 m_senderCpFteid = fteid;
776}
777
778std::list<GtpcCreateSessionResponseMessage::BearerContextCreated>
780{
782}
783
784void
786 std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContexts)
787{
788 m_bearerContextsCreated = bearerContexts;
789}
790
791/////////////////////////////////////////////////////////////////////
792
793TypeId
795{
796 static TypeId tid = TypeId("ns3::GtpcModifyBearerRequestMessage")
797 .SetParent<Header>()
798 .SetGroupName("Lte")
799 .AddConstructor<GtpcModifyBearerRequestMessage>();
800 return tid;
801}
802
804{
807 m_imsi = 0;
808 m_uliEcgi = 0;
809}
810
812{
813}
814
815TypeId
817{
818 return GetTypeId();
819}
820
823{
824 uint32_t serializedSize =
828 return serializedSize;
829}
830
833{
835}
836
837void
839{
840 Buffer::Iterator i = start;
841
845
846 for (auto& bc : m_bearerContextsToBeModified)
847 {
849
850 SerializeEbi(i, bc.epsBearerId);
851 SerializeFteid(i, bc.fteid);
852 }
853}
854
857{
858 Buffer::Iterator i = start;
860
863
864 while (i.GetRemainingSize() > 0)
865 {
866 BearerContextToBeModified bearerContext;
867 uint16_t length;
868
870
871 DeserializeEbi(i, bearerContext.epsBearerId);
872 DeserializeFteid(i, bearerContext.fteid);
873
874 m_bearerContextsToBeModified.push_back(bearerContext);
875 }
876
877 return GetSerializedSize();
878}
879
880void
882{
883 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
884}
885
886uint64_t
888{
889 return m_imsi;
890}
891
892void
894{
895 m_imsi = imsi;
896}
897
900{
901 return m_uliEcgi;
902}
903
904void
906{
907 m_uliEcgi = uliEcgi;
908}
909
910std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified>
912{
914}
915
916void
918 std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts)
919{
920 m_bearerContextsToBeModified = bearerContexts;
921}
922
923/////////////////////////////////////////////////////////////////////
924
925TypeId
927{
928 static TypeId tid = TypeId("ns3::GtpcModifyBearerResponseMessage")
929 .SetParent<Header>()
930 .SetGroupName("Lte")
931 .AddConstructor<GtpcModifyBearerResponseMessage>();
932 return tid;
933}
934
936{
940}
941
943{
944}
945
946TypeId
948{
949 return GetTypeId();
950}
951
954{
955 return serializedSizeCause;
956}
957
960{
962}
963
964void
966{
967 Buffer::Iterator i = start;
968
971}
972
975{
976 Buffer::Iterator i = start;
978
980
981 return GetSerializedSize();
982}
983
984void
986{
987 os << " cause " << (uint16_t)m_cause;
988}
989
992{
993 return m_cause;
994}
995
996void
998{
999 m_cause = cause;
1000}
1001
1002/////////////////////////////////////////////////////////////////////
1003
1004TypeId
1006{
1007 static TypeId tid = TypeId("ns3::GtpcDeleteBearerCommandMessage")
1008 .SetParent<Header>()
1009 .SetGroupName("Lte")
1010 .AddConstructor<GtpcDeleteBearerCommandMessage>();
1011 return tid;
1012}
1013
1015{
1018}
1019
1021{
1022}
1023
1024TypeId
1026{
1027 return GetTypeId();
1028}
1029
1032{
1033 uint32_t serializedSize =
1035 return serializedSize;
1036}
1037
1040{
1042}
1043
1044void
1046{
1047 Buffer::Iterator i = start;
1048
1050 for (auto& bearerContext : m_bearerContexts)
1051 {
1053
1054 SerializeEbi(i, bearerContext.m_epsBearerId);
1055 }
1056}
1057
1060{
1061 Buffer::Iterator i = start;
1063
1064 while (i.GetRemainingSize() > 0)
1065 {
1066 uint16_t length;
1068
1069 BearerContext bearerContext;
1070 DeserializeEbi(i, bearerContext.m_epsBearerId);
1071 m_bearerContexts.push_back(bearerContext);
1072 }
1073
1074 return GetSerializedSize();
1075}
1076
1077void
1079{
1080 os << " bearerContexts [";
1081 for (auto& bearerContext : m_bearerContexts)
1082 {
1083 os << (uint16_t)bearerContext.m_epsBearerId << " ";
1084 }
1085 os << "]";
1086}
1087
1088std::list<GtpcDeleteBearerCommandMessage::BearerContext>
1090{
1091 return m_bearerContexts;
1092}
1093
1094void
1096 std::list<GtpcDeleteBearerCommandMessage::BearerContext> bearerContexts)
1097{
1098 m_bearerContexts = bearerContexts;
1099}
1100
1101/////////////////////////////////////////////////////////////////////
1102
1103TypeId
1105{
1106 static TypeId tid = TypeId("ns3::GtpcDeleteBearerRequestMessage")
1107 .SetParent<Header>()
1108 .SetGroupName("Lte")
1109 .AddConstructor<GtpcDeleteBearerRequestMessage>();
1110 return tid;
1111}
1112
1114{
1117}
1118
1120{
1121}
1122
1123TypeId
1125{
1126 return GetTypeId();
1127}
1128
1131{
1132 uint32_t serializedSize = m_epsBearerIds.size() * serializedSizeEbi;
1133 return serializedSize;
1134}
1135
1138{
1140}
1141
1142void
1144{
1145 Buffer::Iterator i = start;
1146
1148 for (auto& epsBearerId : m_epsBearerIds)
1149 {
1150 SerializeEbi(i, epsBearerId);
1151 }
1152}
1153
1156{
1157 Buffer::Iterator i = start;
1159
1160 while (i.GetRemainingSize() > 0)
1161 {
1162 uint8_t epsBearerId;
1163 DeserializeEbi(i, epsBearerId);
1164 m_epsBearerIds.push_back(epsBearerId);
1165 }
1166
1167 return GetSerializedSize();
1168}
1169
1170void
1172{
1173 os << " epsBearerIds [";
1174 for (auto& epsBearerId : m_epsBearerIds)
1175 {
1176 os << (uint16_t)epsBearerId << " ";
1177 }
1178 os << "]";
1179}
1180
1181std::list<uint8_t>
1183{
1184 return m_epsBearerIds;
1185}
1186
1187void
1189{
1190 m_epsBearerIds = epsBearerId;
1191}
1192
1193/////////////////////////////////////////////////////////////////////
1194
1195TypeId
1197{
1198 static TypeId tid = TypeId("ns3::GtpcDeleteBearerResponseMessage")
1199 .SetParent<Header>()
1200 .SetGroupName("Lte")
1201 .AddConstructor<GtpcDeleteBearerResponseMessage>();
1202 return tid;
1203}
1204
1206{
1209}
1210
1212{
1213}
1214
1215TypeId
1217{
1218 return GetTypeId();
1219}
1220
1223{
1225 return serializedSize;
1226}
1227
1230{
1232}
1233
1234void
1236{
1237 Buffer::Iterator i = start;
1238
1241
1242 for (auto& epsBearerId : m_epsBearerIds)
1243 {
1244 SerializeEbi(i, epsBearerId);
1245 }
1246}
1247
1250{
1251 Buffer::Iterator i = start;
1253
1255
1256 while (i.GetRemainingSize() > 0)
1257 {
1258 uint8_t epsBearerId;
1259 DeserializeEbi(i, epsBearerId);
1260 m_epsBearerIds.push_back(epsBearerId);
1261 }
1262
1263 return GetSerializedSize();
1264}
1265
1266void
1268{
1269 os << " cause " << (uint16_t)m_cause << " epsBearerIds [";
1270 for (auto& epsBearerId : m_epsBearerIds)
1271 {
1272 os << (uint16_t)epsBearerId << " ";
1273 }
1274 os << "]";
1275}
1276
1279{
1280 return m_cause;
1281}
1282
1283void
1285{
1286 m_cause = cause;
1287}
1288
1289std::list<uint8_t>
1291{
1292 return m_epsBearerIds;
1293}
1294
1295void
1297{
1298 m_epsBearerIds = epsBearerId;
1299}
1300
1301} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint32_t GetRemainingSize() const
Definition: buffer.cc:1173
void WriteHtonU64(uint64_t data)
Definition: buffer.cc:934
uint64_t ReadNtohU64()
Definition: buffer.cc:1041
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void WriteU16(uint16_t data)
Definition: buffer.cc:859
void WriteHtonU16(uint16_t data)
Definition: buffer.h:915
uint32_t ReadNtohU32()
Definition: buffer.h:978
void WriteHtonU32(uint32_t data)
Definition: buffer.h:933
uint16_t ReadNtohU16()
Definition: buffer.h:954
void Next()
go forward by one byte
Definition: buffer.h:853
Direction
Indicates the direction of the traffic that is to be classified.
Definition: epc-tft.h:51
This class contains the specification of EPS Bearers.
Definition: eps-bearer.h:91
Qci qci
Qos class indicator.
Definition: eps-bearer.h:151
GbrQosInformation gbrQosInfo
GBR QOS information.
Definition: eps-bearer.h:153
Qci
QoS Class Indicator.
Definition: eps-bearer.h:106
GTP-C Create Session Request Message.
std::list< BearerContextToBeCreated > m_bearerContextsToBeCreated
Bearer Context list.
static TypeId GetTypeId()
Get the type ID.
uint64_t GetImsi() const
Get the IMSI.
uint32_t Deserialize(Buffer::Iterator start) override
void SetUliEcgi(uint32_t uliEcgi)
Set the UliEcgi.
GtpcHeader::Fteid_t GetSenderCpFteid() const
Get the Sender CpFteid.
uint32_t GetUliEcgi() const
Get the UliEcgi.
uint32_t GetMessageSize() const override
Get the message size.
uint32_t GetSerializedSize() const override
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.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void Serialize(Buffer::Iterator start) const override
void SetImsi(uint64_t imsi)
Set the IMSI.
void Print(std::ostream &os) const override
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Set the Sender CpFteid.
GTP-C Create Session Response Message.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetCause(Cause_t cause)
Set the Cause.
static TypeId GetTypeId()
Get the type ID.
uint32_t Deserialize(Buffer::Iterator start) override
void SetBearerContextsCreated(std::list< BearerContextCreated > bearerContexts)
Set the Bearer Contexts.
Cause_t GetCause() const
Get the Cause.
void Print(std::ostream &os) const override
void SetSenderCpFteid(GtpcHeader::Fteid_t fteid)
Set the Sender CpFteid.
void Serialize(Buffer::Iterator start) const override
uint32_t GetSerializedSize() const override
std::list< BearerContextCreated > m_bearerContextsCreated
Container of Bearer Contexts.
std::list< BearerContextCreated > GetBearerContextsCreated() const
Get the Container of Bearer Contexts.
uint32_t GetMessageSize() const override
Get the message size.
GtpcHeader::Fteid_t m_senderCpFteid
Sender CpFteid.
GtpcHeader::Fteid_t GetSenderCpFteid() const
Get the Sender CpFteid.
GTP-C Delete Bearer Command Message.
void Print(std::ostream &os) const override
std::list< BearerContext > GetBearerContexts() const
Get the Bearer contexts.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
std::list< BearerContext > m_bearerContexts
Container of Bearer Contexts.
void SetBearerContexts(std::list< BearerContext > bearerContexts)
Set the Bearer contexts.
uint32_t GetMessageSize() const override
Get the message size.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
void Serialize(Buffer::Iterator start) const override
GTP-C Delete Bearer Request Message.
uint32_t GetSerializedSize() const override
uint32_t GetMessageSize() const override
Get the message size.
static TypeId GetTypeId()
Get the type ID.
void Print(std::ostream &os) const override
std::list< uint8_t > m_epsBearerIds
Container of Bearers IDs.
uint32_t Deserialize(Buffer::Iterator start) override
void Serialize(Buffer::Iterator start) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
std::list< uint8_t > GetEpsBearerIds() const
Get the Bearers IDs.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Set the Bearers IDs.
GTP-C Delete Bearer Response Message.
void Serialize(Buffer::Iterator start) const override
uint32_t GetSerializedSize() const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetCause(Cause_t cause)
Set the Cause.
Cause_t GetCause() const
Get the Cause.
std::list< uint8_t > m_epsBearerIds
Container of Bearers IDs.
uint32_t GetMessageSize() const override
Get the message size.
std::list< uint8_t > GetEpsBearerIds() const
Get the Bearers IDs.
void Print(std::ostream &os) const override
uint32_t Deserialize(Buffer::Iterator start) override
static TypeId GetTypeId()
Get the type ID.
void SetEpsBearerIds(std::list< uint8_t > epsBearerIds)
Set the Bearers IDs.
Header of the GTPv2-C protocol.
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.
static TypeId GetTypeId()
Get the type ID.
uint16_t GetMessageLength() const
Get message length.
uint8_t m_messageType
Message type field.
void Serialize(Buffer::Iterator start) const override
uint8_t GetMessageType() const
Get message type.
void SetMessageType(uint8_t messageType)
Set message type.
virtual uint32_t GetMessageSize() const
Get the message size.
InterfaceType_t
Interface Type enumeration.
uint32_t GetSequenceNumber() const
Get sequence number.
uint32_t m_sequenceNumber
GTP Sequence number field.
void Print(std::ostream &os) const override
uint32_t m_teid
Tunnel Endpoint Identifier (TEID) field.
bool m_teidFlag
TEID flag.
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
void SetSequenceNumber(uint32_t sequenceNumber)
Set sequence number.
uint32_t PreDeserialize(Buffer::Iterator &i)
Deserialize the GTP-C header in the GTP-C messages.
void ComputeMessageLength()
Compute the message length according to the message type.
~GtpcHeader() override
void SetIesLength(uint16_t iesLength)
Set IEs length.
void SetTeid(uint32_t teid)
Set TEID.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t GetTeid() const
Get TEID.
uint32_t DeserializeFteid(Buffer::Iterator &i, GtpcHeader::Fteid_t &fteid) const
Deserialize the Fteid.
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 DeserializeImsi(Buffer::Iterator &i, uint64_t &imsi) const
Deserialize the IMSI.
uint32_t DeserializeEbi(Buffer::Iterator &i, uint8_t &epsBearerId) const
Deserialize the eps Bearer Id.
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.
uint32_t DeserializeUliEcgi(Buffer::Iterator &i, uint32_t &uliEcgi) const
Deserialize the UliEcgi.
const uint32_t serializedSizeBearerContextHeader
Fteid serialized size.
uint32_t DeserializeCause(Buffer::Iterator &i, Cause_t &cause) const
Deserialize the Cause.
uint32_t GetSerializedSizeBearerTft(std::list< EpcTft::PacketFilter > packetFilters) const
void SerializeFteid(Buffer::Iterator &i, GtpcHeader::Fteid_t fteid) const
Serialize the Fteid_t.
uint32_t DeserializeBearerTft(Buffer::Iterator &i, Ptr< EpcTft > epcTft) const
Deserialize the Bearer TFT.
const uint32_t serializedSizePacketFilter
Packet filter serialized size.
uint64_t ReadNtohU40(Buffer::Iterator &i)
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.
uint32_t DeserializeBearerContextHeader(Buffer::Iterator &i, uint16_t &length) const
Deserialize the Bearer Context Header.
void SerializeCause(Buffer::Iterator &i, Cause_t cause) const
Serialize the Cause.
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.
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 Print(std::ostream &os) const override
void SetBearerContextsToBeModified(std::list< BearerContextToBeModified > bearerContexts)
Set the Bearer Contexts.
uint32_t GetUliEcgi() const
Get the UliEcgi.
void SetUliEcgi(uint32_t uliEcgi)
Set the UliEcgi.
uint32_t Deserialize(Buffer::Iterator start) override
std::list< BearerContextToBeModified > GetBearerContextsToBeModified() const
Get the Bearer Contexts.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t GetMessageSize() const override
Get the message size.
static TypeId GetTypeId()
Get the type ID.
void SetImsi(uint64_t imsi)
Set the IMSI.
std::list< BearerContextToBeModified > m_bearerContextsToBeModified
Bearer Context list.
uint32_t GetSerializedSize() const override
void Serialize(Buffer::Iterator start) const override
GTP-C Modify Bearer Response Message.
uint32_t Deserialize(Buffer::Iterator start) override
uint32_t GetSerializedSize() const override
uint32_t GetMessageSize() const override
Get the message size.
void SetCause(Cause_t cause)
Set the Cause.
static TypeId GetTypeId()
Get the type ID.
void Print(std::ostream &os) const override
Cause_t GetCause() const
Get the Cause.
void Serialize(Buffer::Iterator start) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Protocol header serialization and deserialization.
Definition: header.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
void Set(uint32_t address)
input address is in host order.
uint32_t Get() const
Get the host-order 32-bit IP address.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#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
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint8_t VERSION
GTPv2-C protocol version number.
uint8_t data[writeSize]
Implement the data structure representing a TrafficFlowTemplate Packet Filter.
Definition: epc-tft.h:71
Ipv4Address localAddress
IPv4 address of the UE.
Definition: epc-tft.h:121
uint16_t localPortEnd
end of the port number range of the UE
Definition: epc-tft.h:132
Ipv4Mask localMask
IPv4 address mask of the UE.
Definition: epc-tft.h:122
uint16_t remotePortEnd
end of the port number range of the remote host
Definition: epc-tft.h:130
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:114
Direction direction
Whether the filter needs to be applied to uplink / downlink only, or in both cases.
Definition: epc-tft.h:117
Ipv4Mask remoteMask
IPv4 address mask of the remote host.
Definition: epc-tft.h:120
uint16_t remotePortStart
start of the port number range of the remote host
Definition: epc-tft.h:129
uint8_t typeOfService
type of service field
Definition: epc-tft.h:134
Ipv4Address remoteAddress
IPv4 address of the remote host.
Definition: epc-tft.h:119
uint8_t typeOfServiceMask
type of service field mask
Definition: epc-tft.h:135
uint16_t localPortStart
start of the port number range of the UE
Definition: epc-tft.h:131
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.