From 9b09daa8745bf49e5159272409194189cbcdb7c3 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Wed, 18 Mar 2009 14:36:00 +0300 Subject: [PATCH] Fixed ticket #27 --- src/devices/mesh/hwmp-rtable.cc | 20 +++++------ src/devices/mesh/hwmp-rtable.h | 3 +- src/devices/mesh/hwmp-state.cc | 6 ++-- src/devices/mesh/hwmp-state.h | 4 +-- src/devices/mesh/hwmp.cc | 12 +++---- src/devices/mesh/hwmp.h | 5 ++- src/devices/mesh/mac48-address-comparator.h | 40 --------------------- src/devices/mesh/mesh-wifi-mac.h | 3 +- src/devices/mesh/wscript | 1 - 9 files changed, 25 insertions(+), 69 deletions(-) delete mode 100644 src/devices/mesh/mac48-address-comparator.h diff --git a/src/devices/mesh/hwmp-rtable.cc b/src/devices/mesh/hwmp-rtable.cc index a54c1d496..ff44e9a72 100644 --- a/src/devices/mesh/hwmp-rtable.cc +++ b/src/devices/mesh/hwmp-rtable.cc @@ -70,7 +70,7 @@ HwmpRtable::AddReactivePath( uint32_t seqnum ) { - std::map::iterator i = m_routes.find(destination); + std::map::iterator i = m_routes.find(destination); if (i == m_routes.end()) { ReactiveRoute newroute; @@ -135,7 +135,7 @@ void HwmpRtable::AddPrecursor(Mac48Address destination, uint32_t port, Mac48Address precursor) { bool should_add = true; - std::map::iterator i = m_routes.find(destination); + std::map::iterator i = m_routes.find(destination); if ((i != m_routes.end()) && (i->second.port == port)) { for (unsigned int j = 0 ; j < i->second.precursors.size(); j ++) @@ -178,7 +178,7 @@ HwmpRtable::DeleteProactivePath(Mac48Address root, uint32_t port) void HwmpRtable::DeleteReactivePath(Mac48Address destination, uint32_t port) { - std::map::iterator i = m_routes.find(destination); + std::map::iterator i = m_routes.find(destination); if (i != m_routes.end()) if (i->second.port == port) m_routes.erase(i); @@ -192,7 +192,7 @@ HwmpRtable::LookupReactive(Mac48Address destination) result.metric = MAX_METRIC; result.ifIndex = PORT_ANY; - std::map::iterator i = m_routes.find(destination); + std::map::iterator i = m_routes.find(destination); if (i == m_routes.end()) return result; result.ifIndex = i->second.port; @@ -213,7 +213,7 @@ HwmpRtable::LookupProactive(uint32_t port) result.retransmitter = Mac48Address::GetBroadcast(); result.metric = MAX_METRIC; result.ifIndex = PORT_ANY; - std::map::iterator i = m_roots.find(port); + std::map::iterator i = m_roots.find(port); if (i == m_roots.end()) return result; result.ifIndex = i->first; @@ -229,7 +229,7 @@ std::vector HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress, uint32_t port) { std::vector retval; - for (std::map::iterator i = m_routes.begin(); i!= m_routes.end(); i++) + for (std::map::iterator i = m_routes.begin(); i!= m_routes.end(); i++) if ((i->second.retransmitter == peerAddress)&&(i->second.port == port)) { FailedDestination dst; @@ -241,7 +241,7 @@ HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress, uint32_t port) /** * Lookup a path to root */ - std::map::iterator i = m_roots.find(port); + std::map::iterator i = m_roots.find(port); if ((i != m_roots.end())&&(i->second.retransmitter == peerAddress)) { FailedDestination dst; @@ -254,7 +254,7 @@ HwmpRtable::GetUnreachableDestinations(Mac48Address peerAddress, uint32_t port) uint32_t HwmpRtable::RequestSeqnum(Mac48Address destination) { - std::map::iterator i = m_routes.find(destination); + std::map::iterator i = m_routes.find(destination); if (i == m_routes.end()) return 0; return i->second.seqnum; @@ -264,13 +264,13 @@ std::vector HwmpRtable::GetPrecursors(Mac48Address destination, uint32_t port) { std::vector retval; - std::map::iterator root = m_roots.find(port); + std::map::iterator root = m_roots.find(port); if ((root != m_roots.end()) &&(root->second.root == destination)) { for (unsigned int i = 0; i < root->second.precursors.size(); i ++) retval.push_back(root->second.precursors[i]); } - std::map::iterator route = m_routes.find(destination); + std::map::iterator route = m_routes.find(destination); if ( (route != m_routes.end()) && (route->second.port == port) ) { for (unsigned int i = 0; i < route->second.precursors.size(); i ++) diff --git a/src/devices/mesh/hwmp-rtable.h b/src/devices/mesh/hwmp-rtable.h index e23eb9d9d..65ad9cf9a 100644 --- a/src/devices/mesh/hwmp-rtable.h +++ b/src/devices/mesh/hwmp-rtable.h @@ -26,7 +26,6 @@ #include #include "ns3/nstime.h" #include "ns3/mac48-address.h" -#include "ns3/mac48-address-comparator.h" #include "ns3/net-device.h" #include "ns3/event-id.h" #include "ns3/packet.h" @@ -101,7 +100,7 @@ private: uint32_t seqnum; std::vector precursors; }; - std::map m_routes; + std::map m_routes; std::map m_roots; }; } //namespace ns3 diff --git a/src/devices/mesh/hwmp-state.cc b/src/devices/mesh/hwmp-state.cc index acb75202f..e6f80eb4b 100644 --- a/src/devices/mesh/hwmp-state.cc +++ b/src/devices/mesh/hwmp-state.cc @@ -184,7 +184,7 @@ HwmpState::ReceivePreq(IeDot11sPreq& preq, const Mac48Address& from, const uint if (preq.GetTtl() == 0) return; //acceptance cretirea: - std::map::iterator i = m_dsnDatabase.find(preq.GetOriginatorAddress()); + std::map::iterator i = m_dsnDatabase.find(preq.GetOriginatorAddress()); if (i == m_dsnDatabase.end()) { m_dsnDatabase[preq.GetOriginatorAddress()] = preq.GetOriginatorSeqNumber(); @@ -197,7 +197,7 @@ HwmpState::ReceivePreq(IeDot11sPreq& preq, const Mac48Address& from, const uint if (i->second == preq.GetOriginatorSeqNumber()) { //find metric - std::map::iterator j = + std::map::iterator j = m_preqMetricDatabase.find(preq.GetOriginatorAddress()); NS_ASSERT(j != m_dsnDatabase.end()); if (j->second <= preq.GetMetric()) @@ -319,7 +319,7 @@ HwmpState::ReceivePrep(IeDot11sPrep& prep, const Mac48Address& from, const uint3 prep.DecrementTtl(); prep.IncrementMetric(metric); //acceptance cretirea: - std::map::iterator i = m_dsnDatabase.find(prep.GetDestinationAddress()); + std::map::iterator i = m_dsnDatabase.find(prep.GetDestinationAddress()); if (i == m_dsnDatabase.end()) { m_dsnDatabase[prep.GetDestinationAddress()] = prep.GetDestinationSeqNumber(); diff --git a/src/devices/mesh/hwmp-state.h b/src/devices/mesh/hwmp-state.h index aa9f1fdba..97da32d1f 100644 --- a/src/devices/mesh/hwmp-state.h +++ b/src/devices/mesh/hwmp-state.h @@ -161,8 +161,8 @@ private: uint32_t m_preqId; uint32_t m_myDsn; //Seqno and metric database - std::map m_dsnDatabase; - std::map m_preqMetricDatabase; + std::map m_dsnDatabase; + std::map m_preqMetricDatabase; //Disable/enable functionality bool m_disabled; //Proactive PREQ mechanism: diff --git a/src/devices/mesh/hwmp.cc b/src/devices/mesh/hwmp.cc index 93dfa52c9..0f26e7a0d 100644 --- a/src/devices/mesh/hwmp.cc +++ b/src/devices/mesh/hwmp.cc @@ -172,7 +172,7 @@ Hwmp::~Hwmp() void Hwmp::DoDispose() { - for (std::map::iterator i = m_timeoutDatabase.begin(); i != m_timeoutDatabase.end(); i ++) + for (std::map::iterator i = m_timeoutDatabase.begin(); i != m_timeoutDatabase.end(); i ++) i->second.Cancel(); m_timeoutDatabase.clear(); m_seqnoDatabase.clear(); @@ -234,7 +234,7 @@ Hwmp::RequestRoute( //check seqno! if (destination == Mac48Address::GetBroadcast()) { - std::map::iterator i = m_seqnoDatabase.find(source); + std::map::iterator i = m_seqnoDatabase.find(source); if (i == m_seqnoDatabase.end()) m_seqnoDatabase[source] = tag.GetSeqno(); else @@ -608,7 +608,7 @@ Hwmp::DequeuePacket(Mac48Address dst) MeshL2RoutingProtocol::QueuedPacket retval; retval.pkt = NULL; //Ptr in this structure is NULL when queue is empty - std::map, mac48addrComparator>:: iterator i = m_rqueue.find(dst); + std::map >:: iterator i = m_rqueue.find(dst); if (i == m_rqueue.end()) return retval; if ((int)m_rqueue[dst].size() == 0) @@ -648,7 +648,7 @@ Hwmp::SendAllPossiblePackets(Mac48Address dst) bool Hwmp::ShouldSendPreq(Mac48Address dst) { - std::map::iterator i = m_timeoutDatabase.find(dst); + std::map::iterator i = m_timeoutDatabase.find(dst); if (i == m_timeoutDatabase.end()) { m_timeoutDatabase[dst] = Simulator::Schedule( @@ -664,7 +664,7 @@ Hwmp::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) HwmpRtable::LookupResult result = m_rtable->LookupReactive(dst); if (result.retransmitter != Mac48Address::GetBroadcast()) { - std::map::iterator i = m_timeoutDatabase.find(dst); + std::map::iterator i = m_timeoutDatabase.find(dst); NS_ASSERT(i != m_timeoutDatabase.end()); m_timeoutDatabase.erase(i); return; @@ -681,7 +681,7 @@ Hwmp::RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry) break; packet.reply(false, packet.pkt, packet.src, packet.dst, packet.protocol, HwmpRtable::MAX_METRIC); } - std::map::iterator i = m_timeoutDatabase.find(dst); + std::map::iterator i = m_timeoutDatabase.find(dst); NS_ASSERT(i != m_timeoutDatabase.end()); m_timeoutDatabase.erase(i); return; diff --git a/src/devices/mesh/hwmp.h b/src/devices/mesh/hwmp.h index 8f34e5ade..90bea5ce0 100644 --- a/src/devices/mesh/hwmp.h +++ b/src/devices/mesh/hwmp.h @@ -28,7 +28,6 @@ #include "ns3/tag.h" #include "ns3/object.h" #include "ns3/mac48-address.h" -#include "ns3/mac48-address-comparator.h" #include "ns3/mesh-l2-routing-protocol.h" #include "ns3/packet.h" #include "ns3/ptr.h" @@ -249,7 +248,7 @@ private: * \attention mesh seqno is processed at HWMP */ uint32_t m_seqno; - std::map + std::map m_seqnoDatabase; //Timers: /** @@ -269,7 +268,7 @@ private: * Keeps PREQ retry timers for every * destination */ - std::map + std::map m_timeoutDatabase; /** * Configurable parameters: diff --git a/src/devices/mesh/mac48-address-comparator.h b/src/devices/mesh/mac48-address-comparator.h deleted file mode 100644 index 5a40449ee..000000000 --- a/src/devices/mesh/mac48-address-comparator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008,2009 IITP RAS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Kirill Andreev - */ - - -#ifndef MAC48ADDRESS_COMPARATOR -#define MAC48ADDRESS_COMPARATOR -#include "ns3/mac48-address.h" -namespace ns3 { -struct mac48addrComparator -{ - bool operator()(const Mac48Address addr1, Mac48Address addr2) const - { - uint8_t s1[6], s2[6]; - addr1.CopyTo(s1); - addr2.CopyTo(s2); - for (int i = 0; i < 6; i ++) - if (s1[i] > s2[i]) - return true; - return false; - } -}; -}//namespace ns3 -#endif diff --git a/src/devices/mesh/mesh-wifi-mac.h b/src/devices/mesh/mesh-wifi-mac.h index 516471720..70d59fe99 100644 --- a/src/devices/mesh/mesh-wifi-mac.h +++ b/src/devices/mesh/mesh-wifi-mac.h @@ -25,7 +25,6 @@ #include #include #include "ns3/mac48-address.h" -#include "ns3/mac48-address-comparator.h" #include "ns3/mgt-headers.h" #include "ns3/mesh-mgt-headers.h" #include "ns3/callback.h" @@ -370,7 +369,7 @@ private: * \brief metric calculation parameters */ uint32_t CalculateMetric(Mac48Address peerAddress); - std::map + std::map m_metricDatabase; }; diff --git a/src/devices/mesh/wscript b/src/devices/mesh/wscript index 233ca4d1c..f35baef75 100644 --- a/src/devices/mesh/wscript +++ b/src/devices/mesh/wscript @@ -37,7 +37,6 @@ def build(bld): 'hwmp.h', 'tx-statistics.h', 'dot11s-peer-management-element.h', - 'mac48-address-comparator.h', 'hwmp-rtable.h', 'mesh-wifi-peer-manager.h', 'mesh-wifi-mac-header.h',