A net device that switches multiple LAN segments via an OpenFlow-compatible flow table. More...
#include "openflow-switch-net-device.h"
Public Member Functions | |
OpenFlowSwitchNetDevice () | |
~OpenFlowSwitchNetDevice () override | |
void | AddLinkChangeCallback (Callback< void > callback) override |
int | AddSwitchPort (Ptr< NetDevice > switchPort) |
Add a 'port' to a switch device. | |
int | AddVPort (const ofp_vport_mod *ovpm) |
Add a virtual port to a switch device. | |
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 | ForwardControlInput (const void *msg, size_t length) |
The registered controller calls this method when sending a message to the switch. | |
Address | GetAddress () const override |
Address | GetBroadcast () const override |
sw_chain * | GetChain () |
Ptr< Channel > | GetChannel () const override |
uint32_t | GetIfIndex () const override |
uint16_t | GetMtu () const override |
Address | GetMulticast (Ipv4Address multicastGroup) const override |
Make and return a MAC multicast address using the provided multicast group. | |
Address | GetMulticast (Ipv6Address addr) const override |
Get the MAC multicast address corresponding to the IPv6 address provided. | |
Ptr< Node > | GetNode () const override |
uint32_t | GetNSwitchPorts () const |
ofi::Port | GetSwitchPort (uint32_t n) const |
int | GetSwitchPortIndex (ofi::Port p) |
vport_table_t | GetVPortTable () |
bool | IsBridge () const override |
Return true if the net device is acting as a bridge. | |
bool | IsBroadcast () const override |
bool | IsLinkUp () const override |
bool | IsMulticast () const override |
bool | IsPointToPoint () const override |
Return true if the net device is on a point-to-point link. | |
bool | NeedsArp () const override |
bool | Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override |
bool | SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override |
void | SetAddress (Address address) override |
Set the address of this interface. | |
void | SetController (Ptr< ofi::Controller > c) |
Set up the Switch's controller connection. | |
void | SetIfIndex (const uint32_t index) override |
bool | SetMtu (const uint16_t mtu) override |
void | SetNode (Ptr< Node > node) override |
void | SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) override |
void | SetReceiveCallback (NetDevice::ReceiveCallback cb) override |
void | StatsDone (ofi::StatsDumpCallback *cb_) |
Stats callback is done. | |
int | StatsDump (ofi::StatsDumpCallback *cb_) |
Stats callback is ready for a dump. | |
bool | SupportsSendFrom () const override |
Public Member Functions inherited from ns3::NetDevice | |
~NetDevice () override | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. | |
bool | IsInitialized () const |
Check if the object has been initialized. | |
void | UnidirectionalAggregateObject (Ptr< Object > other) |
Aggregate an Object to another Object. | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. | |
void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Register this type. | |
Descriptive Data | |
OpenFlowSwitchNetDevice Description Data These four data describe the OpenFlowSwitchNetDevice as if it were a real OpenFlow switch. There is a type of stats request that OpenFlow switches are supposed to handle that returns the description of the OpenFlow switch. Currently manufactured by "The ns-3 team", software description is "Simulated OpenFlow Switch", and the other two are "N/A". | |
static const char * | GetManufacturerDescription () |
static const char * | GetHardwareDescription () |
static const char * | GetSoftwareDescription () |
static const char * | GetSerialNumber () |
Static Public Member Functions inherited from ns3::NetDevice | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Protected Member Functions | |
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 headers. | |
void | DoDispose () override |
Destructor implementation. | |
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. | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | DoInitialize () |
Initialize() implementation. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Private Types | |
typedef std::map< uint32_t, ofi::SwitchPacketMetadata > | PacketData_t |
PacketData type. | |
typedef std::vector< ofi::Port > | Ports_t |
Switch's port type. | |
Private Member Functions | |
int | AddFlow (const ofp_flow_mod *ofm) |
Add a flow. | |
void | FillPortDesc (ofi::Port p, ofp_phy_port *desc) |
Fill out a description of the switch port. | |
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. | |
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. | |
int | OutputAll (uint32_t packet_uid, int in_port, bool flood) |
Send packets out all the ports except the originating one. | |
void | OutputControl (uint32_t packet_uid, int in_port, size_t max_len, int reason) |
Sends a copy of the Packet to the controller. | |
void | OutputPacket (uint32_t packet_uid, int out_port) |
Sends a copy of the Packet over the provided output port. | |
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 | RunThroughFlowTable (uint32_t packet_uid, int port, bool send_to_controller=true) |
Run the packet through the flow table. | |
int | RunThroughVPortTable (uint32_t packet_uid, int port, uint32_t vport) |
Run the packet through the vport table. | |
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. | |
void | SendFeaturesReply () |
Send a reply about this OpenFlow switch's features to the controller. | |
void | SendFlowExpired (sw_flow *flow, ofp_flow_expired_reason reason) |
Send a reply to the controller that a specific flow has expired. | |
int | SendOpenflowBuffer (ofpbuf *buffer) |
Send a message to the controller. | |
void | SendPortStatus (ofi::Port p, uint8_t status) |
Send a reply about a Port's status to the controller. | |
void | SendVPortTableFeatures () |
Send a reply about this OpenFlow switch's virtual port table features to the controller. | |
int | UpdatePortStatus (ofi::Port &p) |
Update the port status field of the switch port. | |
Receive Methods | |
Actions to do when a specific OpenFlow message/packet is received | |
int | ReceivePortMod (const void *msg) |
int | ReceiveFeaturesRequest (const void *msg) |
int | ReceiveGetConfigRequest (const void *msg) |
int | ReceiveSetConfig (const void *msg) |
int | ReceivePacketOut (const void *msg) |
int | ReceiveFlow (const void *msg) |
int | ReceiveStatsRequest (const void *msg) |
int | ReceiveEchoRequest (const void *msg) |
int | ReceiveEchoReply (const void *msg) |
int | ReceiveVPortMod (const void *msg) |
int | ReceiveVPortTableFeaturesRequest (const void *msg) |
Private Attributes | |
Mac48Address | m_address |
Address of this device. | |
sw_chain * | m_chain |
Flow Table; forwarding rules. | |
Ptr< BridgeChannel > | m_channel |
Collection of port channels into the Switch Channel. | |
Ptr< ofi::Controller > | m_controller |
Connection to controller. | |
uint16_t | m_flags |
Flags; configurable by the controller. | |
uint64_t | m_id |
Unique identifier for this switch, needed for OpenFlow. | |
uint32_t | m_ifIndex |
Interface Index. | |
Time | m_lastExecute |
Last time the periodic execution occurred. | |
Time | m_lookupDelay |
Flow Table Lookup Delay [overhead]. | |
uint16_t | m_missSendLen |
Flow Table Miss Send Length; configurable by the controller. | |
uint16_t | m_mtu |
Maximum Transmission Unit. | |
Ptr< Node > | m_node |
Node this device is installed on. | |
PacketData_t | m_packetData |
Packet data. | |
Ports_t | m_ports |
Switch's ports. | |
NetDevice::PromiscReceiveCallback | m_promiscRxCallback |
Promiscuous Rx Callback. | |
NetDevice::ReceiveCallback | m_rxCallback |
Rx Callback. | |
vport_table_t | m_vportTable |
Virtual Port Table. | |
Additional Inherited Members | |
Public Types inherited from ns3::NetDevice | |
typedef void(* | LinkChangeTracedCallback) () |
TracedCallback signature for link changed event. | |
enum | PacketType { PACKET_HOST = 1 , NS3_PACKET_HOST = PACKET_HOST , PACKET_BROADCAST , NS3_PACKET_BROADCAST = PACKET_BROADCAST , PACKET_MULTICAST , NS3_PACKET_MULTICAST = PACKET_MULTICAST , PACKET_OTHERHOST , NS3_PACKET_OTHERHOST = PACKET_OTHERHOST } |
Packet types are used as they are in Linux. More... | |
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketType > | PromiscReceiveCallback |
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > | ReceiveCallback |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
A net device that switches multiple LAN segments via an OpenFlow-compatible flow table.
Definition at line 79 of file openflow-switch-net-device.h.
|
private |
PacketData type.
Definition at line 520 of file openflow-switch-net-device.h.
|
private |
Switch's port type.
Definition at line 524 of file openflow-switch-net-device.h.
ns3::OpenFlowSwitchNetDevice::OpenFlowSwitchNetDevice | ( | ) |
Definition at line 94 of file openflow-switch-net-device.cc.
References ns3::CreateObject(), m_chain, m_channel, m_controller, m_ports, m_vportTable, NS_LOG_ERROR, and NS_LOG_FUNCTION_NOARGS.
|
override |
Definition at line 119 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Add a flow.
Possible error numbers: ENOMEM, ENOBUFS, ESRCH
ofm | The flow data to add. |
Definition at line 1313 of file openflow-switch-net-device.cc.
References discard_buffer(), ns3::ofi::ExecuteActions(), m_chain, NS_LOG_INFO, retrieve_buffer(), SendErrorMsg(), and ns3::ofi::ValidateActions().
Referenced by ReceiveFlow().
|
overridevirtual |
callback | the callback to invoke |
Add a callback invoked whenever the link status changes to UP. This callback is typically used by the IP/ARP layer to flush the ARP cache and by IPv6 stack to flush NDISC cache whenever the link goes up.
Implements ns3::NetDevice.
Definition at line 260 of file openflow-switch-net-device.cc.
Add a 'port' to a switch device.
This method adds a new switch port to a OpenFlowSwitchNetDevice, so that the new switch port NetDevice becomes part of the switch and L2 frames start being forwarded to/from this NetDevice.
switchPort | The port to add. |
Definition at line 159 of file openflow-switch-net-device.cc.
References ns3::ofi::Port::config, ns3::Mac48Address::ConvertFrom(), ns3::Mac48Address::IsMatchingType(), m_address, m_channel, m_node, m_ports, ns3::MakeCallback(), ns3::ofi::Port::netdev, NS_ASSERT, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, ReceiveFromDevice(), ns3::Node::RegisterProtocolHandler(), and SendPortStatus().
int ns3::OpenFlowSwitchNetDevice::AddVPort | ( | const ofp_vport_mod * | ovpm | ) |
Add a virtual port to a switch device.
The Ericsson OFSID has the concept of virtual ports and virtual port tables. These are implemented in the OpenFlowSwitchNetDevice, but don't have an understood use [perhaps it may have to do with MPLS integration].
Possible error numbers: EINVAL
ovpm | The data for adding a virtual port. |
Definition at line 406 of file openflow-switch-net-device.cc.
References m_vportTable, NS_LOG_ERROR, SendErrorMsg(), and ns3::ofi::ValidateVPortActions().
Referenced by ReceiveVPortMod().
|
protected |
Takes a packet and generates an OpenFlow buffer from it, loading the packet data as well as its headers.
packet | The packet. |
src | The source address. |
dst | The destination address. |
mtu | The Maximum Transmission Unit. |
protocol | The protocol defining the packet. |
Definition at line 455 of file openflow-switch-net-device.cc.
References ns3::Address::CopyTo(), ns3::Ipv4Address::Get(), ns3::TcpHeader::GetAckNumber(), ns3::Ipv4Header::GetDestination(), ns3::ArpHeader::GetDestinationHardwareAddress(), ns3::ArpHeader::GetDestinationIpv4Address(), ns3::TcpHeader::GetDestinationPort(), ns3::UdpHeader::GetDestinationPort(), ns3::TcpHeader::GetFlags(), ns3::Ipv4Header::GetFragmentOffset(), ns3::Ipv4Header::GetIdentification(), ns3::Ipv4Header::GetProtocol(), ns3::TcpHeader::GetSequenceNumber(), ns3::Ipv4Header::GetSource(), ns3::ArpHeader::GetSourceHardwareAddress(), ns3::ArpHeader::GetSourceIpv4Address(), ns3::TcpHeader::GetSourcePort(), ns3::UdpHeader::GetSourcePort(), ns3::Ipv4Header::GetTos(), ns3::Ipv4Header::GetTtl(), ns3::TcpHeader::GetUrgentPointer(), ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::GetValue(), ns3::TcpHeader::GetWindowSize(), ns3::ArpHeader::m_type, NS_LOG_INFO, NS_LOG_WARN, ns3::ArpL3Protocol::PROT_NUMBER, ns3::Ipv4L3Protocol::PROT_NUMBER, ns3::TcpL4Protocol::PROT_NUMBER, and ns3::UdpL4Protocol::PROT_NUMBER.
Referenced by ReceiveFromDevice(), and SendFrom().
|
overrideprotectedvirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.
It is safe to call GetObject() from within this method.
Reimplemented from ns3::Object.
Definition at line 125 of file openflow-switch-net-device.cc.
References ns3::Object::DoDispose(), m_chain, m_channel, m_controller, m_node, m_ports, m_vportTable, NS_LOG_FUNCTION_NOARGS, and SendPortStatus().
void ns3::OpenFlowSwitchNetDevice::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.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
in_port | The index of the port the Packet was initially received on. |
max_len | The maximum number of bytes the caller wants to be sent; a value of 0 indicates the entire packet should be sent. Used when outputting to controller. |
out_port | The port we want to output on. |
ignore_no_fwd | If true, Ports that are set to not forward are forced to forward. |
Definition at line 308 of file openflow-switch-net-device.cc.
References OutputControl(), and OutputPort().
|
private |
Fill out a description of the switch port.
p | The port to get the description from. |
desc | A pointer to the description message; used to fill the description message with the data from the port. |
Definition at line 889 of file openflow-switch-net-device.cc.
References ns3::ofi::Port::config, GetSwitchPortIndex(), ns3::ofi::Port::netdev, and ns3::ofi::Port::state.
Referenced by SendFeaturesReply(), and SendPortStatus().
|
private |
Called by RunThroughFlowTable on a scheduled delay to account for the flow table lookup overhead.
key | Matching key to look up in the flow table. |
buffer | Buffer of the packet received. |
packet_uid | Packet UID; used to fetch the packet and its metadata. |
port | The port the packet was received over. |
send_to_controller |
Definition at line 1010 of file openflow-switch-net-device.cc.
References discard_buffer(), ns3::ofi::ExecuteActions(), m_chain, m_missSendLen, m_packetData, NS_LOG_INFO, OutputControl(), and port.
Referenced by RunThroughFlowTable().
int ns3::OpenFlowSwitchNetDevice::ForwardControlInput | ( | const void * | msg, |
size_t | length ) |
The registered controller calls this method when sending a message to the switch.
msg | The message received from the controller. |
length | Length of the message. |
Definition at line 1593 of file openflow-switch-net-device.cc.
References ReceiveEchoReply(), ReceiveEchoRequest(), ReceiveFeaturesRequest(), ReceiveFlow(), ReceiveGetConfigRequest(), ReceivePacketOut(), ReceivePortMod(), ReceiveSetConfig(), ReceiveStatsRequest(), ReceiveVPortMod(), ReceiveVPortTableFeaturesRequest(), and SendErrorMsg().
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 231 of file openflow-switch-net-device.cc.
References m_address, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Calling this method is invalid if IsBroadcast returns not true.
Implements ns3::NetDevice.
Definition at line 272 of file openflow-switch-net-device.cc.
References ns3::Mac48Address::GetBroadcast(), and NS_LOG_FUNCTION_NOARGS.
sw_chain * ns3::OpenFlowSwitchNetDevice::GetChain | ( | ) |
Definition at line 1657 of file openflow-switch-net-device.cc.
References m_chain.
Implements ns3::NetDevice.
Definition at line 217 of file openflow-switch-net-device.cc.
References m_channel, and NS_LOG_FUNCTION_NOARGS.
|
static |
Definition at line 39 of file openflow-switch-net-device.cc.
Referenced by ns3::ofi::Stats::DescStatsDump().
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 210 of file openflow-switch-net-device.cc.
References m_ifIndex, and NS_LOG_FUNCTION_NOARGS.
|
static |
Definition at line 33 of file openflow-switch-net-device.cc.
Referenced by ns3::ofi::Stats::DescStatsDump().
|
overridevirtual |
This value is typically used by the IP layer to perform IP fragmentation when needed.
Implements ns3::NetDevice.
Definition at line 246 of file openflow-switch-net-device.cc.
References m_mtu, and NS_LOG_FUNCTION_NOARGS.
Referenced by SendFrom().
|
overridevirtual |
Make and return a MAC multicast address using the provided multicast group.
RFC 1112 says that an Ipv4 host group address is mapped to an Ethernet multicast address by placing the low-order 23-bits of the IP address into the low-order 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex). Similar RFCs exist for Ipv6 and Eui64 mappings. This method performs the multicast address creation function appropriate to the underlying MAC address of the device. This MAC address is encapsulated in an abstract Address to avoid dependencies on the exact MAC address format.
In the case of net devices that do not support multicast, clients are expected to test NetDevice::IsMulticast and avoid attempting to map multicast packets. Subclasses of NetDevice that do support multicasting are expected to override this method and provide an implementation appropriate to the particular device.
multicastGroup | The IP address for the multicast group destination of the packet. |
Implements ns3::NetDevice.
Definition at line 286 of file openflow-switch-net-device.cc.
References ns3::Mac48Address::GetMulticast(), and NS_LOG_FUNCTION.
|
overridevirtual |
Get the MAC multicast address corresponding to the IPv6 address provided.
addr | IPv6 address |
Implements ns3::NetDevice.
Definition at line 398 of file openflow-switch-net-device.cc.
References ns3::Mac48Address::GetMulticast(), and NS_LOG_FUNCTION.
When a subclass needs to get access to the underlying node base class to print the nodeid for example, it can invoke this method.
Implements ns3::NetDevice.
Definition at line 356 of file openflow-switch-net-device.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
uint32_t ns3::OpenFlowSwitchNetDevice::GetNSwitchPorts | ( | ) | const |
Definition at line 1663 of file openflow-switch-net-device.cc.
References m_ports, and NS_LOG_FUNCTION_NOARGS.
|
static |
Definition at line 51 of file openflow-switch-net-device.cc.
Referenced by ns3::ofi::Stats::DescStatsDump().
|
static |
Definition at line 45 of file openflow-switch-net-device.cc.
Referenced by ns3::ofi::Stats::DescStatsDump().
n | index of the Port. |
Definition at line 1670 of file openflow-switch-net-device.cc.
References m_ports, and NS_LOG_FUNCTION_NOARGS.
int ns3::OpenFlowSwitchNetDevice::GetSwitchPortIndex | ( | ofi::Port | p | ) |
p | The Port to get the index of. |
Definition at line 1677 of file openflow-switch-net-device.cc.
References m_ports, and ns3::ofi::Port::netdev.
Referenced by FillPortDesc().
|
static |
Register this type.
Definition at line 57 of file openflow-switch-net-device.cc.
References ns3::GenerateId(), m_flags, m_id, m_lookupDelay, m_missSendLen, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), ns3::NanoSeconds(), and ns3::TypeId::SetParent().
vport_table_t ns3::OpenFlowSwitchNetDevice::GetVPortTable | ( | ) |
Definition at line 1690 of file openflow-switch-net-device.cc.
References m_vportTable.
|
overridevirtual |
Return true if the net device is acting as a bridge.
Implements ns3::NetDevice.
Definition at line 301 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 265 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 253 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 279 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Return true if the net device is on a point-to-point link.
Implements ns3::NetDevice.
Definition at line 294 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Generates an OpenFlow reply message based on the type.
openflow_len | Length of the reply to make. |
type | Type of reply message to make. |
bufferp | Message buffer; used to make the reply. |
Definition at line 845 of file openflow-switch-net-device.cc.
Referenced by ReceiveGetConfigRequest(), SendErrorMsg(), SendFeaturesReply(), SendFlowExpired(), SendPortStatus(), SendVPortTableFeatures(), and StatsDump().
|
private |
Modify a flow.
ofm | The flow data to modify. |
Definition at line 1400 of file openflow-switch-net-device.cc.
References discard_buffer(), ns3::ofi::ExecuteActions(), m_chain, retrieve_buffer(), SendErrorMsg(), and ns3::ofi::ValidateActions().
Referenced by ReceiveFlow().
|
overridevirtual |
Called by higher-layers to check if this NetDevice requires ARP to be used.
Implements ns3::NetDevice.
Definition at line 370 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Send packets out all the ports except the originating one.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
in_port | The index of the port the Packet was initially received on. This port doesn't forward when flooding. |
flood | If true, don't send out on the ports with flooding disabled. |
Definition at line 736 of file openflow-switch-net-device.cc.
References m_ports, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, and OutputPort().
Referenced by OutputPort().
|
private |
Sends a copy of the Packet to the controller.
If the packet can be saved in an OpenFlow buffer, then only the first 'max_len' bytes of the packet are sent; otherwise, all of the packet is sent.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
in_port | The index of the port the Packet was initially received on. |
max_len | The maximum number of bytes that the caller wants to be sent; a value of 0 indicates the entire packet should be sent. |
reason | Why the packet is being sent. |
Definition at line 863 of file openflow-switch-net-device.cc.
References data, m_packetData, NS_LOG_INFO, and SendOpenflowBuffer().
Referenced by DoOutput(), FlowTableLookup(), and OutputPort().
|
private |
Sends a copy of the Packet over the provided output port.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
out_port | Output port. |
Definition at line 767 of file openflow-switch-net-device.cc.
References ns3::ofi::Port::config, data, m_packetData, m_ports, ns3::ofi::Port::netdev, NS_LOG_DEBUG, NS_LOG_INFO, ns3::ofi::Port::tx_bytes, ns3::ofi::Port::tx_dropped, and ns3::ofi::Port::tx_packets.
Referenced by OutputPort().
|
private |
Seeks to send out a Packet over the provided output port.
This is called generically when we may or may not know the specific port we're outputting on. There are many pre-set types of port options besides a Port that's hooked to our OpenFlowSwitchNetDevice. For example, it could be outputting as a flood, or seeking to output to the controller.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
in_port | The index of the port the Packet was initially received on. |
out_port | The port we want to output on. |
ignore_no_fwd | If true, Ports that are set to not forward are forced to forward. |
Definition at line 794 of file openflow-switch-net-device.cc.
References NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, OutputAll(), OutputControl(), OutputPacket(), RunThroughFlowTable(), and RunThroughVPortTable().
Referenced by DoOutput(), OutputAll(), and RunThroughVPortTable().
|
private |
msg | The OpenFlow message received. |
Definition at line 1587 of file openflow-switch-net-device.cc.
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1581 of file openflow-switch-net-device.cc.
References SendOpenflowBuffer().
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1201 of file openflow-switch-net-device.cc.
References SendFeaturesReply().
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1449 of file openflow-switch-net-device.cc.
References AddFlow(), m_chain, ModFlow(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ForwardControlInput().
|
protected |
Called when a packet is received on one of the switch's ports.
netdev | The port the packet was received on. |
packet | The Packet itself. |
protocol | The protocol defining the Packet. |
src | The source address of the Packet. |
dst | The destination address of the Packet. |
packetType | Type of the packet. |
Definition at line 624 of file openflow-switch-net-device.cc.
References BufferFromPacket(), ns3::Mac48Address::ConvertFrom(), data, ns3::Time::GetSeconds(), ns3::Callback< R, UArgs >::IsNull(), m_address, m_chain, m_lastExecute, m_packetData, m_ports, m_promiscRxCallback, m_rxCallback, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, ns3::NetDevice::PACKET_BROADCAST, ns3::NetDevice::PACKET_HOST, ns3::NetDevice::PACKET_MULTICAST, ns3::NetDevice::PACKET_OTHERHOST, RunThroughFlowTable(), save_buffer(), ns3::Seconds(), SendFlowExpired(), SendPortStatus(), and UpdatePortStatus().
Referenced by AddSwitchPort().
|
private |
msg | The OpenFlow message received. |
Definition at line 1215 of file openflow-switch-net-device.cc.
References m_flags, m_missSendLen, MakeOpenflowReply(), and SendOpenflowBuffer().
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1244 of file openflow-switch-net-device.cc.
References ns3::ofi::ExecuteActions(), NS_LOG_DEBUG, retrieve_buffer(), SendErrorMsg(), and ns3::ofi::ValidateActions().
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1158 of file openflow-switch-net-device.cc.
References ns3::ofi::Port::config, ns3::Mac48Address::CopyFrom(), m_ports, ns3::ofi::Port::netdev, and port.
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1227 of file openflow-switch-net-device.cc.
References m_flags, and m_missSendLen.
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1535 of file openflow-switch-net-device.cc.
References ns3::ofi::Stats::DoInit(), ns3::ofi::StatsDumpCallback::done, m_controller, NS_LOG_ERROR, NS_LOG_WARN, ns3::ofi::StatsDumpCallback::rq, ns3::ofi::StatsDumpCallback::s, ns3::ofi::StatsDumpCallback::state, and ns3::ofi::StatsDumpCallback::swtch.
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1289 of file openflow-switch-net-device.cc.
References AddVPort(), m_vportTable, and SendErrorMsg().
Referenced by ForwardControlInput().
|
private |
msg | The OpenFlow message received. |
Definition at line 1208 of file openflow-switch-net-device.cc.
References SendVPortTableFeatures().
Referenced by ForwardControlInput().
|
private |
Run the packet through the flow table.
Looks up in the flow table for a match. If it doesn't match, it forwards the packet to the registered controller, if the flag is set.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
port | The port this packet was received over. |
send_to_controller | If set, sends to the controller if the packet isn't matched. |
Definition at line 1046 of file openflow-switch-net-device.cc.
References data, FlowTableLookup(), m_flags, m_lookupDelay, m_packetData, m_ports, NS_LOG_INFO, port, and ns3::Simulator::Schedule().
Referenced by OutputPort(), ReceiveFromDevice(), and SendFrom().
|
private |
Run the packet through the vport table.
As with AddVPort, this doesn't have an understood use yet.
packet_uid | Packet UID; used to fetch the packet and its metadata. |
port | The port this packet was received over. |
vport | The virtual port this packet identifies itself by. |
Definition at line 1102 of file openflow-switch-net-device.cc.
References ns3::ofi::ExecuteVPortActions(), m_flags, m_packetData, m_vportTable, NS_LOG_ERROR, OutputPort(), and port.
Referenced by OutputPort().
|
overridevirtual |
packet | packet sent from above down to Network Device |
dest | mac address of the destination (already resolved) |
protocolNumber | identifies the type of payload contained in this packet. Used to call the right L3Protocol when the packet is received. |
Called from higher layer to send packet into Network Device to the specified destination Address
Implements ns3::NetDevice.
Definition at line 325 of file openflow-switch-net-device.cc.
References m_address, NS_LOG_FUNCTION_NOARGS, and SendFrom().
|
private |
If an error message happened during the controller's request, send it to the controller.
type | The type of error. |
code | The error code. |
data | The faulty data that lead to the error. |
len | The length of the faulty data. |
Definition at line 999 of file openflow-switch-net-device.cc.
References data, MakeOpenflowReply(), and SendOpenflowBuffer().
Referenced by AddFlow(), AddVPort(), ForwardControlInput(), ModFlow(), ReceivePacketOut(), and ReceiveVPortMod().
|
private |
Send a reply about this OpenFlow switch's features to the controller.
List of capabilities and actions to support are found in the specification <www.openflowswitch.org/documents/openflow-spec-v0.8.9.pdf>.
Supported capabilities and actions are defined in the openflow interface. To recap, flow status, flow table status, port status, virtual port table status can all be requested. It can also transmit over multiple physical interfaces.
It supports every action: outputting over a port, and all of the flow table manipulation actions: setting the 802.1q VLAN ID, the 802.1q priority, stripping the 802.1 header, setting the Ethernet source address and destination, setting the IP source address and destination, setting the TCP/UDP source address and destination, and setting the MPLS label and EXP bits.
Definition at line 909 of file openflow-switch-net-device.cc.
References FillPortDesc(), m_chain, m_id, m_ports, MakeOpenflowReply(), N_PKT_BUFFERS, OFP_SUPPORTED_ACTIONS, OFP_SUPPORTED_CAPABILITIES, and SendOpenflowBuffer().
Referenced by ReceiveFeaturesRequest().
|
private |
Send a reply to the controller that a specific flow has expired.
flow | The flow that expired. |
reason | The reason for sending this expiration notification. |
Definition at line 980 of file openflow-switch-net-device.cc.
References MakeOpenflowReply(), and SendOpenflowBuffer().
Referenced by ReceiveFromDevice().
|
overridevirtual |
packet | packet sent from above down to Network Device |
source | source mac address (so called "MAC spoofing") |
dest | mac address of the destination (already resolved) |
protocolNumber | identifies the type of payload contained in this packet. Used to call the right L3Protocol when the packet is received. |
Called from higher layer to send packet into Network Device with the specified source and destination Addresses.
Implements ns3::NetDevice.
Definition at line 332 of file openflow-switch-net-device.cc.
References BufferFromPacket(), data, GetMtu(), m_packetData, NS_LOG_FUNCTION_NOARGS, RunThroughFlowTable(), and save_buffer().
Referenced by Send().
|
private |
Send a message to the controller.
This method is the key to communicating with the controller, it does the actual sending. The other Send methods call this one when they are ready to send a message.
buffer | Buffer of the message to send out. |
Definition at line 851 of file openflow-switch-net-device.cc.
References m_controller.
Referenced by OutputControl(), ReceiveEchoRequest(), ReceiveGetConfigRequest(), SendErrorMsg(), SendFeaturesReply(), SendFlowExpired(), SendPortStatus(), SendVPortTableFeatures(), and StatsDump().
|
private |
Send a reply about a Port's status to the controller.
p | The port to get status from. |
status | The reason for sending this reply. |
Definition at line 966 of file openflow-switch-net-device.cc.
References FillPortDesc(), MakeOpenflowReply(), and SendOpenflowBuffer().
Referenced by AddSwitchPort(), DoDispose(), and ReceiveFromDevice().
|
private |
Send a reply about this OpenFlow switch's virtual port table features to the controller.
Definition at line 930 of file openflow-switch-net-device.cc.
References m_vportTable, MakeOpenflowReply(), OFP_SUPPORTED_VPORT_TABLE_ACTIONS, and SendOpenflowBuffer().
Referenced by ReceiveVPortTableFeaturesRequest().
|
overridevirtual |
Set the address of this interface.
address | address to set |
Implements ns3::NetDevice.
Definition at line 224 of file openflow-switch-net-device.cc.
References ns3::Mac48Address::ConvertFrom(), m_address, and NS_LOG_FUNCTION_NOARGS.
void ns3::OpenFlowSwitchNetDevice::SetController | ( | Ptr< ofi::Controller > | c | ) |
Set up the Switch's controller connection.
c | Pointer to a Controller. |
Definition at line 146 of file openflow-switch-net-device.cc.
References m_controller, and NS_LOG_ERROR.
|
overridevirtual |
index | ifIndex of the device |
Implements ns3::NetDevice.
Definition at line 203 of file openflow-switch-net-device.cc.
References m_ifIndex, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
mtu | MTU value, in bytes, to set for the device |
Override for default MTU defined on a per-type basis.
Implements ns3::NetDevice.
Definition at line 238 of file openflow-switch-net-device.cc.
References m_mtu, and NS_LOG_FUNCTION_NOARGS.
node | the node associated to this netdevice. |
This method is called from ns3::Node::AddDevice.
Implements ns3::NetDevice.
Definition at line 363 of file openflow-switch-net-device.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
cb | callback to invoke whenever a packet has been received in promiscuous mode and must be forwarded to the higher layers. |
Enables netdevice promiscuous mode and sets the callback that will handle promiscuous mode packets. Note, promiscuous mode packets means all packets, including those packets that can be sensed by the netdevice but which are intended to be received by other hosts.
Implements ns3::NetDevice.
Definition at line 384 of file openflow-switch-net-device.cc.
References m_promiscRxCallback, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
cb | callback to invoke whenever a packet has been received and must be forwarded to the higher layers. |
Set the callback to be used to notify higher layers when a packet has been received.
Implements ns3::NetDevice.
Definition at line 377 of file openflow-switch-net-device.cc.
References m_rxCallback, and NS_LOG_FUNCTION_NOARGS.
void ns3::OpenFlowSwitchNetDevice::StatsDone | ( | ofi::StatsDumpCallback * | cb_ | ) |
Stats callback is done.
Controllers have a callback system for status requests which calls this function.
cb_ | The callback data. |
Definition at line 1524 of file openflow-switch-net-device.cc.
References ns3::ofi::Stats::DoCleanup(), ns3::ofi::StatsDumpCallback::s, and ns3::ofi::StatsDumpCallback::state.
Referenced by ns3::ofi::Controller::StartDump().
int ns3::OpenFlowSwitchNetDevice::StatsDump | ( | ofi::StatsDumpCallback * | cb_ | ) |
Stats callback is ready for a dump.
Controllers have a callback system for status requests which calls this function.
cb_ | The callback data. |
Definition at line 1484 of file openflow-switch-net-device.cc.
References ns3::ofi::Stats::DoDump(), ns3::ofi::StatsDumpCallback::done, MakeOpenflowReply(), ns3::ofi::StatsDumpCallback::s, SendOpenflowBuffer(), ns3::ofi::StatsDumpCallback::state, and ns3::ofi::Stats::type.
Referenced by ns3::ofi::Controller::StartDump().
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 391 of file openflow-switch-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Update the port status field of the switch port.
A non-zero return value indicates some field has changed.
p | A reference to a Port; used to change its config and flag fields. |
Definition at line 945 of file openflow-switch-net-device.cc.
References ns3::ofi::Port::config, ns3::ofi::Port::netdev, and ns3::ofi::Port::state.
Referenced by ReceiveFromDevice().
|
private |
Address of this device.
Definition at line 513 of file openflow-switch-net-device.h.
Referenced by AddSwitchPort(), GetAddress(), ReceiveFromDevice(), Send(), and SetAddress().
|
private |
Flow Table; forwarding rules.
Definition at line 536 of file openflow-switch-net-device.h.
Referenced by OpenFlowSwitchNetDevice(), AddFlow(), DoDispose(), FlowTableLookup(), GetChain(), ModFlow(), ReceiveFlow(), ReceiveFromDevice(), and SendFeaturesReply().
|
private |
Collection of port channels into the Switch Channel.
Definition at line 515 of file openflow-switch-net-device.h.
Referenced by OpenFlowSwitchNetDevice(), AddSwitchPort(), DoDispose(), and GetChannel().
|
private |
Connection to controller.
Definition at line 527 of file openflow-switch-net-device.h.
Referenced by OpenFlowSwitchNetDevice(), DoDispose(), ReceiveStatsRequest(), SendOpenflowBuffer(), and SetController().
|
private |
Flags; configurable by the controller.
Definition at line 533 of file openflow-switch-net-device.h.
Referenced by GetTypeId(), ReceiveGetConfigRequest(), ReceiveSetConfig(), RunThroughFlowTable(), and RunThroughVPortTable().
|
private |
Unique identifier for this switch, needed for OpenFlow.
Definition at line 529 of file openflow-switch-net-device.h.
Referenced by GetTypeId(), and SendFeaturesReply().
|
private |
Interface Index.
Definition at line 516 of file openflow-switch-net-device.h.
Referenced by GetIfIndex(), and SetIfIndex().
|
private |
Last time the periodic execution occurred.
Definition at line 532 of file openflow-switch-net-device.h.
Referenced by ReceiveFromDevice().
|
private |
Flow Table Lookup Delay [overhead].
Definition at line 530 of file openflow-switch-net-device.h.
Referenced by GetTypeId(), and RunThroughFlowTable().
|
private |
Flow Table Miss Send Length; configurable by the controller.
Definition at line 534 of file openflow-switch-net-device.h.
Referenced by FlowTableLookup(), GetTypeId(), ReceiveGetConfigRequest(), and ReceiveSetConfig().
|
private |
Maximum Transmission Unit.
Definition at line 517 of file openflow-switch-net-device.h.
Node this device is installed on.
Definition at line 514 of file openflow-switch-net-device.h.
Referenced by AddSwitchPort(), DoDispose(), GetNode(), and SetNode().
|
private |
Packet data.
Definition at line 521 of file openflow-switch-net-device.h.
Referenced by FlowTableLookup(), OutputControl(), OutputPacket(), ReceiveFromDevice(), RunThroughFlowTable(), RunThroughVPortTable(), and SendFrom().
|
private |
Switch's ports.
Definition at line 525 of file openflow-switch-net-device.h.
Referenced by OpenFlowSwitchNetDevice(), AddSwitchPort(), DoDispose(), GetNSwitchPorts(), GetSwitchPort(), GetSwitchPortIndex(), OutputAll(), OutputPacket(), ReceiveFromDevice(), ReceivePortMod(), RunThroughFlowTable(), and SendFeaturesReply().
|
private |
Promiscuous Rx Callback.
Definition at line 511 of file openflow-switch-net-device.h.
Referenced by ReceiveFromDevice(), and SetPromiscReceiveCallback().
|
private |
Rx Callback.
Definition at line 509 of file openflow-switch-net-device.h.
Referenced by ReceiveFromDevice(), and SetReceiveCallback().
|
private |
Virtual Port Table.
Definition at line 537 of file openflow-switch-net-device.h.
Referenced by OpenFlowSwitchNetDevice(), AddVPort(), DoDispose(), GetVPortTable(), ReceiveVPortMod(), RunThroughVPortTable(), and SendVPortTableFeatures().