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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Manuel Requena <manuel.requena@cttc.es>
7 */
8
9#include "epc-gtpc-header.h"
10
11#include "ns3/log.h"
12
13namespace ns3
14{
15
16NS_LOG_COMPONENT_DEFINE("GtpcHeader");
17
19
20/// GTPv2-C protocol version number
21static const uint8_t VERSION = 2;
22
25{
26 static TypeId tid = TypeId("ns3::GtpcHeader")
28 .SetGroupName("Lte")
29 .AddConstructor<GtpcHeader>();
30 return tid;
31}
32
34 : m_teidFlag(false),
35 m_messageType(0),
36 m_messageLength(4),
37 m_teid(0),
38 m_sequenceNumber(0)
39{
40}
41
45
48{
49 return GetTypeId();
50}
51
54{
55 return m_teidFlag ? 12 : 8;
56}
57
58void
60{
61 NS_FATAL_ERROR("Serialize GTP-C header is forbidden");
62}
63
64void
66{
67 i.WriteU8((VERSION << 5) | (1 << 3));
71 i.WriteU8((m_sequenceNumber & 0x00ff0000) >> 16);
72 i.WriteU8((m_sequenceNumber & 0x0000ff00) >> 8);
73 i.WriteU8(m_sequenceNumber & 0x000000ff);
74 i.WriteU8(0);
75}
76
82
85{
86 uint8_t firstByte = i.ReadU8();
87 uint8_t version = (firstByte >> 5) & 0x07;
88 if (version != 2)
89 {
90 NS_FATAL_ERROR("GTP-C version not supported");
91 return 0;
92 }
93
94 m_teidFlag = ((firstByte >> 3) & 0x01) == 1;
95 if (!m_teidFlag)
96 {
97 NS_FATAL_ERROR("TEID is missing");
98 return 0;
99 }
100
101 m_messageType = i.ReadU8();
103 if (m_teidFlag)
104 {
105 m_teid = i.ReadNtohU32();
106 }
107 m_sequenceNumber = i.ReadU8() << 16 | i.ReadU8() << 8 | i.ReadU8();
108 i.ReadU8();
109
111}
112
113void
114GtpcHeader::Print(std::ostream& os) const
115{
116 os << " messageType " << (uint32_t)m_messageType << " messageLength " << m_messageLength;
117 os << " TEID " << m_teid << " sequenceNumber " << m_sequenceNumber;
118}
119
122{
123 return 0;
124}
125
126uint8_t
128{
129 return m_messageType;
130}
131
132uint16_t
134{
135 return m_messageLength;
136}
137
140{
141 return m_teid;
142}
143
149
150void
151GtpcHeader::SetMessageType(uint8_t messageType)
152{
153 m_messageType = messageType;
154}
155
156void
157GtpcHeader::SetMessageLength(uint16_t messageLength)
158{
159 m_messageLength = messageLength;
160}
161
162void
164{
165 m_teidFlag = true;
166 m_teid = teid;
167 m_messageLength = m_teidFlag ? 8 : 4;
168}
169
170void
172{
173 m_sequenceNumber = sequenceNumber;
174}
175
176void
177GtpcHeader::SetIesLength(uint16_t iesLength)
178{
179 m_messageLength = iesLength;
180 m_messageLength += (m_teidFlag) ? 8 : 4;
181}
182
183void
188
189/////////////////////////////////////////////////////////////////////
190
191void
193{
194 i.WriteU8(1); // IE Type = IMSI
195 i.WriteHtonU16(8); // Length
196 i.WriteU8(0); // Spare + Instance
197 i.WriteHtonU64(imsi);
198}
199
202{
203 uint8_t type = i.ReadU8();
204 NS_ASSERT_MSG(type == 1, "Wrong IMSI IE type = " << (uint16_t)type);
205 uint16_t length = i.ReadNtohU16();
206 NS_ASSERT_MSG(length == 8, "Wrong IMSI IE length");
207 uint8_t instance = i.ReadU8() & 0x0f;
208 NS_ASSERT_MSG(instance == 0, "Wrong IMSI IE instance");
209 imsi = i.ReadNtohU64();
210
211 return serializedSizeImsi;
212}
213
214void
216{
217 i.WriteU8(2); // IE Type = Cause
218 i.WriteHtonU16(2); // Length
219 i.WriteU8(0); // Spare + Instance
220 i.WriteU8(cause); // Cause value
221 i.WriteU8(0); // Spare + CS
222}
223
226{
227 uint8_t type = i.ReadU8();
228 NS_ASSERT_MSG(type == 2, "Wrong Cause IE type = " << (uint16_t)type);
229 uint16_t length = i.ReadNtohU16();
230 NS_ASSERT_MSG(length == 2, "Wrong Cause IE length");
231 uint8_t instance = i.ReadU8() & 0x0f;
232 NS_ASSERT_MSG(instance == 0, "Wrong Cause IE instance");
233 cause = Cause_t(i.ReadU8());
234 i.ReadU8();
235
236 return serializedSizeCause;
237}
238
239void
240GtpcIes::SerializeEbi(Buffer::Iterator& i, uint8_t epsBearerId) const
241{
242 i.WriteU8(73); // IE Type = EPS Bearer ID (EBI)
243 i.WriteHtonU16(1); // Length
244 i.WriteU8(0); // Spare + Instance
245 i.WriteU8(epsBearerId & 0x0f);
246}
247
249GtpcIes::DeserializeEbi(Buffer::Iterator& i, uint8_t& epsBearerId) const
250{
251 uint8_t type = i.ReadU8();
252 NS_ASSERT_MSG(type == 73, "Wrong EBI IE type = " << (uint16_t)type);
253 uint16_t length = i.ReadNtohU16();
254 NS_ASSERT_MSG(length == 1, "Wrong EBI IE length");
255 uint8_t instance = i.ReadU8();
256 NS_ASSERT_MSG(instance == 0, "Wrong EBI IE instance");
257 epsBearerId = i.ReadU8() & 0x0f;
258
259 return serializedSizeEbi;
260}
261
262void
264{
265 i.WriteU8((data >> 32) & 0xff);
266 i.WriteU8((data >> 24) & 0xff);
267 i.WriteU8((data >> 16) & 0xff);
268 i.WriteU8((data >> 8) & 0xff);
269 i.WriteU8((data >> 0) & 0xff);
270}
271
272uint64_t
274{
275 uint64_t retval = 0;
276 retval |= i.ReadU8();
277 retval <<= 8;
278 retval |= i.ReadU8();
279 retval <<= 8;
280 retval |= i.ReadU8();
281 retval <<= 8;
282 retval |= i.ReadU8();
283 retval <<= 8;
284 retval |= i.ReadU8();
285 return retval;
286}
287
288void
290{
291 i.WriteU8(80); // IE Type = Bearer QoS
292 i.WriteHtonU16(22); // Length
293 i.WriteU8(0); // Spare + Instance
294 i.WriteU8(0); // MRE TODO: bearerQos.arp
295 i.WriteU8(bearerQos.qci);
296 WriteHtonU40(i, bearerQos.gbrQosInfo.mbrUl);
297 WriteHtonU40(i, bearerQos.gbrQosInfo.mbrDl);
298 WriteHtonU40(i, bearerQos.gbrQosInfo.gbrUl);
299 WriteHtonU40(i, bearerQos.gbrQosInfo.gbrDl);
300}
301
304{
305 uint8_t type = i.ReadU8();
306 NS_ASSERT_MSG(type == 80, "Wrong Bearer QoS IE type = " << (uint16_t)type);
307 uint16_t length = i.ReadNtohU16();
308 NS_ASSERT_MSG(length == 22, "Wrong Bearer QoS IE length");
309 uint8_t instance = i.ReadU8();
310 NS_ASSERT_MSG(instance == 0, "Wrong Bearer QoS IE instance");
311 i.ReadU8();
312 bearerQos.qci = EpsBearer::Qci(i.ReadU8());
313 bearerQos.gbrQosInfo.mbrUl = ReadNtohU40(i);
314 bearerQos.gbrQosInfo.mbrDl = ReadNtohU40(i);
315 bearerQos.gbrQosInfo.gbrUl = ReadNtohU40(i);
316 bearerQos.gbrQosInfo.gbrDl = ReadNtohU40(i);
318}
319
320void
322 std::list<EpcTft::PacketFilter> packetFilters) const
323{
324 i.WriteU8(84); // IE Type = EPS Bearer Level Fraffic Flow Template (Bearer TFT)
325 i.WriteHtonU16(1 + packetFilters.size() * serializedSizePacketFilter);
326 i.WriteU8(0); // Spare + Instance
327 i.WriteU8(0x20 + (packetFilters.size() & 0x0f)); // Create new TFT + Number of packet filters
328
329 for (auto& pf : packetFilters)
330 {
331 i.WriteU8((pf.direction << 4) & 0x30);
332 i.WriteU8(pf.precedence);
333 i.WriteU8(serializedSizePacketFilter - 3); // Length of Packet filter contents
334
335 i.WriteU8(0x10); // IPv4 remote address type
336 i.WriteHtonU32(pf.remoteAddress.Get());
337 i.WriteHtonU32(pf.remoteMask.Get());
338 i.WriteU8(0x11); // IPv4 local address type
339 i.WriteHtonU32(pf.localAddress.Get());
340 i.WriteHtonU32(pf.localMask.Get());
341 i.WriteU8(0x41); // Local port range type
342 i.WriteHtonU16(pf.localPortStart);
343 i.WriteHtonU16(pf.localPortEnd);
344 i.WriteU8(0x51); // Remote port range type
345 i.WriteHtonU16(pf.remotePortStart);
346 i.WriteHtonU16(pf.remotePortEnd);
347 i.WriteU8(0x70); // Type of service
348 i.WriteU8(pf.typeOfService);
349 i.WriteU8(pf.typeOfServiceMask);
350 }
351}
352
355{
356 uint8_t type = i.ReadU8();
357 NS_ASSERT_MSG(type == 84, "Wrong Bearer TFT IE type = " << (uint16_t)type);
358 i.ReadNtohU16();
359 i.ReadU8();
360 uint8_t numberOfPacketFilters = i.ReadU8() & 0x0f;
361
362 for (uint8_t pf = 0; pf < numberOfPacketFilters; ++pf)
363 {
364 EpcTft::PacketFilter packetFilter;
365 packetFilter.direction = EpcTft::Direction((i.ReadU8() & 0x30) >> 4);
366 packetFilter.precedence = i.ReadU8();
367 i.ReadU8(); // Length of Packet filter contents
368 i.ReadU8();
369 packetFilter.remoteAddress = Ipv4Address(i.ReadNtohU32());
370 packetFilter.remoteMask = Ipv4Mask(i.ReadNtohU32());
371 i.ReadU8();
372 packetFilter.localAddress = Ipv4Address(i.ReadNtohU32());
373 packetFilter.localMask = Ipv4Mask(i.ReadNtohU32());
374 i.ReadU8();
375 packetFilter.localPortStart = i.ReadNtohU16();
376 packetFilter.localPortEnd = i.ReadNtohU16();
377 i.ReadU8();
378 packetFilter.remotePortStart = i.ReadNtohU16();
379 packetFilter.remotePortEnd = i.ReadNtohU16();
380 i.ReadU8();
381 packetFilter.typeOfService = i.ReadU8();
382 packetFilter.typeOfServiceMask = i.ReadU8();
383 epcTft->Add(packetFilter);
384 }
385
386 return GetSerializedSizeBearerTft(epcTft->GetPacketFilters());
387}
388
390GtpcIes::GetSerializedSizeBearerTft(std::list<EpcTft::PacketFilter> packetFilters) const
391{
392 return (5 + packetFilters.size() * serializedSizePacketFilter);
393}
394
395void
397{
398 i.WriteU8(86); // IE Type = ULI (ECGI)
399 i.WriteHtonU16(8); // Length
400 i.WriteU8(0); // Spare + Instance
401 i.WriteU8(0x10); // ECGI flag
402 i.WriteU8(0); // Dummy MCC and MNC
403 i.WriteU8(0); // Dummy MCC and MNC
404 i.WriteU8(0); // Dummy MCC and MNC
405 i.WriteHtonU32(uliEcgi);
406}
407
410{
411 uint8_t type = i.ReadU8();
412 NS_ASSERT_MSG(type == 86, "Wrong ULI ECGI IE type = " << (uint16_t)type);
413 uint16_t length = i.ReadNtohU16();
414 NS_ASSERT_MSG(length == 8, "Wrong ULI ECGI IE length");
415 uint8_t instance = i.ReadU8() & 0x0f;
416 NS_ASSERT_MSG(instance == 0, "Wrong ULI ECGI IE instance");
417 i.Next(4);
418 uliEcgi = i.ReadNtohU32() & 0x0fffffff;
419
421}
422
423void
425{
426 i.WriteU8(87); // IE Type = Fully Qualified TEID (F-TEID)
427 i.WriteHtonU16(9); // Length
428 i.WriteU8(0); // Spare + Instance
429 i.WriteU8(0x80 | ((uint8_t)fteid.interfaceType & 0x1f)); // IP version flag + Iface type
430 i.WriteHtonU32(fteid.teid); // TEID
431 i.WriteHtonU32(fteid.addr.Get()); // IPv4 address
432}
433
436{
437 uint8_t type = i.ReadU8();
438 NS_ASSERT_MSG(type == 87, "Wrong FTEID IE type = " << (uint16_t)type);
439 uint16_t length = i.ReadNtohU16();
440 NS_ASSERT_MSG(length == 9, "Wrong FTEID IE length");
441 uint8_t instance = i.ReadU8() & 0x0f;
442 NS_ASSERT_MSG(instance == 0, "Wrong FTEID IE instance");
443 uint8_t flags = i.ReadU8(); // IP version flag + Iface type
444 fteid.interfaceType = GtpcHeader::InterfaceType_t(flags & 0x1f);
445 fteid.teid = i.ReadNtohU32(); // TEID
446 fteid.addr.Set(i.ReadNtohU32()); // IPv4 address
447
448 return serializedSizeFteid;
449}
450
451void
453{
454 i.WriteU8(93); // IE Type = Bearer Context
455 i.WriteU16(length);
456 i.WriteU8(0); // Spare + Instance
457}
458
461{
462 uint8_t type = i.ReadU8();
463 NS_ASSERT_MSG(type == 93, "Wrong Bearer Context IE type = " << (uint16_t)type);
464 length = i.ReadNtohU16();
465 uint8_t instance = i.ReadU8() & 0x0f;
466 NS_ASSERT_MSG(instance == 0, "Wrong Bearer Context IE instance");
467
469}
470
471/////////////////////////////////////////////////////////////////////
472
473TypeId
475{
476 static TypeId tid = TypeId("ns3::GtpcCreateSessionRequestMessage")
477 .SetParent<Header>()
478 .SetGroupName("Lte")
479 .AddConstructor<GtpcCreateSessionRequestMessage>();
480 return tid;
481}
482
491
495
496TypeId
501
504{
506 for (auto& bc : m_bearerContextsToBeCreated)
507 {
509 GetSerializedSizeBearerTft(bc.tft->GetPacketFilters()) +
511 }
512
513 return serializedSize;
514}
515
521
522void
524{
525 Buffer::Iterator i = start;
526
531
532 for (auto& bc : m_bearerContextsToBeCreated)
533 {
534 std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters();
535
539
540 SerializeEbi(i, bc.epsBearerId);
541 SerializeBearerTft(i, packetFilters);
542 SerializeFteid(i, bc.sgwS5uFteid);
543 SerializeBearerQos(i, bc.bearerLevelQos);
544 }
545}
546
549{
550 Buffer::Iterator i = start;
552
556
558 while (i.GetRemainingSize() > 0)
559 {
560 uint16_t length;
562
563 BearerContextToBeCreated bearerContext;
564 DeserializeEbi(i, bearerContext.epsBearerId);
565
566 Ptr<EpcTft> epcTft = Create<EpcTft>();
567 DeserializeBearerTft(i, epcTft);
568 bearerContext.tft = epcTft;
569
570 DeserializeFteid(i, bearerContext.sgwS5uFteid);
571 DeserializeBearerQos(i, bearerContext.bearerLevelQos);
572
573 m_bearerContextsToBeCreated.push_back(bearerContext);
574 }
575
576 return GetSerializedSize();
577}
578
579void
581{
582 os << " imsi " << m_imsi << " uliEcgi " << m_uliEcgi;
583}
584
585uint64_t
590
591void
593{
594 m_imsi = imsi;
595}
596
602
603void
608
614
615void
620
621std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated>
626
627void
629 std::list<GtpcCreateSessionRequestMessage::BearerContextToBeCreated> bearerContexts)
630{
631 m_bearerContextsToBeCreated = bearerContexts;
632}
633
634/////////////////////////////////////////////////////////////////////
635
636TypeId
638{
639 static TypeId tid = TypeId("ns3::GtpcCreateSessionResponseMessage")
640 .SetParent<Header>()
641 .SetGroupName("Lte")
642 .AddConstructor<GtpcCreateSessionResponseMessage>();
643 return tid;
644}
645
653
657
658TypeId
663
666{
668 for (auto& bc : m_bearerContextsCreated)
669 {
671 GetSerializedSizeBearerTft(bc.tft->GetPacketFilters()) +
673 }
674
675 return serializedSize;
676}
677
683
684void
686{
687 Buffer::Iterator i = start;
688
692
693 for (auto& bc : m_bearerContextsCreated)
694 {
695 std::list<EpcTft::PacketFilter> packetFilters = bc.tft->GetPacketFilters();
696
700
701 SerializeEbi(i, bc.epsBearerId);
702 SerializeBearerTft(i, packetFilters);
703 SerializeFteid(i, bc.fteid);
704 SerializeBearerQos(i, bc.bearerLevelQos);
705 }
706}
707
710{
711 Buffer::Iterator i = start;
713
716
718 while (i.GetRemainingSize() > 0)
719 {
720 BearerContextCreated bearerContext;
721 uint16_t length;
722
724 DeserializeEbi(i, bearerContext.epsBearerId);
725
726 Ptr<EpcTft> epcTft = Create<EpcTft>();
727 DeserializeBearerTft(i, epcTft);
728 bearerContext.tft = epcTft;
729
730 DeserializeFteid(i, bearerContext.fteid);
731 DeserializeBearerQos(i, bearerContext.bearerLevelQos);
732
733 m_bearerContextsCreated.push_back(bearerContext);
734 }
735
736 return GetSerializedSize();
737}
738
739void
741{
742 os << " cause " << m_cause << " FTEID " << m_senderCpFteid.addr << "," << m_senderCpFteid.teid;
743}
744
750
751void
756
762
763void
768
769std::list<GtpcCreateSessionResponseMessage::BearerContextCreated>
774
775void
777 std::list<GtpcCreateSessionResponseMessage::BearerContextCreated> bearerContexts)
778{
779 m_bearerContextsCreated = bearerContexts;
780}
781
782/////////////////////////////////////////////////////////////////////
783
784TypeId
786{
787 static TypeId tid = TypeId("ns3::GtpcModifyBearerRequestMessage")
788 .SetParent<Header>()
789 .SetGroupName("Lte")
790 .AddConstructor<GtpcModifyBearerRequestMessage>();
791 return tid;
792}
793
801
805
806TypeId
811
821
827
828void
830{
831 Buffer::Iterator i = start;
832
836
837 for (auto& bc : m_bearerContextsToBeModified)
838 {
840
841 SerializeEbi(i, bc.epsBearerId);
842 SerializeFteid(i, bc.fteid);
843 }
844}
845
848{
849 Buffer::Iterator i = start;
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
882
883void
885{
886 m_imsi = imsi;
887}
888
894
895void
900
901std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified>
906
907void
909 std::list<GtpcModifyBearerRequestMessage::BearerContextToBeModified> bearerContexts)
910{
911 m_bearerContextsToBeModified = bearerContexts;
912}
913
914/////////////////////////////////////////////////////////////////////
915
916TypeId
918{
919 static TypeId tid = TypeId("ns3::GtpcModifyBearerResponseMessage")
920 .SetParent<Header>()
921 .SetGroupName("Lte")
922 .AddConstructor<GtpcModifyBearerResponseMessage>();
923 return tid;
924}
925
932
936
937TypeId
942
948
954
955void
963
974
975void
977{
978 os << " cause " << (uint16_t)m_cause;
979}
980
986
987void
992
993/////////////////////////////////////////////////////////////////////
994
995TypeId
997{
998 static TypeId tid = TypeId("ns3::GtpcDeleteBearerCommandMessage")
999 .SetParent<Header>()
1000 .SetGroupName("Lte")
1001 .AddConstructor<GtpcDeleteBearerCommandMessage>();
1002 return tid;
1003}
1004
1010
1014
1015TypeId
1020
1023{
1024 uint32_t serializedSize =
1026 return serializedSize;
1027}
1028
1034
1035void
1037{
1038 Buffer::Iterator i = start;
1039
1041 for (auto& bearerContext : m_bearerContexts)
1042 {
1044
1045 SerializeEbi(i, bearerContext.m_epsBearerId);
1046 }
1047}
1048
1051{
1052 Buffer::Iterator i = start;
1054
1055 while (i.GetRemainingSize() > 0)
1056 {
1057 uint16_t length;
1059
1060 BearerContext bearerContext;
1061 DeserializeEbi(i, bearerContext.m_epsBearerId);
1062 m_bearerContexts.push_back(bearerContext);
1063 }
1064
1065 return GetSerializedSize();
1066}
1067
1068void
1070{
1071 os << " bearerContexts [";
1072 for (auto& bearerContext : m_bearerContexts)
1073 {
1074 os << (uint16_t)bearerContext.m_epsBearerId << " ";
1075 }
1076 os << "]";
1077}
1078
1079std::list<GtpcDeleteBearerCommandMessage::BearerContext>
1084
1085void
1087 std::list<GtpcDeleteBearerCommandMessage::BearerContext> bearerContexts)
1088{
1089 m_bearerContexts = bearerContexts;
1090}
1091
1092/////////////////////////////////////////////////////////////////////
1093
1094TypeId
1096{
1097 static TypeId tid = TypeId("ns3::GtpcDeleteBearerRequestMessage")
1098 .SetParent<Header>()
1099 .SetGroupName("Lte")
1100 .AddConstructor<GtpcDeleteBearerRequestMessage>();
1101 return tid;
1102}
1103
1109
1113
1114TypeId
1119
1122{
1123 uint32_t serializedSize = m_epsBearerIds.size() * serializedSizeEbi;
1124 return serializedSize;
1125}
1126
1132
1133void
1135{
1136 Buffer::Iterator i = start;
1137
1139 for (auto& epsBearerId : m_epsBearerIds)
1140 {
1141 SerializeEbi(i, epsBearerId);
1142 }
1143}
1144
1147{
1148 Buffer::Iterator i = start;
1150
1151 while (i.GetRemainingSize() > 0)
1152 {
1153 uint8_t epsBearerId;
1154 DeserializeEbi(i, epsBearerId);
1155 m_epsBearerIds.push_back(epsBearerId);
1156 }
1157
1158 return GetSerializedSize();
1159}
1160
1161void
1163{
1164 os << " epsBearerIds [";
1165 for (auto& epsBearerId : m_epsBearerIds)
1166 {
1167 os << (uint16_t)epsBearerId << " ";
1168 }
1169 os << "]";
1170}
1171
1172std::list<uint8_t>
1177
1178void
1180{
1181 m_epsBearerIds = epsBearerId;
1182}
1183
1184/////////////////////////////////////////////////////////////////////
1185
1186TypeId
1188{
1189 static TypeId tid = TypeId("ns3::GtpcDeleteBearerResponseMessage")
1190 .SetParent<Header>()
1191 .SetGroupName("Lte")
1192 .AddConstructor<GtpcDeleteBearerResponseMessage>();
1193 return tid;
1194}
1195
1202
1206
1207TypeId
1212
1215{
1217 return serializedSize;
1218}
1219
1225
1226void
1228{
1229 Buffer::Iterator i = start;
1230
1233
1234 for (auto& epsBearerId : m_epsBearerIds)
1235 {
1236 SerializeEbi(i, epsBearerId);
1237 }
1238}
1239
1242{
1243 Buffer::Iterator i = start;
1245
1247
1248 while (i.GetRemainingSize() > 0)
1249 {
1250 uint8_t epsBearerId;
1251 DeserializeEbi(i, epsBearerId);
1252 m_epsBearerIds.push_back(epsBearerId);
1253 }
1254
1255 return GetSerializedSize();
1256}
1257
1258void
1260{
1261 os << " cause " << (uint16_t)m_cause << " epsBearerIds [";
1262 for (auto& epsBearerId : m_epsBearerIds)
1263 {
1264 os << (uint16_t)epsBearerId << " ";
1265 }
1266 os << "]";
1267}
1268
1274
1275void
1280
1281std::list<uint8_t>
1286
1287void
1289{
1290 m_epsBearerIds = epsBearerId;
1291}
1292
1293} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
uint32_t GetRemainingSize() const
Definition buffer.cc:1162
void WriteHtonU64(uint64_t data)
Definition buffer.cc:923
uint64_t ReadNtohU64()
Definition buffer.cc:1030
void WriteU8(uint8_t data)
Definition buffer.h:870
void WriteU16(uint16_t data)
Definition buffer.cc:848
void WriteHtonU16(uint16_t data)
Definition buffer.h:904
uint32_t ReadNtohU32()
Definition buffer.h:967
void WriteHtonU32(uint32_t data)
Definition buffer.h:922
uint16_t ReadNtohU16()
Definition buffer.h:943
void Next()
go forward by one byte
Definition buffer.h:842
Direction
Indicates the direction of the traffic that is to be classified.
Definition epc-tft.h:40
This class contains the specification of EPS Bearers.
Definition eps-bearer.h:80
Qci qci
Qos class indicator.
Definition eps-bearer.h:140
GbrQosInformation gbrQosInfo
GBR QOS information.
Definition eps-bearer.h:142
Qci
QoS Class Indicator.
Definition eps-bearer.h:95
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:33
Ipv4 addresses are stored in host order in this class.
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
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#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:75
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
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:60
Ipv4Address localAddress
IPv4 address of the UE.
Definition epc-tft.h:110
uint16_t localPortEnd
end of the port number range of the UE
Definition epc-tft.h:121
Ipv4Mask localMask
IPv4 address mask of the UE.
Definition epc-tft.h:111
uint16_t remotePortEnd
end of the port number range of the remote host
Definition epc-tft.h:119
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:103
Direction direction
Whether the filter needs to be applied to uplink / downlink only, or in both cases.
Definition epc-tft.h:106
Ipv4Mask remoteMask
IPv4 address mask of the remote host.
Definition epc-tft.h:109
uint16_t remotePortStart
start of the port number range of the remote host
Definition epc-tft.h:118
uint8_t typeOfService
type of service field
Definition epc-tft.h:123
Ipv4Address remoteAddress
IPv4 address of the remote host.
Definition epc-tft.h:108
uint8_t typeOfServiceMask
type of service field mask
Definition epc-tft.h:124
uint16_t localPortStart
start of the port number range of the UE
Definition epc-tft.h:120
uint64_t gbrDl
Guaranteed Bit Rate (bit/s) in downlink.
Definition eps-bearer.h:31
uint64_t gbrUl
Guaranteed Bit Rate (bit/s) in uplink.
Definition eps-bearer.h:32
uint64_t mbrDl
Maximum Bit Rate (bit/s) in downlink.
Definition eps-bearer.h:33
uint64_t mbrUl
Maximum Bit Rate (bit/s) in uplink.
Definition eps-bearer.h:34
Ptr< EpcTft > tft
Bearer traffic flow template.
Ipv4Address addr
IPv4 address.
InterfaceType_t interfaceType
Interface type.