22 #include <ns3/epc-gtpu-header.h>
23 #include <ns3/tunnel-id-tag.h>
70 uint32_t teid = tagValue;
80 NS_LOG_DEBUG(
"Send packet " << packet->
GetUid() <<
" to tunnel with TEID " << teid <<
" IP "
81 << ipv4Addr <<
" port " <<
m_port);
85 if (bytes !=
static_cast<int>(packet->
GetSize()))
87 NS_LOG_ERROR(
"Not all bytes were copied to the socket buffer.");
148 Ipv4Address ipv4Addr = ipv4->GetAddress(idx, 0).GetLocal();
171 memset(buffer, 0, 46);
a polymophic address class
The base class for all ns3 applications.
Ptr< Node > GetNode() const
Packet trailer for Ethernet.
void EnableFcs(bool enable)
Enable or disable FCS checking and calculations.
void CalcFcs(Ptr< const Packet > p)
Updates the Fcs Field to the correct FCS.
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 ...
void RecvFromTunnelSocket(Ptr< Socket > socket)
Method to be assigned to the receive callback of the UDP tunnel socket.
static TypeId GetTypeId()
Register this type.
void StartApplication() override
Application specific startup code.
Ptr< CsmaNetDevice > m_physicalDev
Node physical network device.
void DoDispose() override
Destructor implementation.
Ptr< VirtualNetDevice > m_logicalPort
OpenFlow logical port device.
GtpTunnelApp(Ptr< VirtualNetDevice > logicalPort, Ptr< CsmaNetDevice > physicalDev)
Complete constructor.
Ptr< Socket > m_tunnelSocket
UDP tunnel socket.
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.
~GtpTunnelApp() override
Dummy destructor, see DoDispose.
const uint16_t m_port
GTP tunnel port.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
static Mac48Address ConvertFrom(const Address &address)
@ PACKET_HOST
Packet addressed to us.
static bool ChecksumEnabled()
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint64_t GetUid() const
Returns the packet's Uid.
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
Tag used to hold the tunnel metadata information (tunnel ID) when sending/receiving a packet to/from ...
uint64_t GetTunnelId() const
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool Receive(Ptr< Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
void SetSendCallback(SendCallback transmitCb)
Set the user callback to be called when a L2 packet is to be transmitted.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...