UintegerValue (1500),
MakeUintegerAccessor (&BridgeNetDevice::SetMtu,
&BridgeNetDevice::GetMtu),
- MakeUintegerChecker<uint16_t> ())
+ MakeUintegerChecker<uint16_t> ())
+ .AddAttribute ("StateSize", "The size of the State Table",
+ UintegerValue (8000),
+ MakeUintegerAccessor (&BridgeNetDevice::SetStateSize,
+ &BridgeNetDevice::GetStateSize),
+ MakeUintegerChecker<unsigned long> ())
.AddAttribute ("EnableLearning",
"Enable the learning mode of the Learning Bridge",
BooleanValue (true),
MakeBooleanChecker ())
.AddAttribute ("ExpirationTime",
"Time it takes for learned MAC state entry to expire.",
- TimeValue (Seconds (30)),
+ TimeValue (Seconds (300)),
MakeTimeAccessor (&BridgeNetDevice::m_expirationTime),
MakeTimeChecker ())
;
if (m_enableLearning)
{
- LearnedState &state = m_learnState[src48];
- state.associatedPort = port;
- state.expirationTime = Simulator::Now () + m_expirationTime;
+ std::map<Mac48Address, LearnedState>::iterator it = m_learnState.find(src48);
+ if(it != m_learnState.end() || m_learnState.size() < m_maxStateSize){
+ LearnedState &state = m_learnState[src48];
+ state.associatedPort = port;
+ state.expirationTime = Simulator::Now () + m_expirationTime;
+ }
}
}
return m_mtu;
}
+bool
+BridgeNetDevice::SetMaxStateSize (const unsigned long maxStateSize )
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ m_maxStateSize = maxStateSize ;
+ return true;
+}
+
+unsigned long
+BridgeNetDevice::GetMaxStateSize (void) const
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ return m_maxStateSize;
+}
+
+unsigned long
+BridgeNetDevice::GetStateSize (void) const
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ return m_learnState.size();
+}
bool
BridgeNetDevice::IsLinkUp (void) const
virtual Address GetAddress (void) const;
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
+
+ virtual bool SetMaxStateSize (const unsigned long maxStateSize );
+ virtual unsigned long GetMaxStateSize (void) const;
+ virtual unsigned long GetStateSize (void) const;
+
virtual bool IsLinkUp (void) const;
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
uint16_t mPortNumber;
uint32_t m_ifIndex;
uint16_t m_mtu;
+ unsigned long m_maxStateSize;
bool m_enableLearning;
};