Clean up of connection-manager.cc and connection-manager.h
authoriamine@localhost.localdomain
Mon, 18 Jan 2010 16:57:47 +0100
changeset 4626 8cef8e51c99e
parent 4625 b2154f03b812
child 4627 d101adc17bd3
Clean up of connection-manager.cc and connection-manager.h
src/devices/wimax/bs-net-device.cc
src/devices/wimax/bs-net-device.h
src/devices/wimax/connection-manager.cc
src/devices/wimax/connection-manager.h
--- a/src/devices/wimax/bs-net-device.cc	Mon Jan 18 16:10:10 2010 +0100
+++ b/src/devices/wimax/bs-net-device.cc	Mon Jan 18 16:57:47 2010 +0100
@@ -207,11 +207,8 @@
   m_ulAllocationNumber = 0;
   m_rangingOppNumber = 0;
   m_allocationStartTime = 0;
-
   m_psDuration = Seconds (0);
-
   m_symbolDuration = Seconds (0);
-
   m_linkManager = CreateObject<BSLinkManager> (this);
   m_cidFactory = new CidFactory ();
   m_ssManager = CreateObject<SSManager> ();
@@ -729,8 +726,7 @@
           source = m_ssManager->GetMacAddress (cid);
           //m_traceBSRx (packet, source, &cid);
           m_bsRxTrace (packet);
-          Mac48Address dest = GetConnectionManager ()->GetDestAddress (cid);
-          ForwardUp (packet->Copy (), source, dest);
+          ForwardUp (packet->Copy (), source, Mac48Address("ff:ff:ff:ff:ff:ff"));
         }
     }
   else
@@ -1029,16 +1025,6 @@
   return connection;
 }
 
-void BaseStationNetDevice::SetupConnection (Ptr<SubscriberStationNetDevice> ss1, Ptr<SubscriberStationNetDevice> ss2)
-{
-  GetConnectionManager ()->SetupConnection (ss1, ss2);
-}
-
-void BaseStationNetDevice::SetupConnection (Ptr<SubscriberStationNetDevice> ss)
-{
-  GetConnectionManager ()->SetupConnection (ss);
-}
-
 void BaseStationNetDevice::MarkUplinkAllocations (void)
 {
   uint16_t symbolsToAllocation = 0;
--- a/src/devices/wimax/bs-net-device.h	Mon Jan 18 16:10:10 2010 +0100
+++ b/src/devices/wimax/bs-net-device.h	Mon Jan 18 16:57:47 2010 +0100
@@ -32,8 +32,7 @@
 #include "dl-mac-messages.h"
 #include "ipcs-classifier.h"
 
-namespace ns3
-{
+namespace ns3 {
 
 class Node;
 class Packet;
@@ -61,8 +60,10 @@
   static TypeId GetTypeId (void);
   BaseStationNetDevice (void);
   BaseStationNetDevice (Ptr<Node> node, Ptr<WimaxPhy> phy);
-  BaseStationNetDevice (Ptr<Node> node, Ptr<WimaxPhy> phy, Ptr<
-      UplinkScheduler> uplinkScheduler, Ptr<BSScheduler> bsScheduler);
+  BaseStationNetDevice (Ptr<Node> node,
+                        Ptr<WimaxPhy> phy,
+                        Ptr<UplinkScheduler> uplinkScheduler,
+                        Ptr<BSScheduler> bsScheduler);
   ~BaseStationNetDevice (void);
 
   void SetInitialRangingInterval (Time initialRangInterval);
@@ -116,14 +117,9 @@
   void Start (void);
   void Stop (void);
 
-  bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType,
-                Ptr<WimaxConnection> connection);
+  bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType, Ptr<WimaxConnection> connection);
   Ptr<WimaxConnection> GetConnection (Cid cid);
 
-  void SetupConnection (Ptr<SubscriberStationNetDevice> ss1, Ptr<
-      SubscriberStationNetDevice> ss2);
-  void SetupConnection (Ptr<SubscriberStationNetDevice> ss);
-
   void MarkUplinkAllocations (void);
   void MarkRangingOppStart (Time rangingOppStartTime);
 
@@ -139,8 +135,7 @@
   void EndUlSubFrame (void);
   void EndFrame (void);
 
-  bool DoSend (Ptr<Packet> packet, const Mac48Address& source,
-      const Mac48Address& dest, uint16_t protocolNumber);
+  bool DoSend (Ptr<Packet> packet, const Mac48Address& source, const Mac48Address& dest, uint16_t protocolNumber);
   void DoReceive (Ptr<Packet> packet);
   /**
    * \brief creates the MAC management messages DL-MAP and UL-MAP
@@ -160,8 +155,7 @@
   void SetUlBurstProfiles (Ucd *ucd);
 
   void MarkUplinkAllocationStart (Time allocationStartTime);
-  void MarkUplinkAllocationEnd (Time allocationEndTime,
-                                Cid cid, uint8_t uiuc);
+  void MarkUplinkAllocationEnd (Time allocationEndTime, Cid cid, uint8_t uiuc);
   void UplinkAllocationStart (void);
   void UplinkAllocationEnd (Cid cid, uint8_t uiuc);
   void RangingOppStart (void);
--- a/src/devices/wimax/connection-manager.cc	Mon Jan 18 16:10:10 2010 +0100
+++ b/src/devices/wimax/connection-manager.cc	Mon Jan 18 16:57:47 2010 +0100
@@ -36,17 +36,12 @@
 namespace ns3 {
 
 ConnectionManager::ConnectionManager (void) :
-  m_cidFactory (0), m_connectionSetupList (new std::list<std::pair<std::pair<Mac48Address, Cid>, std::pair<
-      Mac48Address, Cid> > >), m_connectionSetupList2 (new std::list<std::pair<Mac48Address, Cid> >)
+  m_cidFactory (0)
 {
 }
 
 void ConnectionManager::DoDispose (void)
 {
-  delete m_connectionSetupList;
-  delete m_connectionSetupList2;
-  m_connectionSetupList = 0;
-  m_connectionSetupList2 = 0;
 }
 
 ConnectionManager::~ConnectionManager (void)
@@ -80,8 +75,7 @@
       cid = m_cidFactory->Allocate (type);
       break;
     case Cid::TRANSPORT:
-      //retrieving CID already assigned during connection setup at application level
-      cid = GetSetupConnection (ssRecord->GetMacAddress ());
+      cid = m_cidFactory->AllocateTransportOrSecondary ();
       break;
     default:
       NS_FATAL_ERROR ("Invalid connection type");
@@ -233,126 +227,6 @@
 
   return false;
 }
-
-void ConnectionManager::SetupConnection (Ptr<SubscriberStationNetDevice> ss1, Ptr<SubscriberStationNetDevice> ss2)
-{
-  Cid cid1 = m_cidFactory->AllocateTransportOrSecondary ();
-  Cid cid2 = m_cidFactory->AllocateTransportOrSecondary ();
-
-  std::pair<Mac48Address, Cid> peer1 = std::make_pair (ss1->GetMacAddress (), cid1);
-
-  std::pair<Mac48Address, Cid> peer2 = std::make_pair (ss2->GetMacAddress (), cid2);
-
-  m_connectionSetupList->push_back (std::make_pair (peer1, peer2));
-}
-
-void ConnectionManager::SetupConnection (Ptr<SubscriberStationNetDevice> ss)
-{
-  Cid cid = m_cidFactory->AllocateTransportOrSecondary ();
-  std::pair<Mac48Address, Cid> peer = std::make_pair (ss->GetMacAddress (), cid);
-  m_connectionSetupList2->push_back (peer);
-}
-
-Cid ConnectionManager::GetSetupConnection (const Mac48Address &address) const
-{
-  //assumes there is only one transport connection per SS, otherwise will return only the first one
-
-  Cid cid = m_cidFactory->AllocateTransportOrSecondary ();
-  std::pair<std::pair<Mac48Address, Cid>, std::pair<Mac48Address, Cid> > pair;
-
-  std::list<std::pair<std::pair<Mac48Address, Cid>, std::pair<Mac48Address, Cid> > >::const_iterator iter;
-
-  for (iter = m_connectionSetupList->begin (); iter != m_connectionSetupList->end (); ++iter)
-    {
-      pair = *iter;
-      if (address == pair.first.first)
-        {
-          cid = pair.first.second;
-          break;
-        }
-      else if (address == pair.second.first)
-        {
-          cid = pair.second.second;
-          break;
-        }
-    }
-  return cid;
-}
-
-Cid ConnectionManager::GetSetupConnection2 (const Mac48Address &address) const
-{
-  //assumes there is only one transport connection per SS, otherwise will return only the first one
-
-  Cid cid;
-  std::pair<Mac48Address, Cid> pair;
-
-  std::list<std::pair<Mac48Address, Cid> >::const_iterator iter;
-
-  for (iter = m_connectionSetupList2->begin (); iter != m_connectionSetupList2->end (); ++iter)
-    {
-      pair = *iter;
-      if (address == pair.first)
-        {
-          cid = pair.second;
-          break;
-        }
-    }
-
-  return cid;
-}
-
-Mac48Address ConnectionManager::GetDestAddress2 (Cid cid) const
-{
-  Mac48Address address;
-  std::pair<Mac48Address, Cid> pair;
-  std::list<std::pair<Mac48Address, Cid> >::const_iterator iter;
-
-  for (iter = m_connectionSetupList2->begin (); iter != m_connectionSetupList2->end (); ++iter)
-    {
-      pair = *iter;
-
-      if (cid == pair.second)
-        {
-          address = pair.first;
-          break;
-        }
-    }
-
-  return address;
-
-}
-
-Mac48Address ConnectionManager::GetDestAddress (Cid cid) const
-{
-  Mac48Address address;
-  std::pair<Mac48Address, Cid> peer1, peer2;
-  std::pair<std::pair<Mac48Address, Cid>, std::pair<Mac48Address, Cid> > pair;
-
-  std::list<std::pair<std::pair<Mac48Address, Cid>, std::pair<Mac48Address, Cid> > >::const_iterator iter;
-  bool find = false;
-  for (iter = m_connectionSetupList->begin (); iter != m_connectionSetupList->end (); ++iter)
-    {
-      pair = *iter;
-      if (cid == pair.first.second)
-        {
-          address = pair.second.first;
-          find = true;
-          break;
-        }
-      else if (cid == pair.second.second)
-        {
-          address = pair.first.first;
-          find = true;
-          break;
-        }
-    }
-  if (find == false)
-    {
-      return GetDestAddress2 (cid);
-    }
-  return address;
-}
-
 } // namespace ns3
 
 
--- a/src/devices/wimax/connection-manager.h	Mon Jan 18 16:10:10 2010 +0100
+++ b/src/devices/wimax/connection-manager.h	Mon Jan 18 16:57:47 2010 +0100
@@ -54,37 +54,14 @@
   std::vector<Ptr<WimaxConnection> > GetConnections (Cid::Type type) const;
   uint32_t GetNPackets (Cid::Type type, ServiceFlow::SchedulingType schedulingType) const;
   bool HasPackets (void) const;
-
-  /*
-   Only for BS, called from application level, setups connection between two subscriber
-   stations (and their transport connections)
-   */
-  void SetupConnection (Ptr<SubscriberStationNetDevice> ss1, Ptr<SubscriberStationNetDevice> ss2);
-  void SetupConnection (Ptr<SubscriberStationNetDevice> ss1);
-  /*
-   Only for BS, retrieves CID already assigned during connection setup at application level
-   */
-  Cid GetSetupConnection (const Mac48Address &address) const;
-
-  Cid GetSetupConnection2 (const Mac48Address &address) const;
-  /*
-   Only for BS, retrieves other peer's (destination's) CID corresponding to this CID (of source)
-   as setup at application level, and retrieves the MAC address of the peer/destination
-   */
-  Mac48Address GetDestAddress (Cid cid) const;
-  Mac48Address GetDestAddress2 (Cid cid) const;
 private:
   //the following two are only for BS, SS only has one basic and primary CID and maintains as its members
   std::vector<Ptr<WimaxConnection> > m_basicConnections;
   std::vector<Ptr<WimaxConnection> > m_primaryConnections;
-
   std::vector<Ptr<WimaxConnection> > m_transportConnections;
   std::vector<Ptr<WimaxConnection> > m_multicastConnections;
   //only for BS
   CidFactory *m_cidFactory;
-  std::list<std::pair<std::pair<Mac48Address, Cid>, std::pair<Mac48Address, Cid> > > *m_connectionSetupList;
-  std::list<std::pair<Mac48Address, Cid> > *m_connectionSetupList2;
-
 };
 
 }