A Discrete-Event Network Simulator
API
tunnel-controller.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 TUNNEL_CONTROLLER_H
21 #define TUNNEL_CONTROLLER_H
22 
23 #include <ns3/applications-module.h>
24 #include <ns3/core-module.h>
25 #include <ns3/internet-module.h>
26 #include <ns3/network-module.h>
27 #include <ns3/ofswitch13-module.h>
28 #include <ns3/virtual-net-device-module.h>
29 
30 namespace ns3
31 {
32 
42 {
43  public:
45  ~TunnelController() override;
46 
51  static TypeId GetTypeId();
52 
58  void SaveArpEntry(Ipv4Address ipAddr, Mac48Address macAddr);
59 
66  void SaveTunnelEndpoint(uint64_t dpId, uint32_t portNo, Ipv4Address ipAddr);
67 
68  protected:
70  void DoDispose() override;
71 
72  // Inherited from OFSwitch13Controller
73  void HandshakeSuccessful(Ptr<const RemoteSwitch> swtch) override;
74 
83  ofl_err HandlePacketIn(struct ofl_msg_packet_in* msg,
85  uint32_t xid) override;
86 
87  private:
94 
101  Ipv4Address GetTunnelEndpoint(uint64_t dpId, uint32_t portNo);
102 
110  ofl_err HandleArpPacketIn(struct ofl_msg_packet_in* msg,
112  uint32_t xid);
113 
120  Ipv4Address ExtractIpv4Address(uint32_t oxm_of, struct ofl_match* match);
121 
132  Ipv4Address srcIp,
133  Mac48Address dstMac,
134  Ipv4Address dstIp);
135 
137  typedef std::pair<uint64_t, uint32_t> DpPortPair_t;
138 
140  typedef std::map<DpPortPair_t, Ipv4Address> DpPortIpMap_t;
141 
143  typedef std::map<Ipv4Address, Mac48Address> IpMacMap_t;
144 
147 };
148 
149 } // namespace ns3
150 #endif /* TUNNEL_CONTROLLER_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
an EUI-48 address
Definition: mac48-address.h:46
OpenFlow 1.3 controller base class that can handle a collection of OpenFlow switches and provides the...
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
This controller is responsible for installing the forwarding rules on the switches.
ofl_err HandleArpPacketIn(struct ofl_msg_packet_in *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
Handle packet-in messages sent from switch with ARP message.
TunnelController()
Default constructor.
IpMacMap_t m_arpTable
ARP resolution table.
Ipv4Address ExtractIpv4Address(uint32_t oxm_of, struct ofl_match *match)
Extract an IPv4 address from packet match.
static TypeId GetTypeId()
Register this type.
void SaveTunnelEndpoint(uint64_t dpId, uint32_t portNo, Ipv4Address ipAddr)
Save the pair datapath ID + port no / IP address in tunnel endpoint table.
~TunnelController() override
Dummy destructor, see DoDispose.
void DoDispose() override
Destructor implementation.
Ipv4Address GetTunnelEndpoint(uint64_t dpId, uint32_t portNo)
Perform tunnel endpoint resolution.
Ptr< Packet > CreateArpReply(Mac48Address srcMac, Ipv4Address srcIp, Mac48Address dstMac, Ipv4Address dstIp)
Create a Packet with an ARP reply, encapsulated inside of an Ethernet frame (with header and trailer.
DpPortIpMap_t m_endpointTable
Tunnel endpoint resolution table.
Mac48Address GetArpEntry(Ipv4Address ip)
Perform ARP resolution.
ofl_err HandlePacketIn(struct ofl_msg_packet_in *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid) override
Handle a packet in message sent by the switch to this controller.
std::pair< uint64_t, uint32_t > DpPortPair_t
A pair identifying OpenFlow datapath id and port number.
void SaveArpEntry(Ipv4Address ipAddr, Mac48Address macAddr)
Save the pair IP / MAC address in ARP table.
std::map< Ipv4Address, Mac48Address > IpMacMap_t
Map saving <IPv4 address / MAC address>
std::map< DpPortPair_t, Ipv4Address > DpPortIpMap_t
Map saving <DpPortPair_t / IPv4 address>
void HandshakeSuccessful(Ptr< const RemoteSwitch > swtch) override
Function invoked after a successfully handshake procedure between this controller and a remote switch...
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.