A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
epc-gtpu-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Jaume Nin <jnin@cttc.cat>
7 */
8
9#ifndef EPS_GTPU_V1_H
10#define EPS_GTPU_V1_H
11
12#include <ns3/header.h>
13#include <ns3/ipv4-header.h>
14#include <ns3/ptr.h>
15
16namespace ns3
17{
18
19class Packet;
20
21/**
22 * \ingroup lte
23 *
24 * Implementation of the GPRS Tunnelling Protocol header according to
25 * GTPv1-U Release 10 as per 3Gpp TS 29.281 document
26 *
27 */
28class GtpuHeader : public Header
29{
30 public:
31 /**
32 * \brief Get the type ID.
33 * \return the object TypeId
34 */
35 static TypeId GetTypeId();
36 GtpuHeader();
37 ~GtpuHeader() override;
38 TypeId GetInstanceTypeId() const override;
39 uint32_t GetSerializedSize() const override;
40 void Serialize(Buffer::Iterator start) const override;
42 void Print(std::ostream& os) const override;
43
44 /**
45 * Get extension header flag function
46 * \returns the extension header flag
47 */
48 bool GetExtensionHeaderFlag() const;
49 /**
50 * Get length function
51 * \returns the length
52 */
53 uint16_t GetLength() const;
54 /**
55 * Get message type function
56 * \returns the message type
57 */
58 uint8_t GetMessageType() const;
59 /**
60 * Get NPDU number function
61 * \returns the NPDU number
62 */
63 uint8_t GetNPduNumber() const;
64 /**
65 * Get type of GTP-U message function
66 * \returns the NPDU number flag
67 */
68 bool GetNPduNumberFlag() const;
69 /**
70 * Get next extension type function
71 * \returns the next extension type
72 */
73 uint8_t GetNextExtensionType() const;
74 /**
75 * Get protocol type function
76 * \returns the protocol type
77 */
78 bool GetProtocolType() const;
79 /**
80 * Get protocol type function
81 * \returns the sequence number
82 */
83 uint16_t GetSequenceNumber() const;
84 /**
85 * Get sequence number flag function
86 * \returns the sequence number flag
87 */
88 bool GetSequenceNumberFlag() const;
89 /**
90 * Get a tunnel endpoint identificator (TEID)
91 * \returns the TEID
92 */
93 uint32_t GetTeid() const;
94 /**
95 * Get version function
96 * \returns the version
97 */
98 uint8_t GetVersion() const;
99 /**
100 * Set extension header flag function
101 * \param extensionHeaderFlag
102 */
103 void SetExtensionHeaderFlag(bool extensionHeaderFlag);
104 /**
105 * Set the length in octets of the payload
106 * \param length the length
107 */
108 void SetLength(uint16_t length);
109 /**
110 * Set message type function
111 * \param messageType the message type
112 */
113 void SetMessageType(uint8_t messageType);
114 /**
115 * Set NPDU number function
116 * \param nPduNumber the NPDU number
117 */
118 void SetNPduNumber(uint8_t nPduNumber);
119 /**
120 * Sets the flag that indicates the presence of a meaningful value of the N-PDU Number field.
121 * \param nPduNumberFlag the NPDU number flag
122 */
123 void SetNPduNumberFlag(bool nPduNumberFlag);
124 /**
125 * Set next extension type function
126 * \param nextExtensionType the next extension type
127 */
128 void SetNextExtensionType(uint8_t nextExtensionType);
129 /**
130 * Set protocol type function
131 * \param protocolType the protocol type
132 */
133 void SetProtocolType(bool protocolType);
134 /**
135 * Set sequence number function
136 * \param sequenceNumber the sequence number
137 */
138 void SetSequenceNumber(uint16_t sequenceNumber);
139 /**
140 * Set sequence number flag function
141 * \param sequenceNumberFlag the sequence number flag
142 */
143 void SetSequenceNumberFlag(bool sequenceNumberFlag);
144 /**
145 * Set TEID function
146 * \param teid the TEID
147 */
148 void SetTeid(uint32_t teid);
149 /**
150 * Set version function
151 * \param version the version
152 */
153 void SetVersion(uint8_t version);
154
155 /**
156 * Equality operator.
157 *
158 * \param b GtpuHeader object to compare
159 * \returns true of equal
160 */
161 bool operator==(const GtpuHeader& b) const;
162
163 private:
164 /**
165 * This field is used to determine the version of the GTPU-U protocol. The version number shall
166 * be set to 1.
167 */
168 uint8_t m_version; // really a 3 uint3_t
169
170 /**
171 * This bit is used as a protocol discriminator between GTP (when PT is '1') and GTP' (when
172 * PT is '0').
173 */
175
176 /**
177 * This flag indicates the presence of a meaningful value of the Next Extension Header
178 * field. When it is set to '0', the Next Extension Header field either is not present
179 * or, if present, shall not be interpreted. When it is set to '1', the Next Extension
180 * Header field is present, and shall be interpreted
181 */
183
184 /**
185 * This flag indicates the presence of a meaningful value of the Sequence Number field.
186 * When it is set to '0', the Sequence Number field either is not present or, if present,
187 * shall not be interpreted. When it is set to '1', the Sequence Number field is present,
188 * and shall be interpreted
189 */
191 /**
192 * This flag indicates the presence of a meaningful value of the N-PDU Number field.
193 * When it is set to '0', the N-PDU Number field either is not present, or, if present,
194 * shall not be interpreted. When it is set to '1', the N-PDU Number field is present,
195 * and shall be interpreted
196 */
198 /**
199 * This field indicates the type of GTP-U message
200 */
202 /**
203 * This field indicates the length in octets of the payload, i.e. the rest of the packet
204 * following the mandatory part of the GTP header (that is the first 8 octets).
205 * The Sequence Number, the N-PDU Number or any Extension headers shall be considered
206 * to be part of the payload, i.e. included in the length count
207 */
208 uint16_t m_length;
209
210 /**
211 * This field unambiguously identifies a tunnel endpoint in the receiving GTP-U
212 * protocol entity. The receiving end side of a GTP tunnel locally assigns the
213 * TEID value the transmitting side has to use.
214 */
216 /**
217 * If Sequence Number field is used for G-PDUs (T-PDUs+headers), an increasing
218 * sequence number for T-PDUs is transmitted via GTP-U tunnels, when transmission
219 * order must be preserved
220 */
222 /**
223 * This field is used at the Inter SGSN Routeing Area Update procedure and some
224 * inter-system handover procedures (e.g. between 2G and 3G radio access networks).
225 * This field is used to co-ordinate the data transmission for acknowledged mode
226 * of communication between the MS and the SGSN
227 */
229 /**
230 * This field defines the type of Extension Header that follows this field in
231 * the GTP-PDU
232 */
234};
235
236} // namespace ns3
237
238#endif /* EPS_GTPU_V1_H */
iterator in a Buffer instance
Definition buffer.h:89
Implementation of the GPRS Tunnelling Protocol header according to GTPv1-U Release 10 as per 3Gpp TS ...
void SetSequenceNumber(uint16_t sequenceNumber)
Set sequence number function.
uint8_t m_nextExtensionType
This field defines the type of Extension Header that follows this field in the GTP-PDU.
void SetExtensionHeaderFlag(bool extensionHeaderFlag)
Set extension header flag function.
uint32_t m_teid
This field unambiguously identifies a tunnel endpoint in the receiving GTP-U protocol entity.
uint32_t Deserialize(Buffer::Iterator start) override
bool m_nPduNumberFlag
This flag indicates the presence of a meaningful value of the N-PDU Number field.
bool operator==(const GtpuHeader &b) const
Equality operator.
bool m_extensionHeaderFlag
This flag indicates the presence of a meaningful value of the Next Extension Header field.
void SetTeid(uint32_t teid)
Set TEID function.
~GtpuHeader() override
bool GetExtensionHeaderFlag() const
Get extension header flag function.
void SetVersion(uint8_t version)
Set version function.
bool m_protocolType
This bit is used as a protocol discriminator between GTP (when PT is '1') and GTP' (when PT is '0').
uint8_t m_messageType
This field indicates the type of GTP-U message.
uint8_t GetVersion() const
Get version function.
uint32_t GetSerializedSize() const override
bool GetSequenceNumberFlag() const
Get sequence number flag function.
bool GetNPduNumberFlag() const
Get type of GTP-U message function.
void SetNPduNumber(uint8_t nPduNumber)
Set NPDU number function.
uint8_t m_nPduNumber
This field is used at the Inter SGSN Routeing Area Update procedure and some inter-system handover pr...
void SetNPduNumberFlag(bool nPduNumberFlag)
Sets the flag that indicates the presence of a meaningful value of the N-PDU Number field.
uint16_t m_sequenceNumber
If Sequence Number field is used for G-PDUs (T-PDUs+headers), an increasing sequence number for T-PDU...
uint8_t GetNPduNumber() const
Get NPDU number function.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint16_t GetLength() const
Get length function.
void Print(std::ostream &os) const override
void SetMessageType(uint8_t messageType)
Set message type function.
uint8_t m_version
This field is used to determine the version of the GTPU-U protocol.
uint16_t m_length
This field indicates the length in octets of the payload, i.e.
static TypeId GetTypeId()
Get the type ID.
void SetSequenceNumberFlag(bool sequenceNumberFlag)
Set sequence number flag function.
uint16_t GetSequenceNumber() const
Get protocol type function.
uint32_t GetTeid() const
Get a tunnel endpoint identificator (TEID)
bool GetProtocolType() const
Get protocol type function.
void SetProtocolType(bool protocolType)
Set protocol type function.
uint8_t GetMessageType() const
Get message type function.
uint8_t GetNextExtensionType() const
Get next extension type function.
bool m_sequenceNumberFlag
This flag indicates the presence of a meaningful value of the Sequence Number field.
void Serialize(Buffer::Iterator start) const override
void SetNextExtensionType(uint8_t nextExtensionType)
Set next extension type function.
void SetLength(uint16_t length)
Set the length in octets of the payload.
Protocol header serialization and deserialization.
Definition header.h:33
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.