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