From e32c8d2317675d1fd868dbffd75ff6d8f72e29f0 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Sun, 22 Mar 2009 20:54:04 +0300 Subject: [PATCH] Bugfixes --- examples/mesh.cc | 4 +- src/devices/mesh/802.11s/peer-link.cc | 1 + .../mesh/802.11s/peer-manager-protocol.cc | 90 ++++++------------- 3 files changed, 31 insertions(+), 64 deletions(-) diff --git a/examples/mesh.cc b/examples/mesh.cc index 5c593a5ec..c2095a989 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -38,8 +38,8 @@ int main (int argc, char *argv[]) { // Creating square topology with nNodes x nNodes grid: - int xSize = 5; - int ySize = 5; + int xSize = 1; + int ySize = 2; double step = 100.0; //Grid with one-hop edge double randomStart = 0.1; //One beacon interval NodeContainer nodes; diff --git a/src/devices/mesh/802.11s/peer-link.cc b/src/devices/mesh/802.11s/peer-link.cc index 7fbcc8183..1ae88276f 100644 --- a/src/devices/mesh/802.11s/peer-link.cc +++ b/src/devices/mesh/802.11s/peer-link.cc @@ -255,6 +255,7 @@ PeerLink::SetMacPlugin(Ptr plugin) void PeerLink::StateMachine (PeerEvent event,dot11sReasonCode reasoncode) { + NS_LOG_UNCOND("state = "< > interfaces) { - NS_LOG_UNCOND("Peer manager attach interfaces started!"); for(std::vector >::iterator i = interfaces.begin(); i != interfaces.end(); i ++) { MeshWifiInterfaceMac * mac = dynamic_cast (PeekPointer ((*i)->GetMac ())); @@ -126,7 +123,6 @@ Ptr Dot11sPeerManagerProtocol::SendBeacon(uint32_t interface, Time currentTbtt, Time beaconInterval) { Ptr retval = Create (); - NS_LOG_UNCOND("I am sending a beacon"); BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface); if(i == m_neighbourBeacons.end()) return retval; @@ -147,11 +143,9 @@ Dot11sPeerManagerProtocol::SendBeacon(uint32_t interface, Time currentTbtt, Time void Dot11sPeerManagerProtocol::FillBeaconInfo(uint32_t interface, Mac48Address peerAddress, Time receivingTime, Time beaconInterval) { - NS_LOG_UNCOND("FILL started!"); BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface); if(i == m_neighbourBeacons.end()) { - NS_LOG_UNCOND("First beacon from this interface"); BeaconsOnInterface newMap; m_neighbourBeacons[interface] = newMap; } @@ -159,7 +153,6 @@ Dot11sPeerManagerProtocol::FillBeaconInfo(uint32_t interface, Mac48Address peerA BeaconsOnInterface::iterator j = i->second.find(peerAddress); if(j == i->second.end()) { - NS_LOG_UNCOND("first beacon from this station"); BeaconInfo newInfo; newInfo.referenceTbtt = receivingTime; newInfo.beaconInterval = beaconInterval; @@ -170,9 +163,7 @@ Dot11sPeerManagerProtocol::FillBeaconInfo(uint32_t interface, Mac48Address peerA } else { - NS_LOG_UNCOND("last beacon was at"<second.referenceTbtt); j->second.referenceTbtt = receivingTime; - NS_LOG_UNCOND("now beacon is at"<second.referenceTbtt); j->second.beaconInterval = beaconInterval; } } @@ -186,40 +177,6 @@ Dot11sPeerManagerProtocol::ReceiveBeacon( Time receivingTime, Time beaconInterval) { - NS_LOG_UNCOND("Beacon received from "<second.find(peerAddress); - if(j == i->second.end()) - { - NS_LOG_UNCOND("first beacon from this station"); - BeaconInfo newInfo; - newInfo.referenceTbtt = receivingTime; - newInfo.beaconInterval = beaconInterval; - newInfo.aid = m_lastAssocId++; - if(m_lastAssocId == 0xff) - m_lastAssocId = 0; - i->second[peerAddress] = newInfo; - } - else - { - NS_LOG_UNCOND("last beacon was at"<second.referenceTbtt); - j->second.referenceTbtt = receivingTime; - NS_LOG_UNCOND("now beacon is at"<second.referenceTbtt); - j->second.beaconInterval = beaconInterval; - } - } -#endif FillBeaconInfo(interface, peerAddress, receivingTime, beaconInterval); if(!meshBeacon) return; @@ -235,6 +192,7 @@ Dot11sPeerManagerProtocol::ReceiveBeacon( return; } } + NS_LOG_UNCOND("NOT found"<<__LINE__); PeerManagerPluginMap::iterator plugin = m_plugins.find (interface); NS_ASSERT(plugin != m_plugins.end()); Ptr new_link = InitiateLink (interface, peerAddress, receivingTime, beaconInterval); @@ -253,28 +211,26 @@ Dot11sPeerManagerProtocol::ReceivePeerLinkFrame ( IeDot11sConfiguration meshConfig ) { - NS_LOG_UNCOND("Receive Peer Link Frame"); if (peerManagementElement.SubtypeIsOpen ()) { - NS_LOG_UNCOND("OPEN"); dot11sReasonCode reasonCode; bool reject = ! (ShouldAcceptOpen (interface, peerAddress,reasonCode)); PeerLinksMap::iterator iface = m_peerLinks.find (interface); NS_ASSERT (iface != m_peerLinks.end()); for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end(); i++) if ((*i)->GetPeerAddress () == peerAddress) - if (!ShouldAcceptOpen (interface, peerAddress,reasonCode)) + { + if(!reject) { - if(!reject) - { - //Drop from INIT state: - //(*i)->MLMEPassivePeerLinkOpen (); - (*i)->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig); - } - else - (*i)->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, reasonCode); - return; + //Drop from INIT state: + //(*i)->MLMEPassivePeerLinkOpen (); + (*i)->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig); } + else + (*i)->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, reasonCode); + return; + } + NS_LOG_UNCOND("NOT found"<<__LINE__); Ptr new_link = InitiateLink ( interface, peerAddress, @@ -284,6 +240,7 @@ Dot11sPeerManagerProtocol::ReceivePeerLinkFrame ( if(!reject) { //Drop from INIT state: + NS_LOG_UNCOND("new link with "< new_link = CreateObject (); if (m_lastLocalLinkId == 0xff) m_lastLocalLinkId = 0; - //the entry about beacon must exist in beacon map + //find a beacon entry BeaconInfoMap::iterator beaconsOnInterface = m_neighbourBeacons.find (interface); if(beaconsOnInterface == m_neighbourBeacons.end()) FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval); BeaconsOnInterface::iterator beacon = beaconsOnInterface->second.find (peerAddress); if(beacon == beaconsOnInterface->second.end ()) FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval); + //find a peer link + PeerLinksMap::iterator iface = m_peerLinks.find (interface); + NS_ASSERT (iface != m_peerLinks.end()); + for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end(); i++) + if ((*i)->GetPeerAddress () == peerAddress) + { + NS_ASSERT(false); + return (*i); + } + PeerManagerPluginMap::iterator plugin = m_plugins.find (interface); NS_ASSERT(plugin != m_plugins.end ()); - NS_LOG_UNCOND("Adding a new descriptor"); new_link->SetLocalAid (beacon->second.aid); new_link->SetLocalLinkId (m_lastLocalLinkId++); new_link->SetPeerAddress (peerAddress); new_link->SetBeaconInformation (lastBeacon, beaconInterval); new_link->SetMacPlugin (plugin->second); new_link->MLMESetSignalStatusCallback (MakeCallback(&Dot11sPeerManagerProtocol::PeerLinkStatus, this)); - m_peerLinks[interface].push_back (new_link); + NS_LOG_UNCOND("pushed"); + iface->second.push_back (new_link); return new_link; } #if 0