From: Richard Whitehouse Date: Sun, 20 Feb 2011 02:10:12 +0000 (+0000) Subject: Add ability to specify bridge address. Add learning static routes. Check the expirati... X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=a9d66d74d239ec4f95d3a8460475352ffbc8a4b5;p=ns-moose.git Add ability to specify bridge address. Add learning static routes. Check the expiration time before updating --- diff --git a/code/src/devices/bridge/model/moose-bridge-net-device.cc b/code/src/devices/bridge/model/moose-bridge-net-device.cc index ae81609..70ac1e5 100644 --- a/code/src/devices/bridge/model/moose-bridge-net-device.cc +++ b/code/src/devices/bridge/model/moose-bridge-net-device.cc @@ -36,6 +36,11 @@ MooseBridgeNetDevice::GetTypeId (void) static TypeId tid = TypeId ("ns3::MooseBridgeNetDevice") .SetParent () .AddConstructor () + .AddAttribute ("MooseAddress", + "Bridge MOOSE Address", + MooseAddressValue(), + MakeMooseAddressAccessor (&MooseBridgeNetDevice::m_mooseAddress), + MakeMooseAddressChecker ()) .AddAttribute ("MooseExpirationTime", "Time it takes for learned MOOSE state entry to expire.", TimeValue (Seconds (30)), @@ -135,7 +140,9 @@ MooseAddress MooseBridgeNetDevice::ToMoose(MooseAddress const& addr){ NS_LOG_LOGIC("Using Allocated MOOSE Suffix: (" << moose.GetMoosePrefix().GetInt() << "," << moose.GetMooseSuffix().GetInt() << ")"); - state.expirationTime = now + m_expirationTime; + if(now + m_expirationTime > state.expirationTime){ + state.expirationTime = now + m_expirationTime; + } } else { // Delete old and alloc new @@ -167,6 +174,18 @@ MooseAddress MooseBridgeNetDevice::ToMoose(MooseAddress const& addr){ } +void MooseBridgeNetDevice::AddRoutes(std::map > routes){ + + for(std::map >::iterator it = routes.begin(); it != routes.end(); it ++){ + + PrefixState &state = m_prefixState[it->first]; + state.associatedPort = it->second; + state.expirationTime = Simulator::GetMaximumSimulationTime(); + + } + +} + void MooseBridgeNetDevice::Learn(MooseAddress const& addr, Ptr port){ NS_LOG_FUNCTION_NOARGS (); @@ -178,13 +197,17 @@ void MooseBridgeNetDevice::Learn(MooseAddress const& addr, Ptr state.expirationTime){ + state.expirationTime = now + m_expirationTime; + } } else { PortState &state = m_portState[addr.GetMooseSuffix()]; state.associatedPort = port; - state.expirationTime = now + m_expirationTime; + if(now + m_expirationTime > state.expirationTime){ + state.expirationTime = now + m_expirationTime; + } } diff --git a/code/src/devices/bridge/model/moose-bridge-net-device.h b/code/src/devices/bridge/model/moose-bridge-net-device.h index 91fd1d7..eebc55b 100644 --- a/code/src/devices/bridge/model/moose-bridge-net-device.h +++ b/code/src/devices/bridge/model/moose-bridge-net-device.h @@ -44,26 +44,15 @@ public: MooseAddress ToMoose(MooseAddress const& addr); MooseAddress FromMoose(MooseAddress const& addr); + void AddRoutes(std::map > routes); + + void SetMoosePrefixAddress(MoosePrefixAddress const& prefix); + MoosePrefixAddress GetMoosePrefixAddress(); protected: virtual void ForwardUnicast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst); - -// From NetDevice - -// Unconvinced we need these... - -// virtual bool Send (Ptr packet, const Address& dest, uint16_t protocolNumber); -// virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); - -// From BridgeNetDevice - -/* - - virtual void Forward (Ptr port, Ptr packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType); - virtual void ForwardBroadcast (Ptr incomingPort, Ptr packet, uint16_t protocol, Mac48Address src, Mac48Address dst); - virtual void Learn (Address const &src, Ptr port); - virtual Ptr GetLearnedState (Mac48Address source); */ + virtual Ptr CreateBridgePort(Ptr bridge, Ptr device, Ptr node);