24 #ifndef OPENFLOW_SWITCH_NET_DEVICE_H
25 #define OPENFLOW_SWITCH_NET_DEVICE_H
27 #include "ns3/simulator.h"
29 #include "ns3/mac48-address.h"
31 #include "ns3/ethernet-header.h"
32 #include "ns3/arp-header.h"
33 #include "ns3/tcp-header.h"
34 #include "ns3/udp-header.h"
36 #include "ns3/ipv4-l3-protocol.h"
37 #include "ns3/arp-l3-protocol.h"
39 #include "ns3/bridge-channel.h"
42 #include "ns3/string.h"
43 #include "ns3/integer.h"
44 #include "ns3/uinteger.h"
148 int AddVPort (
const ofp_vport_mod *ovpm);
178 void DoOutput (uint32_t packet_uid,
int in_port,
size_t max_len,
int out_port,
bool ignore_no_fwd);
218 virtual void SetIfIndex (
const uint32_t index);
223 virtual bool SetMtu (
const uint16_t mtu);
224 virtual uint16_t
GetMtu (
void)
const;
286 int AddFlow (
const ofp_flow_mod *ofm);
296 int ModFlow (
const ofp_flow_mod *ofm);
308 int OutputAll (uint32_t packet_uid,
int in_port,
bool flood);
332 void OutputPort (uint32_t packet_uid,
int in_port,
int out_port,
bool ignore_no_fwd);
346 void OutputControl (uint32_t packet_uid,
int in_port,
size_t max_len,
int reason);
358 void SendErrorMsg (uint16_t type, uint16_t code,
const void *
data,
size_t len);
393 void SendFlowExpired (sw_flow *flow,
enum ofp_flow_expired_reason reason);
462 void FlowTableLookup (sw_flow_key key, ofpbuf* buffer, uint32_t packet_uid,
int port,
bool send_to_controller);
int ReceiveEchoRequest(const void *oh)
uint32_t GetNSwitchPorts(void) const
keep track of time values and allow control of global simulation resolution
uint32_t m_ifIndex
Interface Index.
vport_table_t GetVPortTable()
void ReceiveFromDevice(Ptr< NetDevice > netdev, Ptr< const Packet > packet, uint16_t protocol, const Address &src, const Address &dst, PacketType packetType)
void FlowTableLookup(sw_flow_key key, ofpbuf *buffer, uint32_t packet_uid, int port, bool send_to_controller)
ofpbuf * BufferFromPacket(Ptr< Packet > packet, Address src, Address dst, int mtu, uint16_t protocol)
virtual bool NeedsArp(void) const
int AddVPort(const ofp_vport_mod *ovpm)
Add a virtual port to a switch device.
static const char * GetSerialNumber()
int ReceiveGetConfigRequest(const void *msg)
uint16_t m_flags
Flags; configurable by the controller.
vport_table_t m_vportTable
Virtual Port Table.
virtual bool IsLinkUp(void) const
virtual void SetNode(Ptr< Node > node)
int ReceivePortMod(const void *msg)
virtual void SetIfIndex(const uint32_t index)
int RunThroughVPortTable(uint32_t packet_uid, int port, uint32_t vport)
ofi::Port GetSwitchPort(uint32_t n) const
void OutputControl(uint32_t packet_uid, int in_port, size_t max_len, int reason)
static const char * GetHardwareDescription()
Mac48Address m_address
Address of this device.
int OutputAll(uint32_t packet_uid, int in_port, bool flood)
int ReceiveFeaturesRequest(const void *msg)
int ReceivePacketOut(const void *msg)
virtual bool SupportsSendFrom() const
void SendPortStatus(ofi::Port p, uint8_t status)
int ReceiveStatsRequest(const void *oh)
int AddFlow(const ofp_flow_mod *ofm)
a polymophic address class
virtual bool SetMtu(const uint16_t mtu)
NetDevice::ReceiveCallback m_rxCallback
Callbacks.
void SendErrorMsg(uint16_t type, uint16_t code, const void *data, size_t len)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
int ModFlow(const ofp_flow_mod *ofm)
uint16_t m_mtu
Maximum Transmission Unit.
virtual void DoDispose(void)
int UpdatePortStatus(ofi::Port &p)
int GetSwitchPortIndex(ofi::Port p)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Ptr< Node > m_node
Node this device is installed on.
virtual uint16_t GetMtu(void) const
void StatsDone(ofi::StatsDumpCallback *cb_)
Stats callback is done.
void DoOutput(uint32_t packet_uid, int in_port, size_t max_len, int out_port, bool ignore_no_fwd)
Called from the OpenFlow Interface to output the Packet on either a Port or the Controller.
static TypeId GetTypeId(void)
void OutputPacket(uint32_t packet_uid, int out_port)
void RunThroughFlowTable(uint32_t packet_uid, int port, bool send_to_controller=true)
int ReceiveVPortTableFeaturesRequest(const void *msg)
void SendFlowExpired(sw_flow *flow, enum ofp_flow_expired_reason reason)
static const char * GetManufacturerDescription()
Time m_lastExecute
Last time the periodic execution occurred.
uint64_t m_id
Unique identifier for this switch, needed for OpenFlow.
void * MakeOpenflowReply(size_t openflow_len, uint8_t type, ofpbuf **bufferp)
int ForwardControlInput(const void *msg, size_t length)
The registered controller calls this method when sending a message to the switch. ...
PacketData_t m_packetData
Packet data.
int ReceiveFlow(const void *msg)
Callback for a stats dump request.
Ptr< BridgeChannel > m_channel
Collection of port channels into the Switch Channel.
static const char * GetSoftwareDescription()
sw_chain * m_chain
Flow Table; forwarding rules.
virtual void AddLinkChangeCallback(Callback< void > callback)
Ptr< ofi::Controller > m_controller
Connection to controller.
virtual Ptr< Channel > GetChannel(void) const
int ReceiveSetConfig(const void *msg)
OpenFlowSwitchNetDevice()
int StatsDump(ofi::StatsDumpCallback *cb_)
Stats callback is ready for a dump.
void OutputPort(uint32_t packet_uid, int in_port, int out_port, bool ignore_no_fwd)
virtual Address GetAddress(void) const
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
void SetController(Ptr< ofi::Controller > c)
Set up the Switch's controller connection.
virtual uint32_t GetIfIndex(void) const
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
virtual void SetAddress(Address address)
Network layer to device interface.
void FillPortDesc(ofi::Port p, ofp_phy_port *desc)
virtual bool IsBroadcast(void) const
int AddSwitchPort(Ptr< NetDevice > switchPort)
Add a 'port' to a switch device.
int ReceiveVPortMod(const void *msg)
virtual Ptr< Node > GetNode(void) const
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual Address GetBroadcast(void) const
virtual bool IsMulticast(void) const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
std::map< uint32_t, ofi::SwitchPacketMetadata > PacketData_t
void SendVPortTableFeatures()
a unique identifier for an interface.
uint16_t m_missSendLen
Flow Table Miss Send Length; configurable by the controller.
int ReceiveEchoReply(const void *oh)
A net device that switches multiple LAN segments via an OpenFlow-compatible flow table.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Ports_t m_ports
Switch's ports.
std::vector< ofi::Port > Ports_t
int SendOpenflowBuffer(ofpbuf *buffer)
Time m_lookupDelay
Flow Table Lookup Delay [overhead].
virtual ~OpenFlowSwitchNetDevice()