|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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"
186 void DoOutput (uint32_t packet_uid,
int in_port,
size_t max_len,
int out_port,
bool ignore_no_fwd);
230 virtual bool SetMtu (
const uint16_t mtu);
304 int OutputAll (uint32_t packet_uid,
int in_port,
bool flood);
324 void OutputPort (uint32_t packet_uid,
int in_port,
int out_port,
bool ignore_no_fwd);
336 void OutputControl (uint32_t packet_uid,
int in_port,
size_t max_len,
int reason);
434 void FlowTableLookup (sw_flow_key key, ofpbuf* buffer, uint32_t packet_uid,
int port,
bool send_to_controller);
a unique identifier for an interface.
virtual Address GetBroadcast(void) const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual Ptr< Channel > GetChannel(void) const
uint16_t m_flags
Flags; configurable by the controller.
Mac48Address m_address
Address of this device.
void SendPortStatus(ofi::Port p, uint8_t status)
Send a reply about a Port's status to the controller.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int AddVPort(const ofp_vport_mod *ovpm)
Add a virtual port to a switch device.
Time m_lastExecute
Last time the periodic execution occurred.
static const char * GetHardwareDescription()
virtual Ptr< Node > GetNode(void) const
void SendErrorMsg(uint16_t type, uint16_t code, const void *data, size_t len)
If an error message happened during the controller's request, send it to the controller.
A net device that switches multiple LAN segments via an OpenFlow-compatible flow table.
virtual void SetNode(Ptr< Node > node)
Ptr< BridgeChannel > m_channel
Collection of port channels into the Switch Channel.
void SendFeaturesReply()
Send a reply about this OpenFlow switch's features to the controller.
void SendFlowExpired(sw_flow *flow, enum ofp_flow_expired_reason reason)
Send a reply to the controller that a specific flow has expired.
int GetSwitchPortIndex(ofi::Port p)
virtual bool SupportsSendFrom() const
virtual ~OpenFlowSwitchNetDevice()
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
vport_table_t m_vportTable
Virtual Port Table.
Ptr< Node > m_node
Node this device is installed on.
Ipv4 addresses are stored in host order in this class.
static const char * GetSoftwareDescription()
Describes an IPv6 address.
void * MakeOpenflowReply(size_t openflow_len, uint8_t type, ofpbuf **bufferp)
Generates an OpenFlow reply message based on the type.
int ModFlow(const ofp_flow_mod *ofm)
Modify a flow.
void ReceiveFromDevice(Ptr< NetDevice > netdev, Ptr< const Packet > packet, uint16_t protocol, const Address &src, const Address &dst, PacketType packetType)
Called when a packet is received on one of the switch's ports.
virtual bool NeedsArp(void) const
vport_table_t GetVPortTable()
Time m_lookupDelay
Flow Table Lookup Delay [overhead].
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.
int ReceiveFeaturesRequest(const void *msg)
uint32_t GetNSwitchPorts(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
int OutputAll(uint32_t packet_uid, int in_port, bool flood)
Send packets out all the ports except the originating one.
void OutputPacket(uint32_t packet_uid, int out_port)
Sends a copy of the Packet over the provided output port.
virtual void DoDispose(void)
Destructor implementation.
uint16_t m_mtu
Maximum Transmission Unit.
int ReceiveStatsRequest(const void *oh)
NetDevice::ReceiveCallback m_rxCallback
Callbacks.
ofi::Port GetSwitchPort(uint32_t n) const
virtual bool SetMtu(const uint16_t mtu)
Smart pointer class similar to boost::intrusive_ptr.
int UpdatePortStatus(ofi::Port &p)
Update the port status field of the switch port.
virtual void SetIfIndex(const uint32_t index)
int RunThroughVPortTable(uint32_t packet_uid, int port, uint32_t vport)
Run the packet through the vport table.
void FillPortDesc(ofi::Port p, ofp_phy_port *desc)
Fill out a description of the switch port.
void StatsDone(ofi::StatsDumpCallback *cb_)
Stats callback is done.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
a polymophic address class
void RunThroughFlowTable(uint32_t packet_uid, int port, bool send_to_controller=true)
Run the packet through the flow table.
uint64_t m_id
Unique identifier for this switch, needed for OpenFlow.
virtual void SetAddress(Address address)
Set the address of this interface.
OpenFlowSwitchNetDevice()
sw_chain * m_chain
Flow Table; forwarding rules.
virtual uint32_t GetIfIndex(void) const
ofpbuf * BufferFromPacket(Ptr< const Packet > packet, Address src, Address dst, int mtu, uint16_t protocol)
Takes a packet and generates an OpenFlow buffer from it, loading the packet data as well as its heade...
Simulation virtual time values and global simulation resolution.
static TypeId GetTypeId(void)
Register this type.
int AddFlow(const ofp_flow_mod *ofm)
Add a flow.
int ForwardControlInput(const void *msg, size_t length)
The registered controller calls this method when sending a message to the switch.
virtual Address GetMulticast(Ipv6Address addr) const
Get the MAC multicast address corresponding to the IPv6 address provided.
int ReceivePacketOut(const void *msg)
int ReceiveSetConfig(const void *msg)
PacketData_t m_packetData
Packet data.
Ptr< ofi::Controller > m_controller
Connection to controller.
static const char * GetManufacturerDescription()
virtual bool IsMulticast(void) const
NetDevice::PromiscReceiveCallback m_promiscRxCallback
int ReceiveVPortTableFeaturesRequest(const void *msg)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
void SetController(Ptr< ofi::Controller > c)
Set up the Switch's controller connection.
virtual bool IsLinkUp(void) const
int StatsDump(ofi::StatsDumpCallback *cb_)
Stats callback is ready for a dump.
virtual bool IsBroadcast(void) const
virtual Address GetAddress(void) const
void FlowTableLookup(sw_flow_key key, ofpbuf *buffer, uint32_t packet_uid, int port, bool send_to_controller)
Called by RunThroughFlowTable on a scheduled delay to account for the flow table lookup overhead.
int SendOpenflowBuffer(ofpbuf *buffer)
Send a message to the controller.
std::map< uint32_t, ofi::SwitchPacketMetadata > PacketData_t
int ReceiveFlow(const void *msg)
int ReceiveEchoRequest(const void *oh)
static const char * GetSerialNumber()
int ReceiveVPortMod(const void *msg)
PacketType
Packet types are used as they are in Linux.
std::vector< ofi::Port > Ports_t
uint32_t m_ifIndex
Interface Index.
virtual void AddLinkChangeCallback(Callback< void > callback)
void OutputPort(uint32_t packet_uid, int in_port, int out_port, bool ignore_no_fwd)
Seeks to send out a Packet over the provided output port.
void SendVPortTableFeatures()
Send a reply about this OpenFlow switch's virtual port table features to the controller.
int ReceiveGetConfigRequest(const void *msg)
Ports_t m_ports
Switch's ports.
int AddSwitchPort(Ptr< NetDevice > switchPort)
Add a 'port' to a switch device.
void OutputControl(uint32_t packet_uid, int in_port, size_t max_len, int reason)
Sends a copy of the Packet to the controller.
uint16_t m_missSendLen
Flow Table Miss Send Length; configurable by the controller.
int ReceiveEchoReply(const void *oh)
Network layer to device interface.
virtual uint16_t GetMtu(void) const
Callback for a stats dump request.
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
int ReceivePortMod(const void *msg)