20 #include "ns3/channel.h" 
   21 #include "ns3/packet.h" 
   23 #include "ns3/boolean.h" 
   24 #include "ns3/simulator.h" 
   25 #include "ns3/uinteger.h" 
   39     .AddConstructor<BridgeNetDevice> ()
 
   40     .AddAttribute (
"Mtu", 
"The MAC-level Maximum Transmission Unit",
 
   44                    MakeUintegerChecker<uint16_t> ())
 
   45     .AddAttribute (
"EnableLearning",
 
   46                    "Enable the learning mode of the Learning Bridge",
 
   49                    MakeBooleanChecker ())
 
   50     .AddAttribute (
"ExpirationTime",
 
   51                    "Time it takes for learned MAC state entry to expire.",
 
   65   m_channel = CreateObject<BridgeChannel> ();
 
  135   NS_LOG_DEBUG (
"LearningBridgeForward (incomingPort=" << incomingPort->GetInstanceTypeId ().GetName ()
 
  136                                                        << 
", packet=" << packet << 
", protocol="<<protocol
 
  137                                                        << 
", src=" << src << 
", dst=" << dst << 
")");
 
  139   Learn (src, incomingPort);
 
  141   if (outPort != NULL && outPort != incomingPort)
 
  143       NS_LOG_LOGIC (
"Learning bridge state says to use port `" << outPort->GetInstanceTypeId ().GetName () << 
"'");
 
  144       outPort->SendFrom (packet->
Copy (), src, dst, protocol);
 
  148       NS_LOG_LOGIC (
"No learned state: send through all ports");
 
  150            iter != 
m_ports.end (); iter++)
 
  153           if (port != incomingPort)
 
  155               NS_LOG_LOGIC (
"LearningBridgeForward (" << src << 
" => " << dst << 
"): "  
  156                                                       << incomingPort->GetInstanceTypeId ().GetName ()
 
  157                                                       << 
" --> " << port->GetInstanceTypeId ().GetName ()
 
  158                                                       << 
" (UID " << packet->
GetUid () << 
").");
 
  159               port->SendFrom (packet->
Copy (), src, dst, protocol);
 
  170   NS_LOG_DEBUG (
"LearningBridgeForward (incomingPort=" << incomingPort->GetInstanceTypeId ().GetName ()
 
  171                                                        << 
", packet=" << packet << 
", protocol="<<protocol
 
  172                                                        << 
", src=" << src << 
", dst=" << dst << 
")");
 
  173   Learn (src, incomingPort);
 
  176        iter != 
m_ports.end (); iter++)
 
  179       if (port != incomingPort)
 
  181           NS_LOG_LOGIC (
"LearningBridgeForward (" << src << 
" => " << dst << 
"): "  
  182                                                   << incomingPort->GetInstanceTypeId ().GetName ()
 
  183                                                   << 
" --> " << port->GetInstanceTypeId ().GetName ()
 
  184                                                   << 
" (UID " << packet->
GetUid () << 
").");
 
  185           port->SendFrom (packet->
Copy (), src, dst, protocol);
 
  207       std::map<Mac48Address, LearnedState>::iterator iter =
 
  247       NS_FATAL_ERROR (
"Device does not support eui 48 addresses: cannot be added to bridge.");
 
  249   if (!bridgePort->SupportsSendFrom ())
 
  251       NS_FATAL_ERROR (
"Device does not support SendFrom: cannot be added to bridge.");
 
  258   NS_LOG_DEBUG (
"RegisterProtocolHandler for " << bridgePort->GetInstanceTypeId ().GetName ());
 
  260                                    0, bridgePort, 
true);
 
  261   m_ports.push_back (bridgePort);
 
  262   m_channel->AddChannel (bridgePort->GetChannel ());
 
  394           outPort->SendFrom (packet, src, dest, protocolNumber);
 
  402        iter != 
m_ports.end (); iter++)
 
  405       port->SendFrom (packet, src, dest, protocolNumber);
 
void AddBridgePort(Ptr< NetDevice > bridgePort)
Add a 'port' to a bridge device. 
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
static bool IsMatchingType(const Address &address)
keep track of time values and allow control of global simulation resolution 
smart pointer class similar to boost::intrusive_ptr 
#define NS_LOG_FUNCTION(parameters)
void Learn(Mac48Address source, Ptr< NetDevice > port)
virtual bool IsBridge(void) const 
Return true if the net device is acting as a bridge. 
Ptr< NetDevice > GetLearnedState(Mac48Address source)
void ForwardBroadcast(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, Mac48Address src, Mac48Address dst)
virtual bool IsPointToPoint(void) const 
Return true if the net device is on a point-to-point link. 
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual void SetIfIndex(const uint32_t index)
virtual uint32_t GetIfIndex(void) const 
uint64_t GetUid(void) const 
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual bool IsMulticast(void) const 
virtual Ptr< Channel > GetChannel(void) const 
static TypeId GetTypeId(void)
virtual void DoDispose(void)
#define NS_LOG_FUNCTION_NOARGS()
virtual void SetAddress(Address address)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
NetDevice::PromiscReceiveCallback m_promiscRxCallback
virtual void AddLinkChangeCallback(Callback< void > callback)
#define NS_FATAL_ERROR(msg)
fatal error handling 
a polymophic address class 
Ptr< NetDevice > associatedPort
static Mac48Address GetMulticast(Ipv4Address address)
Ptr< NetDevice > GetBridgePort(uint32_t n) const 
hold objects of type ns3::Time 
std::vector< Ptr< NetDevice > > m_ports
virtual uint16_t GetMtu(void) const 
Hold an unsigned integer type. 
virtual bool SetMtu(const uint16_t mtu)
virtual bool SupportsSendFrom() const 
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
virtual bool IsBroadcast(void) const 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
virtual Address GetBroadcast(void) const 
#define NS_LOG_LOGIC(msg)
static Mac48Address ConvertFrom(const Address &address)
Ptr< Packet > Copy(void) const 
virtual bool NeedsArp(void) const 
virtual ~BridgeNetDevice()
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
NetDevice::ReceiveCallback m_rxCallback
virtual Address GetAddress(void) const 
virtual Address GetMulticast(Ipv4Address multicastGroup) const 
Make and return a MAC multicast address using the provided multicast group. 
virtual Ptr< Node > GetNode(void) const 
virtual void DoDispose(void)
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
std::map< Mac48Address, LearnedState > m_learnState
Describes an IPv6 address. 
Ipv4 addresses are stored in host order in this class. 
void ForwardUnicast(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, Mac48Address src, Mac48Address dst)
Network layer to device interface. 
#define NS_LOG_DEBUG(msg)
Ptr< BridgeChannel > m_channel
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive. 
uint32_t GetNBridgePorts(void) const 
virtual void SetNode(Ptr< Node > node)
a unique identifier for an interface. 
TypeId SetParent(TypeId tid)
virtual bool IsLinkUp(void) const 
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType)