A bridge to make it appear that a real host process is connected to an ns-3 net device. More...
#include <tap-bridge.h>
Public Types | |
enum | Mode { ILLEGAL, CONFIGURE_LOCAL, USE_LOCAL, USE_BRIDGE } |
Enumeration of the operating modes supported in the class. More... | |
![]() | |
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 &, enum PacketType > | PromiscReceiveCallback |
typedef Callback< bool, Ptr < NetDevice >, Ptr< const Packet >, uint16_t, const Address & > | ReceiveCallback |
Public Member Functions | |
TapBridge () | |
virtual | ~TapBridge () |
virtual void | AddLinkChangeCallback (Callback< void > callback) |
virtual Address | GetAddress (void) const |
Ptr< NetDevice > | GetBridgedNetDevice (void) |
Get the bridged net device. More... | |
virtual Address | GetBroadcast (void) const |
virtual Ptr< Channel > | GetChannel (void) const |
virtual uint32_t | GetIfIndex (void) const |
TapBridge::Mode | GetMode (void) |
Get the operating mode of this device. More... | |
virtual uint16_t | GetMtu (void) const |
virtual Address | GetMulticast (Ipv4Address multicastGroup) const |
Make and return a MAC multicast address using the provided multicast group. More... | |
virtual Address | GetMulticast (Ipv6Address addr) const |
Get the MAC multicast address corresponding to the IPv6 address provided. More... | |
virtual Ptr< Node > | GetNode (void) const |
virtual bool | IsBridge (void) const |
Return true if the net device is acting as a bridge. More... | |
virtual bool | IsBroadcast (void) const |
virtual bool | IsLinkUp (void) const |
virtual bool | IsMulticast (void) const |
virtual bool | IsPointToPoint (void) const |
Return true if the net device is on a point-to-point link. More... | |
virtual bool | NeedsArp (void) const |
virtual bool | Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) |
virtual bool | SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) |
virtual void | SetAddress (Address address) |
Set the address of this interface. More... | |
void | SetBridgedNetDevice (Ptr< NetDevice > bridgedDevice) |
Set the ns-3 net device to bridge. More... | |
virtual void | SetIfIndex (const uint32_t index) |
void | SetMode (TapBridge::Mode mode) |
Set the operating mode of this device. More... | |
virtual bool | SetMtu (const uint16_t mtu) |
virtual void | SetNode (Ptr< Node > node) |
virtual void | SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) |
virtual void | SetReceiveCallback (NetDevice::ReceiveCallback cb) |
void | Start (Time tStart) |
Set a start time for the device. More... | |
void | Stop (Time tStop) |
Set a stop time for the device. More... | |
virtual bool | SupportsSendFrom () const |
![]() | |
virtual | ~NetDevice () |
![]() | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
![]() | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
![]() | |
static TypeId | GetTypeId (void) |
![]() | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static void | Cleanup (void) |
Noop. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Protected Member Functions | |
bool | DiscardFromBridgedDevice (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &src) |
virtual void | DoDispose (void) |
bool | ReceiveFromBridgedDevice (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType) |
![]() | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. More... | |
Private Member Functions | |
void | CreateTap (void) |
Ptr< Packet > | Filter (Ptr< Packet > packet, Address *src, Address *dst, uint16_t *type) |
void | ForwardToBridgedDevice (uint8_t *buf, ssize_t len) |
void | NotifyLinkUp (void) |
void | ReadCallback (uint8_t *buf, ssize_t len) |
void | StartTapDevice (void) |
void | StopTapDevice (void) |
Private Attributes | |
Mac48Address | m_address |
Ptr< NetDevice > | m_bridgedDevice |
Ptr< TapBridgeFdReader > | m_fdReader |
uint32_t | m_ifIndex |
TracedCallback | m_linkChangeCallbacks |
bool | m_linkUp |
Mode | m_mode |
uint16_t | m_mtu |
Ptr< Node > | m_node |
uint32_t | m_nodeId |
bool | m_ns3AddressRewritten |
uint8_t * | m_packetBuffer |
A 64K buffer to hold packet data while it is being sent. More... | |
NetDevice::PromiscReceiveCallback | m_promiscRxCallback |
NetDevice::ReceiveCallback | m_rxCallback |
int | m_sock |
EventId | m_startEvent |
EventId | m_stopEvent |
std::string | m_tapDeviceName |
Ipv4Address | m_tapGateway |
Ipv4Address | m_tapIp |
Mac48Address | m_tapMac |
Ipv4Mask | m_tapNetmask |
Time | m_tStart |
Time | m_tStop |
A bridge to make it appear that a real host process is connected to an ns-3 net device.
The Tap Bridge lives in a kind of a gray world somewhere between a Linux host and an ns-3 bridge device. From the Linux perspective, this code appears as the user mode handler for a Tap net device. That is, when the Linux host writes to a /dev/tap device (that is either manually or automatically created depending on basic operating mode – more on this later), the write is redirected into the TapBridge that lives in the ns-3 world; and from this perspective, becomes a read. In other words, a Linux process writes a packet to a tap device and this packet is redirected to an ns-3 process where it is received by the TapBridge as a result of a read operation there. The TapBridge then sends the packet to the ns-3 net device to which it is bridged. In the other direction, a packet received by an ns-3 net device is bridged to the TapBridge (it appears via a callback from that net device. The TapBridge then takes that packet and writes it back to the host using the Linux TAP mechanism. This write to the device will then appear to the Linux host as if a packet has arrived on its device.
The upshot is that the Tap Bridge appears to bridge a tap device on a Linux host in the "real world" to an ns-3 net device in the simulation and make is appear that a ns-3 net device is actually installed in the Linux host. In order to do this on the ns-3 side, we need a "ghost node" in the simulation to hold the bridged ns-3 net device and the TapBridge. This node should not actually do anything else in the simulation since its job is simply to make the net device appear in Linux. This is not just arbitrary policy, it is because:
Of course, if you understand all of the issues you can take control of your own destiny and do whatever you want – we do not actively prevent you from using the ghost node for anything you decide. You will be able to perform typical ns-3 operations on the ghost node if you so desire. The internet stack, for example, must be there and functional on that node in order to participate in IP address assignment and global routing. However, as mentioned above, interfaces talking any Tap Bridge or associated bridged net devices will not work completely. If you understand exactly what you are doing, you can set up other interfaces and devices on the ghost node and use them; or take advantage of the operational send side of the bridged devices to create traffic generators. We generally recommend that you treat this node as a ghost of the Linux host and leave it to itself, though.
ns3::TapBridge is accessible through the following paths with Config::Set and Config::Connect:
No TraceSources are defined for this type.
Definition at line 103 of file tap-bridge.h.
enum ns3::TapBridge::Mode |
Enumeration of the operating modes supported in the class.
Definition at line 112 of file tap-bridge.h.
ns3::TapBridge::TapBridge | ( | ) |
Definition at line 139 of file tap-bridge.cc.
References m_packetBuffer, m_tStart, NS_LOG_FUNCTION_NOARGS, and Start().
|
virtual |
Definition at line 153 of file tap-bridge.cc.
References m_bridgedDevice, m_packetBuffer, NS_LOG_FUNCTION_NOARGS, and StopTapDevice().
|
virtual |
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 1081 of file tap-bridge.cc.
References ns3::TracedCallback< T1, T2, T3, T4, T5, T6, T7, T8 >::ConnectWithoutContext(), m_linkChangeCallbacks, and NS_LOG_FUNCTION_NOARGS.
|
private |
Call out to a separate process running as suid root in order to get our tap device created. We do this to avoid having the entire simulation running as root. If this method returns, we'll have a socket waiting for us in m_sock that we can use to talk to the tap device.
Definition at line 256 of file tap-bridge.cc.
References first::address, CONFIGURE_LOCAL, ns3::Mac48Address::ConvertFrom(), ns3::Mac48Address::CopyFrom(), GetBridgedNetDevice(), ns3::Object::GetObject(), ns3::Ipv4Mask::GetOnes(), ns3::Mac48Address::IsBroadcast(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Mask::IsEqual(), m_bridgedDevice, m_mode, m_ns3AddressRewritten, m_sock, m_tapDeviceName, m_tapGateway, m_tapIp, m_tapMac, m_tapNetmask, NS_ABORT_MSG_IF, NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, NS_LOG_WARN, TAP_MAGIC, ns3::TapBufferToString(), USE_BRIDGE, and USE_LOCAL.
Referenced by StartTapDevice().
|
protected |
Definition at line 919 of file tap-bridge.cc.
References NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by SetBridgedNetDevice().
|
protectedvirtual |
Call out to a separate process running as suid root in order to get our tap device created. We do this to avoid having the entire simulation running as root. If this method returns, we'll have a socket waiting for us in m_sock that we can use to talk to the tap device.
Reimplemented from ns3::Object.
Definition at line 166 of file tap-bridge.cc.
References ns3::Object::DoDispose(), and NS_LOG_FUNCTION_NOARGS.
|
private |
The host we are bridged to is in the evil real world. Do some sanity checking on a received packet to make sure it isn't too evil for our poor naive virginal simulator to handle.
packet | The packet we received from the host, and which we need to check. |
src | A pointer to the data structure that will get the source MAC address of the packet (extracted from the packet Ethernet header). |
dst | A pointer to the data structure that will get the destination MAC address of the packet (extracted from the packet Ethernet header). |
type | A pointer to the variable that will get the packet type from either the Ethernet header in the case of type interpretation (DIX framing) or from the 802.2 LLC header in the case of length interpretation (802.3 framing). |
Definition at line 818 of file tap-bridge.cc.
References ns3::EthernetHeader::GetDestination(), ns3::EthernetHeader::GetLengthType(), ns3::LlcSnapHeader::GetSerializedSize(), ns3::EthernetHeader::GetSerializedSize(), ns3::Packet::GetSize(), ns3::EthernetHeader::GetSource(), ns3::LlcSnapHeader::GetType(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Packet::RemoveHeader().
Referenced by ForwardToBridgedDevice().
|
private |
Definition at line 691 of file tap-bridge.cc.
References CONFIGURE_LOCAL, ns3::Mac48Address::ConvertFrom(), Filter(), m_bridgedDevice, m_mode, m_ns3AddressRewritten, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, USE_BRIDGE, and USE_LOCAL.
Referenced by ReadCallback().
|
virtual |
Implements ns3::NetDevice.
Definition at line 1027 of file tap-bridge.cc.
References m_address, and NS_LOG_FUNCTION_NOARGS.
Get the bridged net device.
The bridged net device is the ns-3 device to which this bridge is connected,
Definition at line 879 of file tap-bridge.cc.
References m_bridgedDevice, and NS_LOG_FUNCTION_NOARGS.
Referenced by CreateTap().
|
virtual |
Calling this method is invalid if IsBroadcast returns not true.
Implements ns3::NetDevice.
Definition at line 1095 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
Implements ns3::NetDevice.
Definition at line 1013 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 1006 of file tap-bridge.cc.
References m_ifIndex, and NS_LOG_FUNCTION_NOARGS.
TapBridge::Mode ns3::TapBridge::GetMode | ( | void | ) |
Get the operating mode of this device.
Definition at line 1041 of file tap-bridge.cc.
References m_mode, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
This value is typically used by the IP layer to perform IP fragmentation when needed.
Implements ns3::NetDevice.
Definition at line 1056 of file tap-bridge.cc.
References m_mtu, and NS_LOG_FUNCTION_NOARGS.
Referenced by GetTypeId().
|
virtual |
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 1109 of file tap-bridge.cc.
References ns3::Mac48Address::GetMulticast(), and NS_LOG_FUNCTION.
|
virtual |
Get the MAC multicast address corresponding to the IPv6 address provided.
addr | IPv6 address |
Implements ns3::NetDevice.
Definition at line 1194 of file tap-bridge.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 1153 of file tap-bridge.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
Referenced by StartTapDevice().
|
static |
Definition at line 80 of file tap-bridge.cc.
References CONFIGURE_LOCAL, GetMtu(), m_tapDeviceName, m_tapGateway, m_tapIp, m_tapMac, m_tapNetmask, m_tStart, m_tStop, ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeTimeChecker(), SetMode(), SetMtu(), ns3::TypeId::SetParent(), USE_BRIDGE, and USE_LOCAL.
|
virtual |
Return true if the net device is acting as a bridge.
Implements ns3::NetDevice.
Definition at line 1124 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 1088 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 1074 of file tap-bridge.cc.
References m_linkUp, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 1102 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Return true if the net device is on a point-to-point link.
Implements ns3::NetDevice.
Definition at line 1117 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Called by higher-layers to check if this NetDevice requires ARP to be used.
Implements ns3::NetDevice.
Definition at line 1167 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Definition at line 1063 of file tap-bridge.cc.
References m_linkChangeCallbacks, m_linkUp, and NS_LOG_FUNCTION_NOARGS.
Referenced by StartTapDevice().
|
private |
Callback to process packets that are read
Definition at line 666 of file tap-bridge.cc.
References ForwardToBridgedDevice(), m_nodeId, ns3::MakeEvent(), NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, and ns3::Simulator::ScheduleWithContext().
Referenced by StartTapDevice().
|
protected |
Definition at line 927 of file tap-bridge.cc.
References ns3::Packet::AddHeader(), CONFIGURE_LOCAL, ns3::Mac48Address::ConvertFrom(), ns3::Packet::Copy(), ns3::Packet::CopyData(), ns3::EthernetHeader::GetDestination(), ns3::Node::GetId(), ns3::EthernetHeader::GetLengthType(), ns3::Packet::GetSize(), ns3::EthernetHeader::GetSource(), ns3::Packet::GetUid(), m_bridgedDevice, m_mode, m_node, m_packetBuffer, m_sock, NS_ABORT_MSG_IF, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::NetDevice::PACKET_OTHERHOST, ns3::EthernetHeader::SetDestination(), ns3::EthernetHeader::SetLengthType(), and ns3::EthernetHeader::SetSource().
Referenced by SetBridgedNetDevice().
|
virtual |
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 1137 of file tap-bridge.cc.
References NS_FATAL_ERROR, and NS_LOG_FUNCTION.
|
virtual |
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 1145 of file tap-bridge.cc.
References NS_FATAL_ERROR, and NS_LOG_FUNCTION.
|
virtual |
Set the address of this interface.
address | address to set |
Implements ns3::NetDevice.
Definition at line 1020 of file tap-bridge.cc.
References ns3::Mac48Address::ConvertFrom(), m_address, and NS_LOG_FUNCTION.
Set the ns-3 net device to bridge.
This method tells the bridge which ns-3 net device it should use to connect the simulation side of the bridge.
bridgedDevice | device to set |
Definition at line 886 of file tap-bridge.cc.
References DiscardFromBridgedDevice(), ns3::Mac48Address::IsMatchingType(), m_bridgedDevice, m_mode, m_node, ns3::MakeCallback(), NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_FUNCTION, ReceiveFromBridgedDevice(), and USE_BRIDGE.
|
virtual |
index | ifIndex of the device |
Implements ns3::NetDevice.
Definition at line 999 of file tap-bridge.cc.
References m_ifIndex, and NS_LOG_FUNCTION_NOARGS.
void ns3::TapBridge::SetMode | ( | TapBridge::Mode | mode | ) |
Set the operating mode of this device.
mode | The operating mode of this device. |
Definition at line 1034 of file tap-bridge.cc.
References m_mode, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
virtual |
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 1048 of file tap-bridge.cc.
References m_mtu, and NS_LOG_FUNCTION_NOARGS.
Referenced by GetTypeId().
node | the node associated to this netdevice. |
This method is called from ns3::Node::AddDevice.
Implements ns3::NetDevice.
Definition at line 1160 of file tap-bridge.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
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 1181 of file tap-bridge.cc.
References m_promiscRxCallback, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
cb | callback to invoke whenever a packet has been received and must be forwarded to the higher layers. |
Implements ns3::NetDevice.
Definition at line 1174 of file tap-bridge.cc.
References m_rxCallback, and NS_LOG_FUNCTION_NOARGS.
void ns3::TapBridge::Start | ( | Time | tStart | ) |
Set a start time for the device.
The tap bridge consumes a non-trivial amount of time to start. It starts up in the context of a scheduled event to ensure that all configuration has been completed before extracting the configuration (IP addresses, etc.) In order to allow a more reasonable start-up sequence than a thundering herd of devices, the time at which each device starts is also configurable bot via the Attribute system and via this call.
tStart | the start time |
Definition at line 173 of file tap-bridge.cc.
References ns3::Simulator::Cancel(), m_startEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StartTapDevice().
Referenced by TapBridge().
|
private |
Spin up the device
Definition at line 196 of file tap-bridge.cc.
References CreateTap(), ns3::Node::GetId(), GetNode(), m_fdReader, m_nodeId, m_sock, ns3::MakeCallback(), NotifyLinkUp(), NS_ABORT_MSG_IF, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, and ReadCallback().
Referenced by Start().
void ns3::TapBridge::Stop | ( | Time | tStop | ) |
Set a stop time for the device.
tStop | the stop time |
Definition at line 185 of file tap-bridge.cc.
References ns3::Simulator::Cancel(), m_startEvent, m_stopEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StopTapDevice().
|
private |
Tear down the device
Definition at line 238 of file tap-bridge.cc.
References m_fdReader, m_sock, and NS_LOG_FUNCTION_NOARGS.
Referenced by Stop(), and ~TapBridge().
|
virtual |
Implements ns3::NetDevice.
Definition at line 1188 of file tap-bridge.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
The (unused) MAC address of the TapBridge net device. Since the TapBridge is implemented as a ns-3 net device, it is required to implement certain functionality. In this case, the TapBridge is automatically assigned a MAC address, but it is not used.
Definition at line 388 of file tap-bridge.h.
Referenced by GetAddress(), and SetAddress().
The ns-3 net device to which we are bridging.
Definition at line 448 of file tap-bridge.h.
Referenced by CreateTap(), ForwardToBridgedDevice(), GetBridgedNetDevice(), ReceiveFromBridgedDevice(), SetBridgedNetDevice(), and ~TapBridge().
|
private |
Includes the ns-3 read thread used to do blocking reads on the fd corresponding to the host device.
Definition at line 370 of file tap-bridge.h.
Referenced by StartTapDevice(), and StopTapDevice().
|
private |
The ns-3 interface index of this TapBridge net device.
Definition at line 331 of file tap-bridge.h.
Referenced by GetIfIndex(), and SetIfIndex().
|
private |
Callbacks to fire if the link changes state (up or down).
Definition at line 483 of file tap-bridge.h.
Referenced by AddLinkChangeCallback(), and NotifyLinkUp().
|
private |
Flag indicating whether or not the link is up. In this case, whether or not ns-3 is connected to the underlying TAP device with a file descriptor.
Definition at line 476 of file tap-bridge.h.
Referenced by IsLinkUp(), and NotifyLinkUp().
|
private |
The operating mode of the bridge. Tells basically who creates and configures the underlying network tap.
Definition at line 378 of file tap-bridge.h.
Referenced by CreateTap(), ForwardToBridgedDevice(), GetMode(), ReceiveFromBridgedDevice(), SetBridgedNetDevice(), and SetMode().
|
private |
Pointer to the (ghost) Node to which we are connected.
Definition at line 323 of file tap-bridge.h.
Referenced by GetNode(), ReceiveFromBridgedDevice(), SetBridgedNetDevice(), and SetNode().
|
private |
Definition at line 467 of file tap-bridge.h.
Referenced by ReadCallback(), and StartTapDevice().
|
private |
Whether the MAC address of the underlying ns-3 device has already been rewritten is stored in this variable (for UseLocal/UseBridge mode only).
Definition at line 455 of file tap-bridge.h.
Referenced by CreateTap(), and ForwardToBridgedDevice().
|
private |
A 64K buffer to hold packet data while it is being sent.
Definition at line 460 of file tap-bridge.h.
Referenced by ReceiveFromBridgedDevice(), TapBridge(), and ~TapBridge().
|
private |
Callback used to hook the promiscuous packet receive callback of the TapBridge ns-3 net device. This is never called, and therefore no packets will ever be received forwarded up the IP stack on the ghost node through this device.
Note that we intercept the similar callback in the bridged device in order to do the actual bridging between the bridged ns-3 net device and the Tap device on the host.
Definition at line 316 of file tap-bridge.h.
Referenced by SetPromiscReceiveCallback().
|
private |
Callback used to hook the standard packet receive callback of the TapBridge ns-3 net device. This is never called, and therefore no packets will ever be received forwarded up the IP stack on the ghost node through this device.
Definition at line 303 of file tap-bridge.h.
Referenced by SetReceiveCallback().
|
private |
The socket (actually interpreted as fd) to use to talk to the Tap device on the real internet host.
Definition at line 346 of file tap-bridge.h.
Referenced by CreateTap(), ReceiveFromBridgedDevice(), StartTapDevice(), and StopTapDevice().
|
private |
The ID of the ns-3 event used to schedule the start up of the underlying host Tap device and ns-3 read thread.
Definition at line 354 of file tap-bridge.h.
|
private |
The ID of the ns-3 event used to schedule the tear down of the underlying host Tap device and ns-3 read thread.
Definition at line 362 of file tap-bridge.h.
Referenced by Stop().
|
private |
The name of the device to create on the host. If the device name is the empty string, we allow the host kernel to choose a name.
Definition at line 410 of file tap-bridge.h.
Referenced by CreateTap(), and GetTypeId().
|
private |
The IP address to use as the device default gateway on the host.
Definition at line 417 of file tap-bridge.h.
Referenced by CreateTap(), and GetTypeId().
|
private |
The IP address to use as the device IP on the host.
Definition at line 424 of file tap-bridge.h.
Referenced by CreateTap(), and GetTypeId().
|
private |
The MAC address to use as the hardware address on the host; only used in UseLocal mode. This value comes from the MAC address assigned to the bridged ns-3 net device and matches the MAC address of the underlying network TAP which we configured to have the same value.
Definition at line 434 of file tap-bridge.h.
Referenced by CreateTap(), and GetTypeId().
|
private |
The network mask to assign to the device created on the host.
Definition at line 441 of file tap-bridge.h.
Referenced by CreateTap(), and GetTypeId().
|
private |
Time to start spinning up the device
Definition at line 395 of file tap-bridge.h.
Referenced by GetTypeId(), and TapBridge().
|
private |
Time to start tearing down the device
Definition at line 402 of file tap-bridge.h.
Referenced by GetTypeId().