23 #include "ns3/address.h"
24 #include "ns3/net-device.h"
26 #include "ns3/callback.h"
27 #include "ns3/packet.h"
28 #include "ns3/traced-callback.h"
29 #include "ns3/event-id.h"
30 #include "ns3/nstime.h"
31 #include "ns3/data-rate.h"
33 #include "ns3/mac48-address.h"
34 #include "ns3/unix-fd-reader.h"
194 virtual void SetIfIndex (
const uint32_t index);
199 virtual bool SetMtu (
const uint16_t mtu);
200 virtual uint16_t
GetMtu (
void)
const;
Time m_tStop
Time to start tearing down the device.
EventId m_startEvent
The ID of the ns-3 event used to schedule the start up of the underlying host Tap device and ns-3 rea...
virtual Ptr< Channel > GetChannel(void) const
Ipv4Address m_tapIp
The IP address to use as the device IP on the host.
virtual void DoDispose(void)
Call out to a separate process running as suid root in order to get our tap device created...
Simulation virtual time values and global simulation resolution.
virtual void SetNode(Ptr< Node > node)
virtual Ptr< Node > GetNode(void) const
A structure representing data read.
Smart pointer class similar to boost::intrusive_ptr.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Mode m_mode
The operating mode of the bridge.
void SetBridgedNetDevice(Ptr< NetDevice > bridgedDevice)
Set the ns-3 net device to bridge.
void SetMode(TapBridge::Mode mode)
Set the operating mode of this device.
Class to perform the actual reading from a socket.
virtual bool SetMtu(const uint16_t mtu)
a class to represent an Ipv4 address mask
Forward calls to a chain of Callback.
ns-3 creates and configures tap device
uint32_t m_nodeId
a copy of the node id so the read thread doesn't have to GetNode() in in order to find the node ID...
void StartTapDevice(void)
Spin up the device.
PacketType
Packet types are used as they are in Linux.
void Start(Time tStart)
Set a start time for the device.
EventId m_stopEvent
The ID of the ns-3 event used to schedule the tear down of the underlying host Tap device and ns-3 re...
ns-3 uses a pre-created tap, and bridges to a bridging net device
Mac48Address m_tapMac
The MAC address to use as the hardware address on the host; only used in UseLocal mode...
bool DiscardFromBridgedDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &src)
Receives a packet from a bridged Device.
void Stop(Time tStop)
Set a stop time for the device.
static TypeId GetTypeId(void)
Get the type ID.
a polymophic address class
bool m_linkUp
Flag indicating whether or not the link is up.
A class that asynchronously reads from a file descriptor.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
void CreateTap(void)
Call out to a separate process running as suid root in order to get our tap device created...
uint8_t * m_packetBuffer
A 64K buffer to hold packet data while it is being sent.
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void SetIfIndex(const uint32_t index)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
A bridge to make it appear that a real host process is connected to an ns-3 net device.
Ptr< NetDevice > GetBridgedNetDevice(void)
Get the bridged net device.
FdReader::Data DoRead(void)
The read implementation.
bool ReceiveFromBridgedDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType)
Receives a packet from a bridged Device.
uint32_t m_ifIndex
The ns-3 interface index of this TapBridge net device.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual uint16_t GetMtu(void) const
virtual bool NeedsArp(void) const
void StopTapDevice(void)
Tear down the device.
TracedCallback m_linkChangeCallbacks
Callbacks to fire if the link changes state (up or down).
Ptr< NetDevice > m_bridgedDevice
The ns-3 net device to which we are bridging.
virtual void SetAddress(Address address)
Set the address of this interface.
void ReadCallback(uint8_t *buf, ssize_t len)
Callback to process packets that are read.
std::string m_tapDeviceName
The name of the device to create on the host.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Node > m_node
Pointer to the (ghost) Node to which we are connected.
Ptr< TapBridgeFdReader > m_fdReader
Includes the ns-3 read thread used to do blocking reads on the fd corresponding to the host device...
Time m_tStart
Time to start spinning up the device.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Callback used to hook the promiscuous packet receive callback of the TapBridge ns-3 net device...
Ipv4Address m_tapGateway
The IP address to use as the device default gateway on the host.
bool m_ns3AddressRewritten
Whether the MAC address of the underlying ns-3 device has already been rewritten is stored in this va...
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
virtual Address GetAddress(void) const
virtual Address GetBroadcast(void) const
Mac48Address m_address
The (unused) MAC address of the TapBridge net device.
Mode
Enumeration of the operating modes supported in the class.
Describes an IPv6 address.
Ptr< Packet > Filter(Ptr< Packet > packet, Address *src, Address *dst, uint16_t *type)
The host we are bridged to is in the evil real world.
Ipv4 addresses are stored in host order in this class.
TapBridge::Mode GetMode(void)
Get the operating mode of this device.
virtual bool IsMulticast(void) const
virtual bool IsLinkUp(void) const
An identifier for simulation events.
Network layer to device interface.
ns-3 uses a pre-created tap, without configuring it
Ipv4Mask m_tapNetmask
The network mask to assign to the device created on the host.
void NotifyLinkUp(void)
Notifies that the link is up and ready.
virtual uint32_t GetIfIndex(void) const
virtual bool IsBroadcast(void) const
uint16_t m_mtu
The common mtu to use for the net devices.
int m_sock
The socket (actually interpreted as fd) to use to talk to the Tap device on the real internet host...
void ForwardToBridgedDevice(uint8_t *buf, ssize_t len)
Forward a packet received from the tap device to the bridged ns-3 device.
a unique identifier for an interface.
NetDevice::ReceiveCallback m_rxCallback
Callback used to hook the standard packet receive callback of the TapBridge ns-3 net device...
virtual bool SupportsSendFrom() const