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 m_senderCpFteid = {};
501}
502
504{
505}
506
507TypeId
509{
510 return GetTypeId();
511}
512
515{
517 for (auto& bc : m_bearerContextsToBeCreated)
518 {
520 GetSerializedSizeBearerTft(bc.tft->GetPacketFilters()) +
522 }
523
524 return serializedSize;
525}
526
529{
531}
532
533void
535{
536 Buffer::Iterator i = start;
537
542
543 for (auto& bc : m_bearerContextsToBeCreated)
544 {
545 std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters();
546
550
551 SerializeEbi(i, bc.epsBearerId);
552 SerializeBearerTft(i, packetFilters);
553 SerializeFteid(i, bc.sgwS5uFteid);
554 SerializeBearerQos(i, bc.bearerLevelQos);
555 }
556}
557
560{
561 Buffer::Iterator i = start;
563
567
569 while (i.GetRemainingSize() > 0)
570 {
571 uint16_t length;
573
574 BearerContextToBeCreated bearerContext;
575 DeserializeEbi(i, bearerContext.epsBearerId);
576
577 Ptr<EpcTft> epcTft = Create<EpcTft>();
578 DeserializeBearerTft(i, epcTft);
579 bearerContext.tft = epcTft;
580
581 DeserializeFteid(i, bearerContext.sgwS5uFteid);
582 DeserializeBearerQos(i, bearerContext.bearerLevelQos);
583
584 m_bearerContextsToBeCreated.push_back(bearerContext);
585 }
586
587 return GetSerializedSize();
588}
589
590void
592{
593 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
594}
595
596uint64_t
598{
599 return m_imsi;
600}
601
602void
604{
605 m_imsi = imsi;
606}
607
610{
611 return m_uliEcgi;
612}
613
614void
616{
617 m_uliEcgi = uliEcgi;
618}
619
622{
623 return m_senderCpFteid;
624}
625
626void
628{
629 m_senderCpFteid = fteid;
630}
631
632std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated>
634{
636}
637
638void
640 std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts)
641{
642 m_bearerContextsToBeCreated = bearerContexts;
643}
644
645/////////////////////////////////////////////////////////////////////
646
647TypeId
649{
650 static TypeId tid = TypeId("ns3::GtpcCreateSessionResponseMessage")
651 .SetParent<Header>()
652 .SetGroupName("Lte")
653 .AddConstructor<GtpcCreateSessionResponseMessage>();
654 return tid;
655}
656
658{
662 m_senderCpFteid = {};
663}
664
666{
667}
668
669TypeId
671{
672 return GetTypeId();
673}
674
677{
679 for (auto& bc : m_bearerContextsCreated)
680 {
682 GetSerializedSizeBearerTft(bc.tft->GetPacketFilters()) +
684 }
685
686 return serializedSize;
687}
688
691{
693}
694
695void
697{
698 Buffer::Iterator i = start;
699
703
704 for (auto& bc : m_bearerContextsCreated)
705 {
706 std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters();
707
711
712 SerializeEbi(i, bc.epsBearerId);
713 SerializeBearerTft(i, packetFilters);
714 SerializeFteid(i, bc.fteid);
715 SerializeBearerQos(i, bc.bearerLevelQos);
716 }
717}
718
721{
722 Buffer::Iterator i = start;
724
727
729 while (i.GetRemainingSize() > 0)
730 {
731 BearerContextCreated bearerContext;
732 uint16_t length;
733
735 DeserializeEbi(i, bearerContext.epsBearerId);
736
737 Ptr<EpcTft> epcTft = Create<EpcTft>();
738 DeserializeBearerTft(i, epcTft);
739 bearerContext.tft = epcTft;
740
741 DeserializeFteid(i, bearerContext.fteid);
742 DeserializeBearerQos(i, bearerContext.bearerLevelQos);
743
744 m_bearerContextsCreated.push_back(bearerContext);
745 }
746
747 return GetSerializedSize();
748}
749
750void
752{
753 os << " cause " << m_cause << " FTEID " << m_senderCpFteid.addr << "," << m_senderCpFteid.teid;
754}
755
758{
759 return m_cause;
760}
761
762void
764{
765 m_cause = cause;
766}
767
770{
771 return m_senderCpFteid;
772}
773
774void
776{
777 m_senderCpFteid = fteid;
778}
779
780std::list<GtpcCreateSessionResponseMessage::BearerContextCreated>
782{
784}
785
786void
788 std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContexts)
789{
790 m_bearerContextsCreated = bearerContexts;
791}
792
793/////////////////////////////////////////////////////////////////////
794
795TypeId
797{
798 static TypeId tid = TypeId("ns3::GtpcModifyBearerRequestMessage")
799 .SetParent<Header>()
800 .SetGroupName("Lte")
801 .AddConstructor<GtpcModifyBearerRequestMessage>();
802 return tid;
803}
804
806{
809 m_imsi = 0;
810 m_uliEcgi = 0;
811}
812
814{
815}
816
817TypeId
819{
820 return GetTypeId();
821}
822
825{
826 uint32_t serializedSize =
830 return serializedSize;
831}
832
835{
837}
838
839void
841{
842 Buffer::Iterator i = start;
843
847
848 for (auto& bc : m_bearerContextsToBeModified)
849 {
851
852 SerializeEbi(i, bc.epsBearerId);
853 SerializeFteid(i, bc.fteid);
854 }
855}
856
859{
860 Buffer::Iterator i = start;
862
865
866 while (i.GetRemainingSize() > 0)
867 {
868 BearerContextToBeModified bearerContext;
869 uint16_t length;
870
872
873 DeserializeEbi(i, bearerContext.epsBearerId);
874 DeserializeFteid(i, bearerContext.fteid);
875
876 m_bearerContextsToBeModified.push_back(bearerContext);
877 }
878
879 return GetSerializedSize();
880}
881
882void
884{
885 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
886}
887
888uint64_t
890{
891 return m_imsi;
892}
893
894void
896{
897 m_imsi = imsi;
898}
899
902{
903 return m_uliEcgi;
904}
905
906void
908{
909 m_uliEcgi = uliEcgi;
910}
911
912std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified>
914{
916}
917
918void
920 std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts)
921{
922 m_bearerContextsToBeModified = bearerContexts;
923}
924
925/////////////////////////////////////////////////////////////////////
926
927TypeId
929{
930 static TypeId tid = TypeId("ns3::GtpcModifyBearerResponseMessage")
931 .SetParent<Header>()
932 .SetGroupName("Lte")
933 .AddConstructor<GtpcModifyBearerResponseMessage>();
934 return tid;
935}
936
938{
942}
943
945{
946}
947
948TypeId
950{
951 return GetTypeId();
952}
953
956{
957 return serializedSizeCause;
958}
959
962{
964}
965
966void
968{
969 Buffer::Iterator i = start;
970
973}
974
977{
978 Buffer::Iterator i = start;
980
982
983 return GetSerializedSize();
984}
985
986void
988{
989 os << " cause " << (uint16_t)m_cause;
990}
991
994{
995 return m_cause;
996}
997
998void
1000{
1001 m_cause = cause;
1002}
1003
1004/////////////////////////////////////////////////////////////////////
1005
1006TypeId
1008{
1009 static TypeId tid = TypeId("ns3::GtpcDeleteBearerCommandMessage")
1010 .SetParent<Header>()
1011 .SetGroupName("Lte")
1012 .AddConstructor<GtpcDeleteBearerCommandMessage>();
1013 return tid;
1014}
1015
1017{
1020}
1021
1023{
1024}
1025
1026TypeId
1028{
1029 return GetTypeId();
1030}
1031
1034{
1035 uint32_t serializedSize =
1037 return serializedSize;
1038}
1039
1042{
1044}
1045
1046void
1048{
1049 Buffer::Iterator i = start;
1050
1052 for (auto& bearerContext : m_bearerContexts)
1053 {
1055
1056 SerializeEbi(i, bearerContext.m_epsBearerId);
1057 }
1058}
1059
1062{
1063 Buffer::Iterator i = start;
1065
1066 while (i.GetRemainingSize() > 0)
1067 {
1068 uint16_t length;
1070
1071 BearerContext bearerContext;
1072 DeserializeEbi(i, bearerContext.m_epsBearerId);
1073 m_bearerContexts.push_back(bearerContext);
1074 }
1075
1076 return GetSerializedSize();
1077}
1078
1079void
1081{
1082 os << " bearerContexts [";
1083 for (auto& bearerContext : m_bearerContexts)
1084 {
1085 os << (uint16_t)bearerContext.m_epsBearerId << " ";
1086 }
1087 os << "]";
1088}
1089
1090std::list<GtpcDeleteBearerCommandMessage::BearerContext>
1092{
1093 return m_bearerContexts;
1094}
1095
1096void
1098 std::list<GtpcDeleteBearerCommandMessage::BearerContext> bearerContexts)
1099{
1100 m_bearerContexts = bearerContexts;
1101}
1102
1103/////////////////////////////////////////////////////////////////////
1104
1105TypeId
1107{
1108 static TypeId tid = TypeId("ns3::GtpcDeleteBearerRequestMessage")
1109 .SetParent<Header>()
1110 .SetGroupName("Lte")
1111 .AddConstructor<GtpcDeleteBearerRequestMessage>();
1112 return tid;
1113}
1114
1116{
1119}
1120
1122{
1123}
1124
1125TypeId
1127{
1128 return GetTypeId();
1129}
1130
1133{
1134 uint32_t serializedSize = m_epsBearerIds.size() * serializedSizeEbi;
1135 return serializedSize;
1136}
1137
1140{
1142}
1143
1144void
1146{
1147 Buffer::Iterator i = start;
1148
1150 for (auto& epsBearerId : m_epsBearerIds)
1151 {
1152 SerializeEbi(i, epsBearerId);
1153 }
1154}
1155
1158{
1159 Buffer::Iterator i = start;
1161
1162 while (i.GetRemainingSize() > 0)
1163 {
1164 uint8_t epsBearerId;
1165 DeserializeEbi(i, epsBearerId);
1166 m_epsBearerIds.push_back(epsBearerId);
1167 }
1168
1169 return GetSerializedSize();
1170}
1171
1172void
1174{
1175 os << " epsBearerIds [";
1176 for (auto& epsBearerId : m_epsBearerIds)
1177 {
1178 os << (uint16_t)epsBearerId << " ";
1179 }
1180 os << "]";
1181}
1182
1183std::list<uint8_t>
1185{
1186 return m_epsBearerIds;
1187}
1188
1189void
1191{
1192 m_epsBearerIds = epsBearerId;
1193}
1194
1195/////////////////////////////////////////////////////////////////////
1196
1197TypeId
1199{
1200 static TypeId tid = TypeId("ns3::GtpcDeleteBearerResponseMessage")
1201 .SetParent<Header>()
1202 .SetGroupName("Lte")
1203 .AddConstructor<GtpcDeleteBearerResponseMessage>();
1204 return tid;
1205}
1206
1208{
1212}
1213
1215{
1216}
1217
1218TypeId
1220{
1221 return GetTypeId();
1222}
1223
1226{
1228 return serializedSize;
1229}
1230
1233{
1235}
1236
1237void
1239{
1240 Buffer::Iterator i = start;
1241
1244
1245 for (auto& epsBearerId : m_epsBearerIds)
1246 {
1247 SerializeEbi(i, epsBearerId);
1248 }
1249}
1250
1253{
1254 Buffer::Iterator i = start;
1256
1258
1259 while (i.GetRemainingSize() > 0)
1260 {
1261 uint8_t epsBearerId;
1262 DeserializeEbi(i, epsBearerId);
1263 m_epsBearerIds.push_back(epsBearerId);
1264 }
1265
1266 return GetSerializedSize();
1267}
1268
1269void
1271{
1272 os << " cause " << (uint16_t)m_cause << " epsBearerIds [";
1273 for (auto& epsBearerId : m_epsBearerIds)
1274 {
1275 os << (uint16_t)epsBearerId << " ";
1276 }
1277 os << "]";
1278}
1279
1282{
1283 return m_cause;
1284}
1285
1286void
1288{
1289 m_cause = cause;
1290}
1291
1292std::list<uint8_t>
1294{
1295 return m_epsBearerIds;
1296}
1297
1298void
1300{
1301 m_epsBearerIds = epsBearerId;
1302}
1303
1304} // 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.