A Discrete-Event Network Simulator
API
gtp-tunnel-app.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 University of Campinas (Unicamp)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Luciano Jerez Chaves <ljerezchaves@gmail.com>
18  */
19 
20 #ifndef GTP_TUNNEL_APP_H
21 #define GTP_TUNNEL_APP_H
22 
23 #include <ns3/applications-module.h>
24 #include <ns3/core-module.h>
25 #include <ns3/csma-module.h>
26 #include <ns3/internet-module.h>
27 #include <ns3/network-module.h>
28 #include <ns3/virtual-net-device-module.h>
29 
30 namespace ns3
31 {
32 
47 class GtpTunnelApp : public Application
48 {
49  public:
55  GtpTunnelApp(Ptr<VirtualNetDevice> logicalPort, Ptr<CsmaNetDevice> physicalDev);
56  ~GtpTunnelApp() override;
57 
62  static TypeId GetTypeId();
63 
76  bool RecvFromLogicalPort(Ptr<Packet> packet,
77  const Address& source,
78  const Address& dest,
79  uint16_t protocolNo);
80 
87  void RecvFromTunnelSocket(Ptr<Socket> socket);
88 
89  protected:
91  void DoDispose() override;
92 
93  // Inherited from Application.
94  void StartApplication() override;
95 
96  private:
104  void AddHeader(Ptr<Packet> packet,
105  Mac48Address source = Mac48Address(),
106  Mac48Address dest = Mac48Address(),
107  uint16_t protocolNo = Ipv4L3Protocol::PROT_NUMBER);
108 
112  const uint16_t m_port = 2152;
113 };
114 
115 } // namespace ns3
116 #endif /* GTP_TUNNEL_APP_H */
a polymophic address class
Definition: address.h:100
The base class for all ns3 applications.
Definition: application.h:61
This GTP tunnel application is responsible for implementing the logical port operations to encapsulat...
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.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
an EUI-48 address
Definition: mac48-address.h:46
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.