-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqos-controller.h
170 lines (143 loc) · 5.27 KB
/
qos-controller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* Copyright (c) 2016 University of Campinas (Unicamp)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Luciano Jerez Chaves <[email protected]>
*/
#ifndef QOS_CONTROLLER_H
#define QOS_CONTROLLER_H
#include <ns3/ofswitch13-module.h>
using namespace ns3;
/**
* \brief An border OpenFlow 1.3 controller
*/
class QosController : public OFSwitch13Controller
{
public:
QosController(); //!< Default constructor.
~QosController() override; //!< Dummy destructor.
/** Destructor implementation */
void DoDispose() override;
/**
* Register this type.
* \return The object TypeId.
*/
static TypeId GetTypeId();
/**
* Handle a packet in message sent by the switch to this controller.
* \note Inherited from OFSwitch13Controller.
* \param msg The OpenFlow received message.
* \param swtch The remote switch metadata.
* \param xid The transaction id from the request message.
* \return 0 if everything's ok, otherwise an error number.
*/
ofl_err HandlePacketIn(struct ofl_msg_packet_in* msg,
Ptr<const RemoteSwitch> swtch,
uint32_t xid) override;
protected:
// Inherited from OFSwitch13Controller
void HandshakeSuccessful(Ptr<const RemoteSwitch> swtch) override;
private:
/**
* Configure the border switch.
* \param swtch The switch information.
*/
void ConfigureSwitch1(Ptr<const RemoteSwitch> swtch);
/**
* Configure the aggregation switch.
* \param swtch The switch information.
*/
void ConfigureSwitch2(Ptr<const RemoteSwitch> swtch);
/**
* Configure the aggregation switch.
* \param swtch The switch information.
*/
void ConfigureSwitch3(Ptr<const RemoteSwitch> swtch);
/**
* Configure the aggregation switch.
* \param swtch The switch information.
*/
void ConfigureSwitch4(Ptr<const RemoteSwitch> swtch);
/**
* Configure the aggregation switch.
* \param swtch The switch information.
*/
void ConfigureSwitch5(Ptr<const RemoteSwitch> swtch);
/**
* Configure the aggregation switch.
* \param swtch The switch information.
*/
void ConfigureSwitch6(Ptr<const RemoteSwitch> swtch);
/**
* Configure the aggregation switch.
* \param swtch The switch information.
*/
void ConfigureSwitch7(Ptr<const RemoteSwitch> swtch);
/**
* Handle ARP request messages.
* \param msg The packet-in message.
* \param swtch The switch information.
* \param xid Transaction id.
* \return 0 if everything's ok, otherwise an error number.
*/
ofl_err HandleArpPacketIn(struct ofl_msg_packet_in* msg,
Ptr<const RemoteSwitch> swtch,
uint32_t xid);
/**
* Extract an IPv4 address from packet match.
* \param oxm_of The OXM_IF_* IPv4 field.
* \param match The ofl_match structure pointer.
* \return The IPv4 address.
*/
Ipv4Address ExtractIpv4Address(uint32_t oxm_of, struct ofl_match* match);
// /**
// * Create an ARP request packet, encapsulated inside of an Ethernet frame.
// * \param srcMac Source MAC address.
// * \param srcIp Source IP address.
// * \param dstIp Destination IP address.
// * \return The ns3 Ptr<Packet> with the ARP request.
// */
Ptr<Packet> CreateArpRequest(Mac48Address srcMac, Ipv4Address srcIp, Ipv4Address dstIp);
/**
* Create an ARP reply packet, encapsulated inside of an Ethernet frame.
* \param srcMac Source MAC address.
* \param srcIp Source IP address.
* \param dstMac Destination MAC address.
* \param dstIp Destination IP address.
* \return The ns3 Ptr<Packet> with the ARP reply.
*/
Ptr<Packet> CreateArpReply(Mac48Address srcMac,
Ipv4Address srcIp,
Mac48Address dstMac,
Ipv4Address dstIp);
/**
* Save the pair IP / MAC address in ARP table.
* \param ipAddr The IPv4 address.
* \param macAddr The MAC address.
*/
void SaveArpEntry(Ipv4Address ipAddr, Mac48Address macAddr);
/**
* Perform an ARP resolution
* \param ip The Ipv4Address to search.
* \return The MAC address for this ip.
*/
Mac48Address GetArpEntry(Ipv4Address ip);
bool m_meterEnable; //!< Enable per-flow mettering
DataRate m_meterRate; //!< Per-flow meter rate
/** Map saving <IPv4 address / MAC address> */
typedef std::map<Ipv4Address, Mac48Address> IpMacMap_t;
IpMacMap_t m_arpTable; //!< ARP resolution table.
};
#endif /* QOS_CONTROLLER_H */