Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill more dead code in NS3
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 25 Mar 2016 12:10:51 +0000 (13:10 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 25 Mar 2016 12:10:55 +0000 (13:10 +0100)
We don't make no difference between hosts and routers in NS3 anymore

src/surf/network_ns3.cpp
src/surf/ns3/my-point-to-point-helper.cc
src/surf/ns3/my-point-to-point-helper.h
src/surf/ns3/ns3_interface.h

index d559716..f3ee8d4 100644 (file)
@@ -76,7 +76,6 @@ static void simgrid_ns3_add_netcard(simgrid::surf::NetCard* netcard)
   nodes.Add(node);
   ns3netcard->node_num = number_of_nodes++;
 
-
   xbt_lib_set(as_router_lib, id, NS3_ASR_LEVEL, ns3netcard );
 }
 
@@ -141,9 +140,7 @@ static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster)
 
     xbt_assert(host_src && host_dst, "\tns3_add_link from %d to %d",host_src->node_num,host_dst->node_num);
 
-    ns3_add_link(host_src->node_num,NS3_NETWORK_ELEMENT_HOST,
-                 host_dst->node_num,NS3_NETWORK_ELEMENT_HOST,
-                 bw,lat);
+    ns3_add_link(host_src->node_num, host_dst->node_num, bw,lat);
 
     free(router_id);
     free(host_id);
@@ -201,7 +198,7 @@ static void create_ns3_topology(void)
       if (!host_src || !host_dst)
           xbt_die("\tns3_add_link from %d to %d",host_src->node_num,host_dst->node_num);
 
-      ns3_add_link(host_src->node_num,NS3_NETWORK_ELEMENT_HOST,host_dst->node_num,NS3_NETWORK_ELEMENT_HOST,link_bdw,link_lat);
+      ns3_add_link(host_src->node_num, host_dst->node_num, link_bdw, link_lat);
 
       xbt_free(link_bdw);
       xbt_free(link_lat);
@@ -534,9 +531,7 @@ static char* transformIpv4Address (ns3::Ipv4Address from){
   return bprintf("%s",s.c_str());
 }
 
-void ns3_add_link(int src, e_ns3_network_element_type_t type_src,
-          int dst, e_ns3_network_element_type_t type_dst,
-          char *bw, char *lat)
+void ns3_add_link(int src, int dst, char *bw, char *lat)
 {
   if(number_of_links == 1 ) {
     LogComponentEnable("UdpEchoClientApplication", ns3::LOG_LEVEL_INFO);
@@ -556,7 +551,7 @@ void ns3_add_link(int src, e_ns3_network_element_type_t type_src,
   pointToPoint.SetChannelAttribute ("Delay", ns3::StringValue (lat));
   //pointToPoint.EnablePcapAll("test_ns3_trace"); //DEBUG
 
-  netA.Add(pointToPoint.Install (a, type_src, b, type_dst));
+  netA.Add(pointToPoint.Install (a, b));
 
   char * adr = bprintf("%d.%d.0.0",number_of_networks,number_of_links);
   address.SetBase (adr, "255.255.0.0");
index 3e8c62b..bfee854 100644 (file)
@@ -204,7 +204,7 @@ MyPointToPointHelper::EnableAsciiInternal (
 
   //
   // If we are provided an OutputStreamWrapper, we are expected to use it, and
-  // to providd a context.  We are free to come up with our own context if we
+  // to provide a context.  We are free to come up with our own context if we
   // want, and use the AsciiTraceHelper Hook*WithContext functions, but for 
   // compatibility and simplicity, we just use Config::Connect and let it deal
   // with the context.
@@ -245,71 +245,6 @@ MyPointToPointHelper::Install (NodeContainer c)
   return Install (c.Get (0), c.Get (1));
 }
 
-NetDeviceContainer 
-MyPointToPointHelper::Install (Ptr<Node> a, e_ns3_network_element_type_t type_a, Ptr<Node> b, e_ns3_network_element_type_t type_b)
-{
-  NetDeviceContainer container;
-  Ptr<Queue> queueA;
-  Ptr<Queue> queueB;
-
-  Ptr<PointToPointNetDevice> devA = m_deviceFactory.Create<PointToPointNetDevice> ();
-  devA->SetAddress (Mac48Address::Allocate ());
-  a->AddDevice (devA);
-
-  if(type_a == NS3_NETWORK_ELEMENT_ROUTER){
-       queueA = m_queueFactory_red.Create<Queue> ();
-  }
-  else
-         queueA = m_queueFactory.Create<Queue> ();
-  devA->SetQueue (queueA);
-
-  Ptr<PointToPointNetDevice> devB = m_deviceFactory.Create<PointToPointNetDevice> ();
-  devB->SetAddress (Mac48Address::Allocate ());
-  b->AddDevice (devB);
-
-  if(type_b == NS3_NETWORK_ELEMENT_ROUTER){
-       queueB = m_queueFactory_red.Create<Queue> ();
-  }
-  else
-         queueB = m_queueFactory.Create<Queue> ();
-  devB->SetQueue (queueB);
-
-  // If MPI is enabled, we need to see if both nodes have the same system id 
-  // (rank), and the rank is the same as this instance.  If both are true, 
-  //use a normal p2p channel, otherwise use a remote channel
-  bool useNormalChannel = true;
-  Ptr<PointToPointChannel> channel = 0;
-  if (MpiInterface::IsEnabled ())
-    {
-      uint32_t n1SystemId = a->GetSystemId ();
-      uint32_t n2SystemId = b->GetSystemId ();
-      uint32_t currSystemId = MpiInterface::GetSystemId ();
-      if (n1SystemId != currSystemId || n2SystemId != currSystemId) 
-          useNormalChannel = false;
-    }
-  if (useNormalChannel)
-    {
-      channel = m_channelFactory.Create<PointToPointChannel> ();
-    }
-  else
-    {
-      channel = m_remoteChannelFactory.Create<PointToPointRemoteChannel> ();
-      Ptr<MpiReceiver> mpiRecA = CreateObject<MpiReceiver> ();
-      Ptr<MpiReceiver> mpiRecB = CreateObject<MpiReceiver> ();
-      mpiRecA->SetReceiveCallback (MakeCallback (&PointToPointNetDevice::Receive, devA));
-      mpiRecB->SetReceiveCallback (MakeCallback (&PointToPointNetDevice::Receive, devB));
-      devA->AggregateObject (mpiRecA);
-      devB->AggregateObject (mpiRecB);
-    }
-
-  devA->Attach (channel);
-  devB->Attach (channel);
-  container.Add (devA);
-  container.Add (devB);
-
-  return container;
-}
-
 NetDeviceContainer 
 MyPointToPointHelper::Install (Ptr<Node> a, Ptr<Node> b)
 {
@@ -330,20 +265,16 @@ MyPointToPointHelper::Install (Ptr<Node> a, Ptr<Node> b)
   //use a normal p2p channel, otherwise use a remote channel
   bool useNormalChannel = true;
   Ptr<PointToPointChannel> channel = 0;
-  if (MpiInterface::IsEnabled ())
-    {
+  if (MpiInterface::IsEnabled ()) {
       uint32_t n1SystemId = a->GetSystemId ();
       uint32_t n2SystemId = b->GetSystemId ();
       uint32_t currSystemId = MpiInterface::GetSystemId ();
       if (n1SystemId != currSystemId || n2SystemId != currSystemId)
           useNormalChannel = false;
-    }
+  }
   if (useNormalChannel)
-    {
       channel = m_channelFactory.Create<PointToPointChannel> ();
-    }
-  else
-    {
+  else {
       channel = m_remoteChannelFactory.Create<PointToPointRemoteChannel> ();
       Ptr<MpiReceiver> mpiRecA = CreateObject<MpiReceiver> ();
       Ptr<MpiReceiver> mpiRecB = CreateObject<MpiReceiver> ();
index 3911f00..e199cee 100644 (file)
@@ -133,16 +133,6 @@ public:
    */
   NetDeviceContainer Install (Ptr<Node> a, Ptr<Node> b);
 
-  /**
-   * \param a first node
-   * \param b second node
-   *
-   * Saves you from having to construct a temporary NodeContainer.
-   * Also, if MPI is enabled, for distributed simulations,
-   * appropriate remote point-to-point channels are created.
-   */
-  NetDeviceContainer Install (Ptr<Node> a, e_ns3_network_element_type_t type_a, Ptr<Node> b, e_ns3_network_element_type_t type_b);
-
   /**
    * \param a first node
    * \param bName name of second node
index 33ce2eb..07ccc66 100644 (file)
@@ -21,13 +21,6 @@ namespace simgrid{
     class NetworkNS3Action;
   }
 }
-typedef enum {
-  NS3_NETWORK_ELEMENT_NULL = 0,    /* NULL */
-  NS3_NETWORK_ELEMENT_HOST,      /* host type */
-  NS3_NETWORK_ELEMENT_ROUTER,     /* router type */
-  NS3_NETWORK_ELEMENT_AS,        /* AS type */
-} e_ns3_network_element_type_t;
-
 
 typedef struct ns3_node {
   int node_num;
@@ -42,11 +35,9 @@ XBT_PUBLIC(void)   ns3_create_flow(const char* a,const char *b,double start,u_in
 XBT_PUBLIC(void)   ns3_simulator(double min);
 XBT_PUBLIC(void *) ns3_add_host_cluster(const char * id);
 XBT_PUBLIC(void *) ns3_add_router(const char * id);
-XBT_PUBLIC(void) ns3_add_link(int src, e_ns3_network_element_type_t type_src,
-                int dst, e_ns3_network_element_type_t type_dst,
-                char * bw,char * lat);
-XBT_PUBLIC(void) ns3_end_platform(void);
-XBT_PUBLIC(void) ns3_add_cluster(char * bw,char * lat,const char *id);
+XBT_PUBLIC(void)   ns3_add_link(int src, int dst, char * bw,char * lat);
+XBT_PUBLIC(void)   ns3_add_cluster(char * bw,char * lat,const char *id);
+XBT_PUBLIC(void)   ns3_end_platform(void);
 
 inline
 ns3_node_t ns3_find_host(const char* id)