A Discrete-Event Network Simulator
API
ns3::GtpTunnelApp Class Reference

This GTP tunnel application is responsible for implementing the logical port operations to encapsulate and de-encapsulated packets withing GTP tunnel. More...

#include "gtp-tunnel-app.h"

+ Inheritance diagram for ns3::GtpTunnelApp:
+ Collaboration diagram for ns3::GtpTunnelApp:

Public Member Functions

 GtpTunnelApp (Ptr< VirtualNetDevice > logicalPort, Ptr< CsmaNetDevice > physicalDev)
 Complete constructor. More...
 
 ~GtpTunnelApp () override
 Dummy destructor, see DoDispose. More...
 
bool RecvFromLogicalPort (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNo)
 Method to be assigned to the send callback of the VirtualNetDevice implementing the OpenFlow logical port. More...
 
void RecvFromTunnelSocket (Ptr< Socket > socket)
 Method to be assigned to the receive callback of the UDP tunnel socket. More...
 
- Public Member Functions inherited from ns3::Application
 Application ()
 
 ~Application () override
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time. More...
 
void SetStopTime (Time stop)
 Specify application stop time. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
 ~Object () override
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose ()
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one. More...
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized () const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::Application
static TypeId GetTypeId ()
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID. More...
 

Protected Member Functions

void DoDispose () override
 Destructor implementation. More...
 
void StartApplication () override
 Application specific startup code. More...
 
- Protected Member Functions inherited from ns3::Application
void DoInitialize () override
 Initialize() implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed. More...
 

Private Member Functions

void AddHeader (Ptr< Packet > packet, Mac48Address source=Mac48Address(), Mac48Address dest=Mac48Address(), uint16_t protocolNo=Ipv4L3Protocol::PROT_NUMBER)
 Adds the necessary Ethernet headers and trailers to a packet of data. More...
 

Private Attributes

Ptr< VirtualNetDevicem_logicalPort
 OpenFlow logical port device. More...
 
Ptr< CsmaNetDevicem_physicalDev
 Node physical network device. More...
 
const uint16_t m_port = 2152
 GTP tunnel port. More...
 
Ptr< Socketm_tunnelSocket
 UDP tunnel socket. More...
 

Additional Inherited Members

- Public Types inherited from ns3::Application
typedef void(* DelayAddressCallback) (const Time &delay, const Address &from)
 Common callback signature for packet delay and address. More...
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source. More...
 
- Protected Attributes inherited from ns3::Application
Ptr< Nodem_node
 The node that this application is installed on. More...
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application. More...
 
Time m_startTime
 The simulation time that the application will start. More...
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application. More...
 
Time m_stopTime
 The simulation time that the application will end. More...
 

Detailed Description

This GTP tunnel application is responsible for implementing the logical port operations to encapsulate and de-encapsulated packets withing GTP tunnel.

It provides the callback implementations that are used by the logical switch port and UDP socket. This application is stateless: it only adds/removes protocols headers over packets leaving/entering the OpenFlow switch based on information that is carried by packet tags.

When sending a packet to the GTP tunnel, this application expects that the packet carries the TunnelId tag set with the destination address in the 32 MSB and the TEID in the 32 LSB of packet tag. When a packet is received from the GTP tunnel, this application attachs the TunnelId tag only with the GTP TEID value.

Definition at line 47 of file gtp-tunnel-app.h.

Constructor & Destructor Documentation

◆ GtpTunnelApp()

ns3::GtpTunnelApp::GtpTunnelApp ( Ptr< VirtualNetDevice logicalPort,
Ptr< CsmaNetDevice physicalDev 
)

Complete constructor.

Parameters
logicalPortThe OpenFlow logical port device.
physicalDevThe physical network device on node.

Definition at line 31 of file gtp-tunnel-app.cc.

References m_logicalPort, m_physicalDev, ns3::MakeCallback(), NS_LOG_FUNCTION, RecvFromLogicalPort(), and ns3::VirtualNetDevice::SetSendCallback().

+ Here is the call graph for this function:

◆ ~GtpTunnelApp()

ns3::GtpTunnelApp::~GtpTunnelApp ( )
override

Dummy destructor, see DoDispose.

Definition at line 41 of file gtp-tunnel-app.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddHeader()

void ns3::GtpTunnelApp::AddHeader ( Ptr< Packet packet,
Mac48Address  source = Mac48Address(),
Mac48Address  dest = Mac48Address(),
uint16_t  protocolNo = Ipv4L3Protocol::PROT_NUMBER 
)
private

Adds the necessary Ethernet headers and trailers to a packet of data.

Parameters
packetPacket to which header should be added.
sourceMAC source address from which packet should be sent.
destMAC destination address to which packet should be sent.
protocolNoThe type of payload contained in this packet.

Definition at line 158 of file gtp-tunnel-app.cc.

References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), ns3::Packet::AddTrailer(), ns3::EthernetTrailer::CalcFcs(), ns3::Node::ChecksumEnabled(), ns3::EthernetTrailer::EnableFcs(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, ns3::EthernetHeader::SetDestination(), ns3::EthernetHeader::SetLengthType(), and ns3::EthernetHeader::SetSource().

Referenced by RecvFromTunnelSocket().

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

◆ DoDispose()

void ns3::GtpTunnelApp::DoDispose ( )
overrideprotectedvirtual

Destructor implementation.

Reimplemented from ns3::Application.

Definition at line 130 of file gtp-tunnel-app.cc.

References m_logicalPort, m_physicalDev, m_tunnelSocket, and NS_LOG_FUNCTION.

◆ GetTypeId()

TypeId ns3::GtpTunnelApp::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 47 of file gtp-tunnel-app.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ RecvFromLogicalPort()

bool ns3::GtpTunnelApp::RecvFromLogicalPort ( Ptr< Packet packet,
const Address source,
const Address dest,
uint16_t  protocolNo 
)

Method to be assigned to the send callback of the VirtualNetDevice implementing the OpenFlow logical port.

It is called when the OpenFlow switch sends a packet out over the logical port. The logical port callbacks here, and we must encapsulate the packet withing GTP and forward it to the UDP tunnel socket.

Parameters
packetThe packet received from the logical port.
sourceEthernet source address.
destEthernet destination address.
protocolNoThe type of payload contained in this packet.
Returns
Whether the operation succeeded.

Definition at line 55 of file gtp-tunnel-app.cc.

References ns3::Packet::AddHeader(), ns3::GtpuHeader::GetSerializedSize(), ns3::Packet::GetSize(), ns3::TunnelIdTag::GetTunnelId(), ns3::Packet::GetUid(), m_port, m_tunnelSocket, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_ERROR, NS_LOG_FUNCTION, ns3::Packet::RemovePacketTag(), ns3::Socket::SendTo(), ns3::GtpuHeader::SetLength(), and ns3::GtpuHeader::SetTeid().

Referenced by GtpTunnelApp().

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

◆ RecvFromTunnelSocket()

void ns3::GtpTunnelApp::RecvFromTunnelSocket ( Ptr< Socket socket)

Method to be assigned to the receive callback of the UDP tunnel socket.

It is called when the tunnel socket receives a packet, and must forward the packet to the logical port.

Parameters
socketPointer to the tunnel socket.

Definition at line 94 of file gtp-tunnel-app.cc.

References AddHeader(), ns3::Mac48Address::ConvertFrom(), ns3::GtpuHeader::GetTeid(), ns3::Packet::GetUid(), m_logicalPort, m_physicalDev, m_tunnelSocket, NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::NetDevice::PACKET_HOST, ns3::Ipv4L3Protocol::PROT_NUMBER, ns3::VirtualNetDevice::Receive(), ns3::Socket::Recv(), ns3::Packet::RemoveHeader(), and ns3::Packet::ReplacePacketTag().

Referenced by StartApplication().

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

◆ StartApplication()

void ns3::GtpTunnelApp::StartApplication ( )
overrideprotectedvirtual

Application specific startup code.

The StartApplication method is called at the start time specified by Start This method should be overridden by all or most application subclasses.

Reimplemented from ns3::Application.

Definition at line 140 of file gtp-tunnel-app.cc.

References ns3::Socket::Bind(), ns3::Socket::BindToNetDevice(), ns3::Socket::CreateSocket(), ns3::Application::GetNode(), ns3::Object::GetObject(), ns3::TypeId::LookupByName(), m_physicalDev, m_port, m_tunnelSocket, ns3::MakeCallback(), NS_LOG_FUNCTION, RecvFromTunnelSocket(), and ns3::Socket::SetRecvCallback().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_logicalPort

Ptr<VirtualNetDevice> ns3::GtpTunnelApp::m_logicalPort
private

OpenFlow logical port device.

Definition at line 110 of file gtp-tunnel-app.h.

Referenced by GtpTunnelApp(), DoDispose(), and RecvFromTunnelSocket().

◆ m_physicalDev

Ptr<CsmaNetDevice> ns3::GtpTunnelApp::m_physicalDev
private

Node physical network device.

Definition at line 111 of file gtp-tunnel-app.h.

Referenced by GtpTunnelApp(), DoDispose(), RecvFromTunnelSocket(), and StartApplication().

◆ m_port

const uint16_t ns3::GtpTunnelApp::m_port = 2152
private

GTP tunnel port.

Definition at line 112 of file gtp-tunnel-app.h.

Referenced by RecvFromLogicalPort(), and StartApplication().

◆ m_tunnelSocket

Ptr<Socket> ns3::GtpTunnelApp::m_tunnelSocket
private

UDP tunnel socket.

Definition at line 109 of file gtp-tunnel-app.h.

Referenced by DoDispose(), RecvFromLogicalPort(), RecvFromTunnelSocket(), and StartApplication().


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