A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
openflow-interface.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: Blake Hurd <naimorai@gmail.com>
5 */
6#ifndef OPENFLOW_INTERFACE_H
7#define OPENFLOW_INTERFACE_H
8
9#include <assert.h>
10#include <errno.h>
11
12// Include OFSI code
13#include "ns3/address.h"
14#include "ns3/log.h"
15#include "ns3/mac48-address.h"
16#include "ns3/net-device.h"
17#include "ns3/nstime.h"
18#include "ns3/packet.h"
19#include "ns3/simulator.h"
20
21#include <limits>
22#include <map>
23#include <set>
24
25// Include main header and Vendor Extension files
26#include "openflow/ericsson-ext.h"
27#include "openflow/nicira-ext.h"
28#include "openflow/openflow.h"
29
30extern "C"
31{
32// Inexplicably, the OpenFlow implementation uses these two reserved words as member names.
33#define private _private
34#define delete _delete
35#define list List
36
37// Include OFSI Library files
38#include "openflow/private/csum.h"
39#include "openflow/private/poll-loop.h"
40#include "openflow/private/rconn.h"
41#include "openflow/private/stp.h"
42#include "openflow/private/vconn.h"
43#include "openflow/private/xtoxll.h"
44
45// Include OFSI Switch files
46#include "openflow/private/chain.h"
47#include "openflow/private/datapath.h" // The functions below are defined in datapath.c
48#include "openflow/private/table.h"
52#include "openflow/private/dp_act.h" // The functions below are defined in dp_act.c
53 void set_vlan_vid(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
54 void set_vlan_pcp(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
55 void strip_vlan(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
56 void set_dl_addr(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
57 void set_nw_addr(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
58 void set_tp_port(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
59 void set_mpls_label(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
60 void set_mpls_exp(ofpbuf* buffer, sw_flow_key* key, const ofp_action_header* ah);
61#include "openflow/private/pt_act.h"
62
63#undef list
64#undef private
65#undef delete
66}
67
68// Capabilities supported by this implementation.
69#ifndef OFP_SUPPORTED_CAPABILITIES
70#define OFP_SUPPORTED_CAPABILITIES \
71 (OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | OFPC_MULTI_PHY_TX | OFPC_VPORT_TABLE)
72#endif
73
74// Actions supported by this implementation.
75#ifndef OFP_SUPPORTED_ACTIONS
76#define OFP_SUPPORTED_ACTIONS \
77 ((1 << OFPAT_OUTPUT) | (1 << OFPAT_SET_VLAN_VID) | (1 << OFPAT_SET_VLAN_PCP) | \
78 (1 << OFPAT_STRIP_VLAN) | (1 << OFPAT_SET_DL_SRC) | (1 << OFPAT_SET_DL_DST) | \
79 (1 << OFPAT_SET_NW_SRC) | (1 << OFPAT_SET_NW_DST) | (1 << OFPAT_SET_TP_SRC) | \
80 (1 << OFPAT_SET_TP_DST) | (1 << OFPAT_SET_MPLS_LABEL) | (1 << OFPAT_SET_MPLS_EXP))
81#endif
82
83#ifndef OFP_SUPPORTED_VPORT_TABLE_ACTIONS
84#define OFP_SUPPORTED_VPORT_TABLE_ACTIONS \
85 ((1 << OFPPAT_OUTPUT) | (1 << OFPPAT_POP_MPLS) | (1 << OFPPAT_PUSH_MPLS) | \
86 (1 << OFPPAT_SET_MPLS_LABEL) | (1 << OFPPAT_SET_MPLS_EXP))
87#endif
88
89namespace ns3
90{
91
92class OpenFlowSwitchNetDevice;
93
94namespace ofi
95{
96
97/**
98 * @ingroup openflow
99 * @brief Port and its metadata.
100 *
101 * We need to store port metadata, because OpenFlow dictates that there
102 * exists a type of request where the Controller asks for data about a
103 * port, or multiple ports. Otherwise, we'd refer to it via Ptr<NetDevice>
104 * everywhere.
105 */
106struct Port
107{
109 : config(0),
110 state(0),
111 netdev(nullptr),
112 rx_packets(0),
113 tx_packets(0),
114 rx_bytes(0),
115 tx_bytes(0),
116 tx_dropped(0),
118 {
119 }
120
121 uint32_t config; ///< Some subset of OFPPC_* flags.
122 uint32_t state; ///< Some subset of OFPPS_* flags.
123 Ptr<NetDevice> netdev; ///< NetDevice pointer
124 unsigned long long int rx_packets; //!< Counter of Rx packets
125 unsigned long long int tx_packets; //!< Counter of Tx packets
126 unsigned long long int rx_bytes; //!< Counter of Rx bytes
127 unsigned long long int tx_bytes; //!< Counter of Tx bytes
128 unsigned long long int tx_dropped; //!< Counter of Tx dropped packets
129 unsigned long long int mpls_ttl0_dropped; //!< Counter of packets dropped due to MPLS TTL
130};
131
132/**
133 * @ingroup openflow
134 * OpenFlow statistics
135 */
136class Stats
137{
138 public:
139 /**
140 * Constructor
141 * @param _type OpenFlow stats type.
142 * @param body_len Stat body length.
143 */
144 Stats(ofp_stats_types _type, size_t body_len);
145
146 /**
147 * @brief Prepares to dump some kind of statistics on the connected OpenFlowSwitchNetDevice.
148 *
149 * @param body Body member of the struct ofp_stats_request.
150 * @param body_len Length of the body member.
151 * @param state State information.
152 * @return 0 if successful, otherwise a negative error code.
153 */
154 int DoInit(const void* body, int body_len, void** state);
155
156 /**
157 * @brief Appends statistics for OpenFlowSwitchNetDevice to 'buffer'.
158 *
159 * @param swtch The OpenFlowSwitchNetDevice this callback is associated with.
160 * @param state State information.
161 * @param buffer Buffer to append stats reply to.
162 * @return 1 if it should be called again later with another buffer, 0 if it is done, or a
163 * negative errno value on failure.
164 */
165 int DoDump(Ptr<OpenFlowSwitchNetDevice> swtch, void* state, ofpbuf* buffer);
166
167 /**
168 * @brief Cleans any state created by the init or dump functions.
169 *
170 * May not be implemented if no cleanup is required.
171 *
172 * @param state State information to clear.
173 */
174 void DoCleanup(void* state);
175
176 /**
177 * @brief State of the FlowStats request/reply.
178 */
180 {
181 int table_idx; //!< Table index
182 sw_table_position position; //!< Table position
183 ofp_flow_stats_request rq; //!< Stats requests
184 time_t now; //!< Actual time
185
186 ofpbuf* buffer; //!< Buffer
187 };
188
189 /**
190 * @ingroup openflow
191 * @brief State of the PortStats request/reply.
192 */
194 {
195 uint32_t num_ports; ///< Number of ports in host byte order
196 uint32_t* ports; ///< Array of ports in network byte order
197 };
198
199 ofp_stats_types type; //!< Status type
200 private:
201 /**
202 * Dumps the stats description
203 * @param [in] state The state.
204 * @param [out] buffer Output buffer.
205 * @return zero on success
206 */
207 int DescStatsDump(void* state, ofpbuf* buffer);
208
209 /**
210 * @{
211 * Initialize the stats.
212 * @param body Body member of the struct ofp_stats_request.
213 * @param body_len Length of the body member.
214 * @param state State information.
215 * @return 0 if successful, otherwise a negative error code.
216 */
217 int FlowStatsInit(const void* body, int body_len, void** state);
218 int AggregateStatsInit(const void* body, int body_len, void** state);
219 int PortStatsInit(const void* body, int body_len, void** state);
220 /** @} */
221
222 /// Flow dump callback functor
223 int (*FlowDumpCallback)(sw_flow* flow, void* state);
224 /// Aggregate dump callback functor
225 int (*AggregateDumpCallback)(sw_flow* flow, void* state);
226
227 /**
228 * @{
229 * Dump the stats.
230 * @param dp OpenFlow NetDevice.
231 * @param state State.
232 * @param [out] buffer output buffer.
233 * @return 0 if successful
234 */
235 int FlowStatsDump(Ptr<OpenFlowSwitchNetDevice> dp, FlowStatsState* state, ofpbuf* buffer);
237 ofp_aggregate_stats_request* state,
238 ofpbuf* buffer);
239 int TableStatsDump(Ptr<OpenFlowSwitchNetDevice> dp, void* state, ofpbuf* buffer);
240 int PortStatsDump(Ptr<OpenFlowSwitchNetDevice> dp, PortStatsState* state, ofpbuf* buffer);
241 int PortTableStatsDump(Ptr<OpenFlowSwitchNetDevice> dp, void* state, ofpbuf* buffer);
242 /** @} */
243};
244
245/**
246 * @ingroup openflow
247 * @brief Class for handling flow table actions.
248 */
249struct Action
250{
251 /**
252 * @param type Type of Flow Table Action.
253 * @return true if the provided type is a type of flow table action.
254 */
255 static bool IsValidType(ofp_action_type type);
256
257 /**
258 * @brief Validates the action on whether its data is valid or not.
259 *
260 * @param type Type of action to validate.
261 * @param len Length of the action data.
262 * @param key Matching key for the flow that is tied to this action.
263 * @param ah Action's data header.
264 * @return ACT_VALIDATION_OK if the action checks out, otherwise an error type.
265 */
266 static uint16_t Validate(ofp_action_type type,
267 size_t len,
268 const sw_flow_key* key,
269 const ofp_action_header* ah);
270
271 /**
272 * @brief Executes the action.
273 *
274 * @param type Type of action to execute.
275 * @param buffer Buffer of the Packet if it's needed for the action.
276 * @param key Matching key for the flow that is tied to this action.
277 * @param ah Action's data header.
278 */
279 static void Execute(ofp_action_type type,
280 ofpbuf* buffer,
281 sw_flow_key* key,
282 const ofp_action_header* ah);
283};
284
285/**
286 * @ingroup openflow
287 * @brief Class for handling virtual port table actions.
288 */
290{
291 /**
292 * @param type Type of virtual port table Action.
293 * @return true if the provided type is a type of virtual port table action.
294 */
295 static bool IsValidType(ofp_vport_action_type type);
296
297 /**
298 * @brief Validates the action on whether its data is valid or not.
299 *
300 * @param type Type of action to validate.
301 * @param len Length of the action data.
302 * @param ah Action's data header.
303 * @return ACT_VALIDATION_OK if the action checks out, otherwise an error type.
304 */
305 static uint16_t Validate(ofp_vport_action_type type, size_t len, const ofp_action_header* ah);
306
307 /**
308 * @brief Executes the action.
309 *
310 * @param type Type of action to execute.
311 * @param buffer Buffer of the Packet if it's needed for the action.
312 * @param key Matching key for the flow that is tied to this action.
313 * @param ah Action's data header.
314 */
315 static void Execute(ofp_vport_action_type type,
316 ofpbuf* buffer,
317 const sw_flow_key* key,
318 const ofp_action_header* ah);
319};
320
321/**
322 * @ingroup openflow
323 * @brief Class for handling Ericsson Vendor-defined actions.
324 */
326{
327 /**
328 * @param type Type of Ericsson Vendor-defined Action.
329 * @return true if the provided type is a type of Ericsson Vendor-defined action.
330 */
331 static bool IsValidType(er_action_type type);
332
333 /**
334 * @brief Validates the action on whether its data is valid or not.
335 *
336 * @param type Type of action to validate.
337 * @param len Length of the action data.
338 * @return ACT_VALIDATION_OK if the action checks out, otherwise an error type.
339 */
340 static uint16_t Validate(er_action_type type, size_t len);
341
342 /**
343 * @brief Executes the action.
344 *
345 * @param type Type of action to execute.
346 * @param buffer Buffer of the Packet if it's needed for the action.
347 * @param key Matching key for the flow that is tied to this action.
348 * @param ah Action's data header.
349 */
350 static void Execute(er_action_type type,
351 ofpbuf* buffer,
352 const sw_flow_key* key,
353 const er_action_header* ah);
354};
355
356/**
357 * @ingroup openflow
358 * @brief Callback for a stats dump request.
359 */
361{
362 bool done; ///< Whether we are done requesting stats.
363 ofp_stats_request* rq; ///< Current stats request.
364 Stats* s; ///< Handler of the stats request.
365 void* state; ///< Stats request state data.
366 Ptr<OpenFlowSwitchNetDevice> swtch; ///< The switch that we're requesting data from.
367};
368
369/**
370 * @ingroup openflow
371 * @brief Packet Metadata, allows us to track the packet's metadata as it passes through the switch.
372 */
374{
375 Ptr<Packet> packet; ///< The Packet itself.
376 ofpbuf* buffer; ///< The OpenFlow buffer as created from the Packet, with its data and headers.
377 uint16_t protocolNumber; ///< Protocol type of the Packet when the Packet is received
378 Address src; ///< Source Address of the Packet when the Packet is received
379 Address dst; ///< Destination Address of the Packet when the Packet is received.
380};
381
382/**
383 * @ingroup openflow
384 * @brief An interface for a Controller of OpenFlowSwitchNetDevices
385 *
386 * Follows the OpenFlow specification for a controller.
387 */
388class Controller : public Object
389{
390 public:
391 /**
392 * Register this type.
393 * @return The TypeId.
394 */
395 static TypeId GetTypeId();
396 /** Destructor. */
397 ~Controller() override;
398
399 /**
400 * Adds a switch to the controller.
401 *
402 * @param swtch The switch to register.
403 */
404 virtual void AddSwitch(Ptr<OpenFlowSwitchNetDevice> swtch);
405
406 /**
407 * A switch calls this method to pass a message on to the Controller.
408 *
409 * @param swtch The switch the message was received from.
410 * @param buffer The message.
411 */
412 virtual void ReceiveFromSwitch(Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer)
413 {
414 }
415
416 /**
417 * @brief Starts a callback-based, reliable, possibly multi-message reply to a request made by
418 * the controller.
419 *
420 * If an incoming request needs to have a reliable reply that might
421 * require multiple messages, it can use StartDump() to set up
422 * a callback that will be called as buffer space for replies.
423 *
424 * A stats request made by the controller is processed by the switch,
425 * the switch then calls this method to tell the controller to start
426 * asking for information. By default (it can be overridden), the
427 * controller stops all work to run through the callback. ReceiveFromSwitch
428 * must be defined appropriately to handle the status reply messages
429 * generated by the switch, or otherwise the status reply messages will be sent
430 * and discarded.
431 *
432 * @param cb The callback data.
433 */
435
436 protected:
437 /**
438 * However the controller is implemented, this method is to
439 * be used to pass a message on to a switch.
440 *
441 * @param swtch The switch to receive the message.
442 * @param msg The message to send.
443 * @param length The length of the message.
444 */
445 virtual void SendToSwitch(Ptr<OpenFlowSwitchNetDevice> swtch, void* msg, size_t length);
446
447 /**
448 * Construct flow data from a matching key to build a flow
449 * entry for adding, modifying, or deleting a flow.
450 *
451 * @param key The matching key data; used to create a flow that matches the packet.
452 * @param buffer_id The OpenFlow Buffer ID; used to run the actions on the packet if we add or
453 * modify the flow.
454 * @param command Whether to add, modify, or delete this flow.
455 * @param acts List of actions to execute.
456 * @param actions_len Length of the actions buffer.
457 * @param idle_timeout Flow expires if left inactive for this amount of time (specify
458 * OFP_FLOW_PERMANENT to disable feature).
459 * @param hard_timeout Flow expires after this amount of time (specify OFP_FLOW_PERMANENT to
460 * disable feature).
461 * @return Flow data that when passed to SetFlow will add, modify, or delete a flow it defines.
462 */
463 ofp_flow_mod* BuildFlow(sw_flow_key key,
464 uint32_t buffer_id,
465 uint16_t command,
466 void* acts,
467 size_t actions_len,
468 int idle_timeout,
469 int hard_timeout);
470
471 /**
472 * Get the packet type on the buffer, which can then be used
473 * to determine how to handle the buffer.
474 *
475 * @param buffer The packet in OpenFlow buffer format.
476 * @return The packet type, as defined in the ofp_type struct.
477 */
478 uint8_t GetPacketType(ofpbuf* buffer);
479
480 /// OpenFlowSwitchNetDevice container type
481 typedef std::set<Ptr<OpenFlowSwitchNetDevice>> Switches_t;
482 Switches_t m_switches; ///< The collection of switches registered to this controller.
483};
484
485/**
486 * @ingroup openflow
487 * Demonstration of a Drop controller. When a connected switch
488 * passes it a packet the switch doesn't recognize, the controller
489 * configures the switch to make a flow that drops alike packets.
490 */
492{
493 public:
494 /**
495 * Register this type.
496 * @return The TypeId.
497 */
498 static TypeId GetTypeId();
499
500 void ReceiveFromSwitch(Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer) override;
501};
502
503/**
504 * @ingroup openflow
505 * Demonstration of a Learning controller. When a connected switch
506 * passes it a packet the switch doesn't recognize, the controller
507 * delves into its learned states and figures out if we know what
508 * port the packet is supposed to go to, flooding if unknown, and
509 * adjusts the switch's flow table accordingly.
510 */
512{
513 public:
514 /**
515 * Register this type.
516 * @return The TypeId.
517 */
518 static TypeId GetTypeId();
519
521 {
522 m_learnState.clear();
523 }
524
525 void ReceiveFromSwitch(Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer) override;
526
527 protected:
528 /// Learned state
530 {
531 uint32_t port; ///< Learned port.
532 };
533
534 Time m_expirationTime; ///< Time it takes for learned MAC state entry/created flow to expire.
535 /// Learned state type
536 typedef std::map<Mac48Address, LearnedState> LearnState_t;
537 LearnState_t m_learnState; ///< Learned state data.
538};
539
540/**
541 * @brief Executes a list of flow table actions.
542 *
543 * @param swtch OpenFlowSwitchNetDevice these actions are being executed on.
544 * @param packet_uid Packet UID; used to fetch the packet and its metadata.
545 * @param buffer The Packet OpenFlow buffer.
546 * @param key The matching key for the flow tied to this list of actions.
547 * @param actions A buffer of actions.
548 * @param actions_len Length of actions buffer.
549 * @param ignore_no_fwd If true, during port forwarding actions, ports that are set to not forward
550 * are forced to forward.
551 */
553 uint64_t packet_uid,
554 ofpbuf* buffer,
555 sw_flow_key* key,
556 const ofp_action_header* actions,
557 size_t actions_len,
558 int ignore_no_fwd);
559
560/**
561 * @brief Validates a list of flow table actions.
562 *
563 * @param key The matching key for the flow tied to this list of actions.
564 * @param actions A buffer of actions.
565 * @param actions_len Length of actions buffer.
566 * @return If the action list validates, ACT_VALIDATION_OK is returned. Otherwise, a code for the
567 * OFPET_BAD_ACTION error type is returned.
568 */
569uint16_t ValidateActions(const sw_flow_key* key,
570 const ofp_action_header* actions,
571 size_t actions_len);
572
573/**
574 * @brief Executes a list of virtual port table entry actions.
575 *
576 * @param swtch OpenFlowSwitchNetDevice these actions are being executed on.
577 * @param packet_uid Packet UID; used to fetch the packet and its metadata.
578 * @param buffer The Packet OpenFlow buffer.
579 * @param key The matching key for the flow tied to this list of actions.
580 * @param actions A buffer of actions.
581 * @param actions_len Length of actions buffer.
582 */
584 uint64_t packet_uid,
585 ofpbuf* buffer,
586 sw_flow_key* key,
587 const ofp_action_header* actions,
588 size_t actions_len);
589
590/**
591 * @brief Validates a list of virtual port table entry actions.
592 *
593 * @param actions A buffer of actions.
594 * @param actions_len Length of actions buffer.
595 * @return If the action list validates, ACT_VALIDATION_OK is returned. Otherwise, a code for the
596 * OFPET_BAD_ACTION error type is returned.
597 */
598uint16_t ValidateVPortActions(const ofp_action_header* actions, size_t actions_len);
599
600/**
601 * @brief Executes a vendor-defined action.
602 *
603 * @param buffer The Packet OpenFlow buffer.
604 * @param key The matching key for the flow tied to this list of actions.
605 * @param ah Header of the action.
606 */
607void ExecuteVendor(ofpbuf* buffer, const sw_flow_key* key, const ofp_action_header* ah);
608
609/**
610 * @brief Validates a vendor-defined action.
611 *
612 * @param key The matching key for the flow tied to this list of actions.
613 * @param ah Header of the action.
614 * @param len Length of the action.
615 * @return If the action list validates, ACT_VALIDATION_OK is returned. Otherwise, a code for the
616 * OFPET_BAD_ACTION error type is returned.
617 */
618uint16_t ValidateVendor(const sw_flow_key* key, const ofp_action_header* ah, uint16_t len);
619
620/*
621 * From datapath.c
622 * Buffers are identified to userspace by a 31-bit opaque ID. We divide the ID
623 * into a buffer number (low bits) and a cookie (high bits). The buffer number
624 * is an index into an array of buffers. The cookie distinguishes between
625 * different packets that have occupied a single buffer. Thus, the more
626 * buffers we have, the lower-quality the cookie...
627 */
628#define PKT_BUFFER_BITS 8
629#define N_PKT_BUFFERS (1 << PKT_BUFFER_BITS)
630#define PKT_BUFFER_MASK (N_PKT_BUFFERS - 1)
631#define PKT_COOKIE_BITS (32 - PKT_BUFFER_BITS)
632
633} // namespace ofi
634
635} // namespace ns3
636
637#endif /* OPENFLOW_INTERFACE_H */
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
a polymophic address class
Definition address.h:90
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
An interface for a Controller of OpenFlowSwitchNetDevices.
virtual void SendToSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, void *msg, size_t length)
However the controller is implemented, this method is to be used to pass a message on to a switch.
uint8_t GetPacketType(ofpbuf *buffer)
Get the packet type on the buffer, which can then be used to determine how to handle the buffer.
Switches_t m_switches
The collection of switches registered to this controller.
~Controller() override
Destructor.
virtual void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer)
A switch calls this method to pass a message on to the Controller.
static TypeId GetTypeId()
Register this type.
ofp_flow_mod * BuildFlow(sw_flow_key key, uint32_t buffer_id, uint16_t command, void *acts, size_t actions_len, int idle_timeout, int hard_timeout)
Construct flow data from a matching key to build a flow entry for adding, modifying,...
std::set< Ptr< OpenFlowSwitchNetDevice > > Switches_t
OpenFlowSwitchNetDevice container type.
void StartDump(StatsDumpCallback *cb)
Starts a callback-based, reliable, possibly multi-message reply to a request made by the controller.
virtual void AddSwitch(Ptr< OpenFlowSwitchNetDevice > swtch)
Adds a switch to the controller.
Demonstration of a Drop controller.
void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer) override
A switch calls this method to pass a message on to the Controller.
static TypeId GetTypeId()
Register this type.
Demonstration of a Learning controller.
static TypeId GetTypeId()
Register this type.
std::map< Mac48Address, LearnedState > LearnState_t
Learned state type.
void ReceiveFromSwitch(Ptr< OpenFlowSwitchNetDevice > swtch, ofpbuf *buffer) override
A switch calls this method to pass a message on to the Controller.
Time m_expirationTime
Time it takes for learned MAC state entry/created flow to expire.
LearnState_t m_learnState
Learned state data.
OpenFlow statistics.
int PortStatsInit(const void *body, int body_len, void **state)
Initialize the stats.
int PortTableStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, void *state, ofpbuf *buffer)
Dump the stats.
int FlowStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, FlowStatsState *state, ofpbuf *buffer)
Dump the stats.
int(* AggregateDumpCallback)(sw_flow *flow, void *state)
Aggregate dump callback functor.
Stats(ofp_stats_types _type, size_t body_len)
Constructor.
void DoCleanup(void *state)
Cleans any state created by the init or dump functions.
int AggregateStatsInit(const void *body, int body_len, void **state)
Initialize the stats.
int DoDump(Ptr< OpenFlowSwitchNetDevice > swtch, void *state, ofpbuf *buffer)
Appends statistics for OpenFlowSwitchNetDevice to 'buffer'.
int DoInit(const void *body, int body_len, void **state)
Prepares to dump some kind of statistics on the connected OpenFlowSwitchNetDevice.
int AggregateStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, ofp_aggregate_stats_request *state, ofpbuf *buffer)
Dump the stats.
int TableStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, void *state, ofpbuf *buffer)
Dump the stats.
int PortStatsDump(Ptr< OpenFlowSwitchNetDevice > dp, PortStatsState *state, ofpbuf *buffer)
Dump the stats.
ofp_stats_types type
Status type.
int FlowStatsInit(const void *body, int body_len, void **state)
Initialize the stats.
int DescStatsDump(void *state, ofpbuf *buffer)
Dumps the stats description.
int(* FlowDumpCallback)(sw_flow *flow, void *state)
Flow dump callback functor.
void ExecuteVPortActions(Ptr< OpenFlowSwitchNetDevice > swtch, uint64_t packet_uid, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *actions, size_t actions_len)
Executes a list of virtual port table entry actions.
void ExecuteActions(Ptr< OpenFlowSwitchNetDevice > swtch, uint64_t packet_uid, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *actions, size_t actions_len, int ignore_no_fwd)
Executes a list of flow table actions.
uint16_t ValidateVendor(const sw_flow_key *key, const ofp_action_header *ah, uint16_t len)
Validates a vendor-defined action.
void ExecuteVendor(ofpbuf *buffer, const sw_flow_key *key, const ofp_action_header *ah)
Executes a vendor-defined action.
uint16_t ValidateActions(const sw_flow_key *key, const ofp_action_header *actions, size_t actions_len)
Validates a list of flow table actions.
uint16_t ValidateVPortActions(const ofp_action_header *actions, size_t actions_len)
Validates a list of virtual port table entry actions.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void discard_buffer(uint32_t id)
void strip_vlan(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_mpls_label(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_dl_addr(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
uint32_t save_buffer(ofpbuf *)
void set_nw_addr(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
ofpbuf * retrieve_buffer(uint32_t id)
void set_vlan_pcp(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_tp_port(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_mpls_exp(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
void set_vlan_vid(ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
Class for handling flow table actions.
static bool IsValidType(ofp_action_type type)
static void Execute(ofp_action_type type, ofpbuf *buffer, sw_flow_key *key, const ofp_action_header *ah)
Executes the action.
static uint16_t Validate(ofp_action_type type, size_t len, const sw_flow_key *key, const ofp_action_header *ah)
Validates the action on whether its data is valid or not.
Class for handling Ericsson Vendor-defined actions.
static bool IsValidType(er_action_type type)
static void Execute(er_action_type type, ofpbuf *buffer, const sw_flow_key *key, const er_action_header *ah)
Executes the action.
static uint16_t Validate(er_action_type type, size_t len)
Validates the action on whether its data is valid or not.
Port and its metadata.
Ptr< NetDevice > netdev
NetDevice pointer.
unsigned long long int mpls_ttl0_dropped
Counter of packets dropped due to MPLS TTL.
unsigned long long int tx_packets
Counter of Tx packets.
unsigned long long int tx_bytes
Counter of Tx bytes.
unsigned long long int rx_packets
Counter of Rx packets.
unsigned long long int rx_bytes
Counter of Rx bytes.
uint32_t config
Some subset of OFPPC_* flags.
unsigned long long int tx_dropped
Counter of Tx dropped packets.
uint32_t state
Some subset of OFPPS_* flags.
State of the FlowStats request/reply.
ofp_flow_stats_request rq
Stats requests.
sw_table_position position
Table position.
State of the PortStats request/reply.
uint32_t * ports
Array of ports in network byte order.
uint32_t num_ports
Number of ports in host byte order.
Callback for a stats dump request.
ofp_stats_request * rq
Current stats request.
Stats * s
Handler of the stats request.
void * state
Stats request state data.
Ptr< OpenFlowSwitchNetDevice > swtch
The switch that we're requesting data from.
bool done
Whether we are done requesting stats.
Packet Metadata, allows us to track the packet's metadata as it passes through the switch.
Address src
Source Address of the Packet when the Packet is received.
uint16_t protocolNumber
Protocol type of the Packet when the Packet is received.
Address dst
Destination Address of the Packet when the Packet is received.
ofpbuf * buffer
The OpenFlow buffer as created from the Packet, with its data and headers.
Ptr< Packet > packet
The Packet itself.
Class for handling virtual port table actions.
static uint16_t Validate(ofp_vport_action_type type, size_t len, const ofp_action_header *ah)
Validates the action on whether its data is valid or not.
static void Execute(ofp_vport_action_type type, ofpbuf *buffer, const sw_flow_key *key, const ofp_action_header *ah)
Executes the action.
static bool IsValidType(ofp_vport_action_type type)