A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::GtpuHeader Class Reference

Implementation of the GPRS Tunnelling Protocol header according to GTPv1-U Release 10 as per 3Gpp TS 29.281 document. More...

#include "epc-gtpu-header.h"

+ Inheritance diagram for ns3::GtpuHeader:
+ Collaboration diagram for ns3::GtpuHeader:

Public Member Functions

 GtpuHeader ()
 
 ~GtpuHeader () override
 
uint32_t Deserialize (Buffer::Iterator start) override
 
bool GetExtensionHeaderFlag () const
 Get extension header flag function.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
uint16_t GetLength () const
 Get length function.
 
uint8_t GetMessageType () const
 Get message type function.
 
uint8_t GetNextExtensionType () const
 Get next extension type function.
 
uint8_t GetNPduNumber () const
 Get NPDU number function.
 
bool GetNPduNumberFlag () const
 Get type of GTP-U message function.
 
bool GetProtocolType () const
 Get protocol type function.
 
uint16_t GetSequenceNumber () const
 Get protocol type function.
 
bool GetSequenceNumberFlag () const
 Get sequence number flag function.
 
uint32_t GetSerializedSize () const override
 
uint32_t GetTeid () const
 Get a tunnel endpoint identificator (TEID)
 
uint8_t GetVersion () const
 Get version function.
 
bool operator== (const GtpuHeader &b) const
 Equality operator.
 
void Print (std::ostream &os) const override
 
void Serialize (Buffer::Iterator start) const override
 
void SetExtensionHeaderFlag (bool extensionHeaderFlag)
 Set extension header flag function.
 
void SetLength (uint16_t length)
 Set the length in octets of the payload.
 
void SetMessageType (uint8_t messageType)
 Set message type function.
 
void SetNextExtensionType (uint8_t nextExtensionType)
 Set next extension type function.
 
void SetNPduNumber (uint8_t nPduNumber)
 Set NPDU number function.
 
void SetNPduNumberFlag (bool nPduNumberFlag)
 Sets the flag that indicates the presence of a meaningful value of the N-PDU Number field.
 
void SetProtocolType (bool protocolType)
 Set protocol type function.
 
void SetSequenceNumber (uint16_t sequenceNumber)
 Set sequence number function.
 
void SetSequenceNumberFlag (bool sequenceNumberFlag)
 Set sequence number flag function.
 
void SetTeid (uint32_t teid)
 Set TEID function.
 
void SetVersion (uint8_t version)
 Set version function.
 
- Public Member Functions inherited from ns3::Header
 ~Header () override
 
virtual uint32_t Deserialize (Buffer::Iterator start, Buffer::Iterator end)
 Deserialize the object from a buffer iterator.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Header
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Chunk
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Private Attributes

bool m_extensionHeaderFlag
 This flag indicates the presence of a meaningful value of the Next Extension Header field.
 
uint16_t m_length
 This field indicates the length in octets of the payload, i.e.
 
uint8_t m_messageType
 This field indicates the type of GTP-U message.
 
uint8_t m_nextExtensionType
 This field defines the type of Extension Header that follows this field in the GTP-PDU.
 
uint8_t m_nPduNumber
 This field is used at the Inter SGSN Routeing Area Update procedure and some inter-system handover procedures (e.g.
 
bool m_nPduNumberFlag
 This flag indicates the presence of a meaningful value of the N-PDU Number field.
 
bool m_protocolType
 This bit is used as a protocol discriminator between GTP (when PT is '1') and GTP' (when PT is '0').
 
uint16_t m_sequenceNumber
 If Sequence Number field is used for G-PDUs (T-PDUs+headers), an increasing sequence number for T-PDUs is transmitted via GTP-U tunnels, when transmission order must be preserved.
 
bool m_sequenceNumberFlag
 This flag indicates the presence of a meaningful value of the Sequence Number field.
 
uint32_t m_teid
 This field unambiguously identifies a tunnel endpoint in the receiving GTP-U protocol entity.
 
uint8_t m_version
 This field is used to determine the version of the GTPU-U protocol.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

Implementation of the GPRS Tunnelling Protocol header according to GTPv1-U Release 10 as per 3Gpp TS 29.281 document.

Definition at line 28 of file epc-gtpu-header.h.

Constructor & Destructor Documentation

◆ GtpuHeader()

ns3::GtpuHeader::GtpuHeader ( )

Definition at line 35 of file epc-gtpu-header.cc.

◆ ~GtpuHeader()

ns3::GtpuHeader::~GtpuHeader ( )
override

Definition at line 50 of file epc-gtpu-header.cc.

Member Function Documentation

◆ Deserialize()

uint32_t ns3::GtpuHeader::Deserialize ( Buffer::Iterator start)
overridevirtual
Parameters
startan iterator which points to where the header should read from.
Returns
the number of bytes read.

This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet. The data read is expected to match bit-for-bit the representation of this header in real networks.

Note that data is not actually removed from the buffer to which the iterator points. Both Packet::RemoveHeader() and Packet::PeekHeader() call Deserialize(), but only the RemoveHeader() has additional statements to remove the header bytes from the underlying buffer and associated metadata.

Implements ns3::Header.

Definition at line 82 of file epc-gtpu-header.cc.

References GetSerializedSize(), m_extensionHeaderFlag, m_length, m_messageType, m_nextExtensionType, m_nPduNumber, m_nPduNumberFlag, m_protocolType, m_sequenceNumber, m_sequenceNumberFlag, m_teid, m_version, ns3::Buffer::Iterator::ReadNtohU16(), ns3::Buffer::Iterator::ReadNtohU32(), and ns3::Buffer::Iterator::ReadU8().

+ Here is the call graph for this function:

◆ GetExtensionHeaderFlag()

bool ns3::GtpuHeader::GetExtensionHeaderFlag ( ) const

Get extension header flag function.

Returns
the extension header flag

Definition at line 127 of file epc-gtpu-header.cc.

References m_extensionHeaderFlag.

◆ GetInstanceTypeId()

TypeId ns3::GtpuHeader::GetInstanceTypeId ( ) const
overridevirtual

Get the most derived TypeId for this Object.

This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.

Returns
The TypeId associated to the most-derived type of this instance.

Implements ns3::ObjectBase.

Definition at line 55 of file epc-gtpu-header.cc.

References GetTypeId().

+ Here is the call graph for this function:

◆ GetLength()

uint16_t ns3::GtpuHeader::GetLength ( ) const

Get length function.

Returns
the length

Definition at line 133 of file epc-gtpu-header.cc.

References m_length.

◆ GetMessageType()

uint8_t ns3::GtpuHeader::GetMessageType ( ) const

Get message type function.

Returns
the message type

Definition at line 139 of file epc-gtpu-header.cc.

References m_messageType.

◆ GetNextExtensionType()

uint8_t ns3::GtpuHeader::GetNextExtensionType ( ) const

Get next extension type function.

Returns
the next extension type

Definition at line 157 of file epc-gtpu-header.cc.

References m_nextExtensionType.

◆ GetNPduNumber()

uint8_t ns3::GtpuHeader::GetNPduNumber ( ) const

Get NPDU number function.

Returns
the NPDU number

Definition at line 145 of file epc-gtpu-header.cc.

References m_nPduNumber.

◆ GetNPduNumberFlag()

bool ns3::GtpuHeader::GetNPduNumberFlag ( ) const

Get type of GTP-U message function.

Returns
the NPDU number flag

Definition at line 151 of file epc-gtpu-header.cc.

References m_nPduNumberFlag.

◆ GetProtocolType()

bool ns3::GtpuHeader::GetProtocolType ( ) const

Get protocol type function.

Returns
the protocol type

Definition at line 163 of file epc-gtpu-header.cc.

References m_protocolType.

◆ GetSequenceNumber()

uint16_t ns3::GtpuHeader::GetSequenceNumber ( ) const

Get protocol type function.

Returns
the sequence number

Definition at line 169 of file epc-gtpu-header.cc.

References m_sequenceNumber.

◆ GetSequenceNumberFlag()

bool ns3::GtpuHeader::GetSequenceNumberFlag ( ) const

Get sequence number flag function.

Returns
the sequence number flag

Definition at line 175 of file epc-gtpu-header.cc.

References m_sequenceNumberFlag.

◆ GetSerializedSize()

uint32_t ns3::GtpuHeader::GetSerializedSize ( ) const
overridevirtual
Returns
the expected size of the header.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.

Implements ns3::Header.

Definition at line 61 of file epc-gtpu-header.cc.

Referenced by Deserialize(), ns3::EpcX2::DoSendUeData(), ns3::EpcEnbApplication::SendToS1uSocket(), ns3::EpcSgwApplication::SendToS1uSocket(), ns3::EpcPgwApplication::SendToS5uSocket(), and ns3::EpcSgwApplication::SendToS5uSocket().

+ Here is the caller graph for this function:

◆ GetTeid()

uint32_t ns3::GtpuHeader::GetTeid ( ) const

Get a tunnel endpoint identificator (TEID)

Returns
the TEID

Definition at line 181 of file epc-gtpu-header.cc.

References m_teid.

Referenced by ns3::EpcEnbApplication::RecvFromS1uSocket(), ns3::EpcSgwApplication::RecvFromS1uSocket(), ns3::EpcPgwApplication::RecvFromS5uSocket(), ns3::EpcSgwApplication::RecvFromS5uSocket(), and ns3::EpcX2::RecvFromX2uSocket().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::GtpuHeader::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 26 of file epc-gtpu-header.cc.

References ns3::TypeId::SetParent().

Referenced by GetInstanceTypeId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetVersion()

uint8_t ns3::GtpuHeader::GetVersion ( ) const

Get version function.

Returns
the version

Definition at line 187 of file epc-gtpu-header.cc.

References m_version.

◆ operator==()

bool ns3::GtpuHeader::operator== ( const GtpuHeader & b) const

Equality operator.

Parameters
bGtpuHeader object to compare
Returns
true of equal

Definition at line 260 of file epc-gtpu-header.cc.

References m_extensionHeaderFlag, m_length, m_messageType, m_nextExtensionType, m_nPduNumber, m_nPduNumberFlag, m_protocolType, m_sequenceNumber, m_sequenceNumberFlag, m_teid, and m_version.

◆ Print()

void ns3::GtpuHeader::Print ( std::ostream & os) const
overridevirtual
Parameters
osoutput stream This method is used by Packet::Print to print the content of a header as ascii data to a c++ output stream. Although the header is free to format its output as it wishes, it is recommended to follow a few rules to integrate with the packet pretty printer: start with flags, small field values located between a pair of parens. Values should be separated by whitespace. Follow the parens with the important fields, separated by whitespace. i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5

Implements ns3::Header.

Definition at line 101 of file epc-gtpu-header.cc.

References m_extensionHeaderFlag, m_length, m_messageType, m_nextExtensionType, m_nPduNumber, m_nPduNumberFlag, m_protocolType, m_sequenceNumber, m_sequenceNumberFlag, m_teid, and m_version.

◆ Serialize()

void ns3::GtpuHeader::Serialize ( Buffer::Iterator start) const
overridevirtual
Parameters
startan iterator which points to where the header should be written.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. The data written is expected to match bit-for-bit the representation of this header in a real network.

Implements ns3::Header.

Definition at line 67 of file epc-gtpu-header.cc.

References m_extensionHeaderFlag, m_length, m_messageType, m_nextExtensionType, m_nPduNumber, m_nPduNumberFlag, m_protocolType, m_sequenceNumber, m_sequenceNumberFlag, m_teid, m_version, ns3::Buffer::Iterator::WriteHtonU16(), ns3::Buffer::Iterator::WriteHtonU32(), and ns3::Buffer::Iterator::WriteU8().

+ Here is the call graph for this function:

◆ SetExtensionHeaderFlag()

void ns3::GtpuHeader::SetExtensionHeaderFlag ( bool extensionHeaderFlag)

Set extension header flag function.

Parameters
extensionHeaderFlag

Definition at line 193 of file epc-gtpu-header.cc.

References m_extensionHeaderFlag.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetLength()

void ns3::GtpuHeader::SetLength ( uint16_t length)

Set the length in octets of the payload.

Parameters
lengththe length

Definition at line 199 of file epc-gtpu-header.cc.

References m_length.

Referenced by EpsGtpuHeaderTestCase::DoRun(), ns3::EpcX2::DoSendUeData(), ns3::EpcEnbApplication::SendToS1uSocket(), ns3::EpcSgwApplication::SendToS1uSocket(), ns3::EpcPgwApplication::SendToS5uSocket(), and ns3::EpcSgwApplication::SendToS5uSocket().

+ Here is the caller graph for this function:

◆ SetMessageType()

void ns3::GtpuHeader::SetMessageType ( uint8_t messageType)

Set message type function.

Parameters
messageTypethe message type

Definition at line 205 of file epc-gtpu-header.cc.

References m_messageType.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetNextExtensionType()

void ns3::GtpuHeader::SetNextExtensionType ( uint8_t nextExtensionType)

Set next extension type function.

Parameters
nextExtensionTypethe next extension type

Definition at line 223 of file epc-gtpu-header.cc.

References m_nextExtensionType.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetNPduNumber()

void ns3::GtpuHeader::SetNPduNumber ( uint8_t nPduNumber)

Set NPDU number function.

Parameters
nPduNumberthe NPDU number

Definition at line 211 of file epc-gtpu-header.cc.

References m_nPduNumber.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetNPduNumberFlag()

void ns3::GtpuHeader::SetNPduNumberFlag ( bool nPduNumberFlag)

Sets the flag that indicates the presence of a meaningful value of the N-PDU Number field.

Parameters
nPduNumberFlagthe NPDU number flag

Definition at line 217 of file epc-gtpu-header.cc.

References m_nPduNumberFlag.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetProtocolType()

void ns3::GtpuHeader::SetProtocolType ( bool protocolType)

Set protocol type function.

Parameters
protocolTypethe protocol type

Definition at line 229 of file epc-gtpu-header.cc.

References m_protocolType.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetSequenceNumber()

void ns3::GtpuHeader::SetSequenceNumber ( uint16_t sequenceNumber)

Set sequence number function.

Parameters
sequenceNumberthe sequence number

Definition at line 235 of file epc-gtpu-header.cc.

References m_sequenceNumber.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetSequenceNumberFlag()

void ns3::GtpuHeader::SetSequenceNumberFlag ( bool sequenceNumberFlag)

Set sequence number flag function.

Parameters
sequenceNumberFlagthe sequence number flag

Definition at line 241 of file epc-gtpu-header.cc.

References m_sequenceNumberFlag.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetTeid()

void ns3::GtpuHeader::SetTeid ( uint32_t teid)

Set TEID function.

Parameters
teidthe TEID

Definition at line 247 of file epc-gtpu-header.cc.

References m_teid.

Referenced by EpsGtpuHeaderTestCase::DoRun(), ns3::EpcX2::DoSendUeData(), ns3::EpcEnbApplication::SendToS1uSocket(), ns3::EpcSgwApplication::SendToS1uSocket(), ns3::EpcPgwApplication::SendToS5uSocket(), and ns3::EpcSgwApplication::SendToS5uSocket().

+ Here is the caller graph for this function:

◆ SetVersion()

void ns3::GtpuHeader::SetVersion ( uint8_t version)

Set version function.

Parameters
versionthe version

Definition at line 253 of file epc-gtpu-header.cc.

References m_version.

Referenced by EpsGtpuHeaderTestCase::DoRun().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_extensionHeaderFlag

bool ns3::GtpuHeader::m_extensionHeaderFlag
private

This flag indicates the presence of a meaningful value of the Next Extension Header field.

When it is set to '0', the Next Extension Header field either is not present or, if present, shall not be interpreted. When it is set to '1', the Next Extension Header field is present, and shall be interpreted

Definition at line 182 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetExtensionHeaderFlag(), operator==(), Print(), Serialize(), and SetExtensionHeaderFlag().

◆ m_length

uint16_t ns3::GtpuHeader::m_length
private

This field indicates the length in octets of the payload, i.e.

the rest of the packet following the mandatory part of the GTP header (that is the first 8 octets). The Sequence Number, the N-PDU Number or any Extension headers shall be considered to be part of the payload, i.e. included in the length count

Definition at line 208 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetLength(), operator==(), Print(), Serialize(), and SetLength().

◆ m_messageType

uint8_t ns3::GtpuHeader::m_messageType
private

This field indicates the type of GTP-U message.

Definition at line 201 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetMessageType(), operator==(), Print(), Serialize(), and SetMessageType().

◆ m_nextExtensionType

uint8_t ns3::GtpuHeader::m_nextExtensionType
private

This field defines the type of Extension Header that follows this field in the GTP-PDU.

Definition at line 233 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetNextExtensionType(), operator==(), Print(), Serialize(), and SetNextExtensionType().

◆ m_nPduNumber

uint8_t ns3::GtpuHeader::m_nPduNumber
private

This field is used at the Inter SGSN Routeing Area Update procedure and some inter-system handover procedures (e.g.

between 2G and 3G radio access networks). This field is used to co-ordinate the data transmission for acknowledged mode of communication between the MS and the SGSN

Definition at line 228 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetNPduNumber(), operator==(), Print(), Serialize(), and SetNPduNumber().

◆ m_nPduNumberFlag

bool ns3::GtpuHeader::m_nPduNumberFlag
private

This flag indicates the presence of a meaningful value of the N-PDU Number field.

When it is set to '0', the N-PDU Number field either is not present, or, if present, shall not be interpreted. When it is set to '1', the N-PDU Number field is present, and shall be interpreted

Definition at line 197 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetNPduNumberFlag(), operator==(), Print(), Serialize(), and SetNPduNumberFlag().

◆ m_protocolType

bool ns3::GtpuHeader::m_protocolType
private

This bit is used as a protocol discriminator between GTP (when PT is '1') and GTP' (when PT is '0').

Definition at line 174 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetProtocolType(), operator==(), Print(), Serialize(), and SetProtocolType().

◆ m_sequenceNumber

uint16_t ns3::GtpuHeader::m_sequenceNumber
private

If Sequence Number field is used for G-PDUs (T-PDUs+headers), an increasing sequence number for T-PDUs is transmitted via GTP-U tunnels, when transmission order must be preserved.

Definition at line 221 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetSequenceNumber(), operator==(), Print(), Serialize(), and SetSequenceNumber().

◆ m_sequenceNumberFlag

bool ns3::GtpuHeader::m_sequenceNumberFlag
private

This flag indicates the presence of a meaningful value of the Sequence Number field.

When it is set to '0', the Sequence Number field either is not present or, if present, shall not be interpreted. When it is set to '1', the Sequence Number field is present, and shall be interpreted

Definition at line 190 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetSequenceNumberFlag(), operator==(), Print(), Serialize(), and SetSequenceNumberFlag().

◆ m_teid

uint32_t ns3::GtpuHeader::m_teid
private

This field unambiguously identifies a tunnel endpoint in the receiving GTP-U protocol entity.

The receiving end side of a GTP tunnel locally assigns the TEID value the transmitting side has to use.

Definition at line 215 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetTeid(), operator==(), Print(), Serialize(), and SetTeid().

◆ m_version

uint8_t ns3::GtpuHeader::m_version
private

This field is used to determine the version of the GTPU-U protocol.

The version number shall be set to 1.

Definition at line 168 of file epc-gtpu-header.h.

Referenced by Deserialize(), GetVersion(), operator==(), Print(), Serialize(), and SetVersion().


The documentation for this class was generated from the following files: