1.1 --- a/src/devices/mesh/dot11s/dot11s-test-suite.cc Mon Nov 02 12:28:38 2009 +0300
1.2 +++ b/src/devices/mesh/dot11s/dot11s-test-suite.cc Tue Nov 03 12:50:18 2009 +0300
1.3 @@ -174,9 +174,9 @@
1.4 {
1.5 for (std::vector<Mac48Address>::const_iterator i = precursors.begin (); i != precursors.end (); i++)
1.6 {
1.7 - table->AddPrecursor (dst, iface, *i);
1.8 + table->AddPrecursor (dst, iface, *i, Seconds (100));
1.9 // Check that duplicates are filtered
1.10 - table->AddPrecursor (dst, iface, *i);
1.11 + table->AddPrecursor (dst, iface, *i, Seconds (100));
1.12 }
1.13 }
1.14
2.1 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc Mon Nov 02 12:28:38 2009 +0300
2.2 +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc Tue Nov 03 12:50:18 2009 +0300
2.3 @@ -415,15 +415,18 @@
2.4 }
2.5 }
2.6 }
2.7 - m_hwmpSeqnoMetricDatabase[preq.GetOriginatorAddress ()] = std::make_pair (preq.GetOriginatorSeqNumber (), preq.GetMetric ());
2.8 -
2.9 + m_hwmpSeqnoMetricDatabase[preq.GetOriginatorAddress ()] =
2.10 + std::make_pair (preq.GetOriginatorSeqNumber (), preq.GetMetric ());
2.11 NS_LOG_DEBUG("I am " << GetAddress () << "Accepted preq from address" << from << ", preq:" << preq);
2.12 std::vector<Ptr<DestinationAddressUnit> > destinations = preq.GetDestinationList ();
2.13 //Add reactive path to originator:
2.14 if (
2.15 - ((m_rtable->LookupReactive (preq.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
2.16 - ((m_rtable->LookupReactive (preq.GetOriginatorAddress ())).metric > preq.GetMetric ())
2.17 + ((int32_t)(i->second.first - preq.GetOriginatorSeqNumber ()) < 0) ||
2.18 + (
2.19 + (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter == Mac48Address::GetBroadcast ()) ||
2.20 + (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).metric > preq.GetMetric ())
2.21 )
2.22 + )
2.23 {
2.24 m_rtable->AddReactivePath (
2.25 preq.GetOriginatorAddress (),
2.26 @@ -432,13 +435,12 @@
2.27 preq.GetMetric (),
2.28 MicroSeconds (preq.GetLifetime () * 1024),
2.29 preq.GetOriginatorSeqNumber ()
2.30 - );
2.31 + );
2.32 ReactivePathResolved (preq.GetOriginatorAddress ());
2.33 }
2.34 - //Add reactive path for precursor:
2.35 if (
2.36 - ((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
2.37 - ((m_rtable->LookupReactive (fromMp)).metric > preq.GetMetric ())
2.38 + (m_rtable->LookupReactive (fromMp).retransmitter == Mac48Address::GetBroadcast ()) ||
2.39 + (m_rtable->LookupReactive (fromMp).metric > metric)
2.40 )
2.41 {
2.42 m_rtable->AddReactivePath (
2.43 @@ -477,15 +479,6 @@
2.44 preq.GetOriginatorSeqNumber ()
2.45 );
2.46 ProactivePathResolved ();
2.47 - m_rtable->AddReactivePath (
2.48 - preq.GetOriginatorAddress (),
2.49 - from,
2.50 - interface,
2.51 - preq.GetMetric (),
2.52 - MicroSeconds (preq.GetLifetime () * 1024),
2.53 - preq.GetOriginatorSeqNumber ()
2.54 - );
2.55 - ReactivePathResolved (preq.GetOriginatorAddress ());
2.56 }
2.57 if (!preq.IsNeedNotPrep ())
2.58 {
2.59 @@ -493,7 +486,7 @@
2.60 GetAddress (),
2.61 preq.GetOriginatorAddress (),
2.62 from,
2.63 - preq.GetMetric (),
2.64 + (uint32_t)0,
2.65 preq.GetOriginatorSeqNumber (),
2.66 GetNextHwmpSeqno (),
2.67 preq.GetLifetime (),
2.68 @@ -523,9 +516,6 @@
2.69 if ((! ((*i)->IsDo ())) && (result.retransmitter != Mac48Address::GetBroadcast ()))
2.70 {
2.71 //have a valid information and can answer
2.72 - //!NB: If there is information from peer - set lifetime as
2.73 - //we have got from PREQ, and set the rest lifetime of the
2.74 - //route if the information is correct
2.75 uint32_t lifetime = result.lifetime.GetMicroSeconds () / 1024;
2.76 if ((lifetime > 0) && ((int32_t)(result.seqnum - (*i)->GetDestSeqNumber ()) >= 0))
2.77 {
2.78 @@ -539,6 +529,8 @@
2.79 lifetime,
2.80 interface
2.81 );
2.82 + m_rtable->AddPrecursor ((*i)->GetDestinationAddress (), interface, from,
2.83 + MicroSeconds (preq.GetLifetime () * 1024));
2.84 if ((*i)->IsRf ())
2.85 {
2.86 (*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0
2.87 @@ -579,29 +571,35 @@
2.88 //Now add a path to destination and add precursor to source
2.89 NS_LOG_DEBUG ("I am " << GetAddress () << ", received prep from " << prep.GetOriginatorAddress () << ", receiver was:" << from);
2.90 HwmpRtable::LookupResult result = m_rtable->LookupReactive (prep.GetDestinationAddress ());
2.91 - //Add a reactive path only if it is better than existing:
2.92 + //Add a reactive path only if seqno is fresher or it improves the
2.93 + //metric
2.94 if (
2.95 - ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
2.96 - ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ())
2.97 + (((int32_t)(i->second.first - prep.GetOriginatorSeqNumber ()) < 0)) ||
2.98 + (
2.99 + ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
2.100 + ((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ())
2.101 )
2.102 + )
2.103 {
2.104 m_rtable->AddReactivePath (
2.105 prep.GetOriginatorAddress (),
2.106 from,
2.107 interface,
2.108 prep.GetMetric (),
2.109 - MicroSeconds(prep.GetLifetime () * 1024),
2.110 + MicroSeconds (prep.GetLifetime () * 1024),
2.111 prep.GetOriginatorSeqNumber ());
2.112 - m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
2.113 + m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from,
2.114 + MicroSeconds (prep.GetLifetime () * 1024));
2.115 if (result.retransmitter != Mac48Address::GetBroadcast ())
2.116 {
2.117 - m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
2.118 + m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter,
2.119 + result.lifetime);
2.120 }
2.121 ReactivePathResolved (prep.GetOriginatorAddress ());
2.122 }
2.123 if (
2.124 ((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
2.125 - ((m_rtable->LookupReactive (fromMp)).metric > prep.GetMetric ())
2.126 + ((m_rtable->LookupReactive (fromMp)).metric > metric)
2.127 )
2.128 {
2.129 m_rtable->AddReactivePath (
2.130 @@ -669,7 +667,7 @@
2.131 prep.SetDestinationAddress (dst);
2.132 prep.SetDestinationSeqNumber (destinationSN);
2.133 prep.SetLifetime (lifetime);
2.134 - prep.SetMetric (0);
2.135 + prep.SetMetric (initMetric);
2.136 prep.SetOriginatorAddress (src);
2.137 prep.SetOriginatorSeqNumber (originatorDsn);
2.138 HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find (interface);
3.1 --- a/src/devices/mesh/dot11s/hwmp-rtable.cc Mon Nov 02 12:28:38 2009 +0300
3.2 +++ b/src/devices/mesh/dot11s/hwmp-rtable.cc Tue Nov 03 12:50:18 2009 +0300
3.3 @@ -84,11 +84,12 @@
3.4 }
3.5 void
3.6 HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface,
3.7 - Mac48Address precursorAddress)
3.8 + Mac48Address precursorAddress, Time lifetime)
3.9 {
3.10 - std::pair<uint32_t, Mac48Address> precursor;
3.11 - precursor.first = precursorInterface;
3.12 - precursor.second = precursorAddress;
3.13 + Precursor precursor;
3.14 + precursor.interface = precursorInterface;
3.15 + precursor.address = precursorAddress;
3.16 + precursor.whenExpire = Simulator::Now () + lifetime;
3.17 std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination);
3.18 if (i != m_routes.end ())
3.19 {
3.20 @@ -97,9 +98,10 @@
3.21 {
3.22 //NB: Only one active route may exist, so do not check
3.23 //interface ID, just address
3.24 - if (i->second.precursors[j].second == precursorAddress)
3.25 + if (i->second.precursors[j].address == precursorAddress)
3.26 {
3.27 should_add = false;
3.28 + i->second.precursors[j].whenExpire = precursor.whenExpire;
3.29 break;
3.30 }
3.31 }
3.32 @@ -108,17 +110,6 @@
3.33 i->second.precursors.push_back (precursor);
3.34 }
3.35 }
3.36 - if (m_root.root == destination)
3.37 - {
3.38 - for (unsigned int j = 0; j < m_root.precursors.size (); j++)
3.39 - {
3.40 - if (m_root.precursors[j].second == precursorAddress)
3.41 - {
3.42 - return;
3.43 - }
3.44 - }
3.45 - }
3.46 - m_root.precursors.push_back (precursor);
3.47 }
3.48 void
3.49 HwmpRtable::DeleteProactivePath ()
3.50 @@ -221,27 +212,12 @@
3.51 std::map<Mac48Address, ReactiveRoute>::iterator route = m_routes.find (destination);
3.52 if (route != m_routes.end ())
3.53 {
3.54 - for (unsigned int i = 0; i < route->second.precursors.size (); i++)
3.55 + for (std::vector<Precursor>::const_iterator i = route->second.precursors.begin ();
3.56 + i != route->second.precursors.end (); i++)
3.57 {
3.58 - retval.push_back (route->second.precursors[i]);
3.59 - }
3.60 - }
3.61 - if (m_root.root == destination)
3.62 - {
3.63 - for (unsigned int i = 0; i < m_root.precursors.size (); i++)
3.64 - {
3.65 - bool should_add = true;
3.66 - for (unsigned int j = 0; j < retval.size (); j++)
3.67 + if (i->whenExpire > Simulator::Now ())
3.68 {
3.69 - if (retval[j].second == m_root.precursors[i].second)
3.70 - {
3.71 - should_add = false;
3.72 - break;
3.73 - }
3.74 - }
3.75 - if (should_add)
3.76 - {
3.77 - retval.push_back (m_root.precursors[i]);
3.78 + retval.push_back (std::make_pair(i->interface, i->address));
3.79 }
3.80 }
3.81 }
4.1 --- a/src/devices/mesh/dot11s/hwmp-rtable.h Mon Nov 02 12:28:38 2009 +0300
4.2 +++ b/src/devices/mesh/dot11s/hwmp-rtable.h Tue Nov 03 12:50:18 2009 +0300
4.3 @@ -85,7 +85,7 @@
4.4 Time lifetime,
4.5 uint32_t seqnum
4.6 );
4.7 - void AddPrecursor (Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress);
4.8 + void AddPrecursor (Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress, Time lifetime);
4.9 PrecursorList GetPrecursors (Mac48Address destination);
4.10 void DeleteProactivePath ();
4.11 void DeleteProactivePath (Mac48Address root);
4.12 @@ -109,6 +109,12 @@
4.13
4.14 private:
4.15 /// Route found in reactive mode
4.16 + struct Precursor
4.17 + {
4.18 + Mac48Address address;
4.19 + uint32_t interface;
4.20 + Time whenExpire;
4.21 + };
4.22 struct ReactiveRoute
4.23 {
4.24 Mac48Address retransmitter;
4.25 @@ -116,7 +122,7 @@
4.26 uint32_t metric;
4.27 Time whenExpire;
4.28 uint32_t seqnum;
4.29 - std::vector<std::pair<uint32_t, Mac48Address> > precursors;
4.30 + std::vector<Precursor> precursors;
4.31 };
4.32 /// Route fond in proactive mode
4.33 struct ProactiveRoute
4.34 @@ -127,7 +133,7 @@
4.35 uint32_t metric;
4.36 Time whenExpire;
4.37 uint32_t seqnum;
4.38 - std::vector<std::pair<uint32_t, Mac48Address> > precursors;
4.39 + std::vector<Precursor> precursors;
4.40 };
4.41
4.42 /// List of routes
5.1 --- a/src/devices/mesh/dot11s/ie-dot11s-prep.cc Mon Nov 02 12:28:38 2009 +0300
5.2 +++ b/src/devices/mesh/dot11s/ie-dot11s-prep.cc Tue Nov 03 12:50:18 2009 +0300
5.3 @@ -135,6 +135,7 @@
5.4 IePrep::DecrementTtl ()
5.5 {
5.6 m_ttl--;
5.7 + m_hopcount ++;
5.8 }
5.9
5.10 void
6.1 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc Mon Nov 02 12:28:38 2009 +0300
6.2 +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc Tue Nov 03 12:50:18 2009 +0300
6.3 @@ -317,17 +317,17 @@
6.4 IePreq::Print (std::ostream &os) const
6.5 {
6.6 os << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
6.7 - os << " originator address = " << m_originatorAddress << "std::endl";
6.8 - os << " TTL = " << (uint16_t) m_ttl << "std::endl";
6.9 - os << " hop count = " << (uint16_t) m_hopCount << "std::endl";
6.10 - os << " metric = " << m_metric << "std::endl";
6.11 - os << " seqno = " << m_originatorSeqNumber << "std::endl";
6.12 - os << " lifetime = " << m_lifetime << "std::endl";
6.13 - os << " preq ID = " << m_preqId << "std::endl";
6.14 - os << " Destinations are:std::endl";
6.15 + os << " originator address = " << m_originatorAddress << std::endl;
6.16 + os << " TTL = " << (uint16_t) m_ttl << std::endl;
6.17 + os << " hop count = " << (uint16_t) m_hopCount << std::endl;
6.18 + os << " metric = " << m_metric << std::endl;
6.19 + os << " seqno = " << m_originatorSeqNumber << std::endl;
6.20 + os << " lifetime = " << m_lifetime << std::endl;
6.21 + os << " preq ID = " << m_preqId << std::endl;
6.22 + os << " Destinations are:" << std::endl;
6.23 for (int j = 0; j < m_destCount; j++)
6.24 {
6.25 - os << " " << m_destinations[j]->GetDestinationAddress () << "std::endl";
6.26 + os << " " << m_destinations[j]->GetDestinationAddress () << std::endl;
6.27 }
6.28 os << "</information_element>" << std::endl;
6.29 }
7.1 --- a/src/devices/mesh/dot11s/ie-dot11s-rann.cc Mon Nov 02 12:28:38 2009 +0300
7.2 +++ b/src/devices/mesh/dot11s/ie-dot11s-rann.cc Tue Nov 03 12:50:18 2009 +0300
7.3 @@ -152,12 +152,12 @@
7.4 IeRann::Print (std::ostream &os) const
7.5 {
7.6 os << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
7.7 - os << " flags = " << (int) m_flags << "std::endl";
7.8 - os << " hop count = " << (int) m_hopcount << "std::endl";
7.9 - os << " TTL = " << (int) m_ttl << "std::endl";
7.10 - os << " originator address = " << m_originatorAddress << "std::endl";
7.11 - os << " dst seq. number = " << m_destSeqNumber << "std::endl";
7.12 - os << " metric = " << m_metric << "std::endl";
7.13 + os << " flags = " << (int) m_flags << std::endl;
7.14 + os << " hop count = " << (int) m_hopcount << std::endl;
7.15 + os << " TTL = " << (int) m_ttl << std::endl;
7.16 + os << " originator address = " << m_originatorAddress << std::endl;
7.17 + os << " dst seq. number = " << m_destSeqNumber << std::endl;
7.18 + os << " metric = " << m_metric << std::endl;
7.19 os << "</information_element>" << std::endl;
7.20 }
7.21