From 44fa63fad4fb9a5e8109a381cec97d78d0f26671 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 25 Mar 2016 13:10:51 +0100 Subject: [PATCH 1/1] kill more dead code in NS3 We don't make no difference between hosts and routers in NS3 anymore --- src/surf/network_ns3.cpp | 13 ++-- src/surf/ns3/my-point-to-point-helper.cc | 77 ++---------------------- src/surf/ns3/my-point-to-point-helper.h | 10 --- src/surf/ns3/ns3_interface.h | 15 +---- 4 files changed, 11 insertions(+), 104 deletions(-) diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index d559716f3b..f3ee8d4027 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -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"); diff --git a/src/surf/ns3/my-point-to-point-helper.cc b/src/surf/ns3/my-point-to-point-helper.cc index 3e8c62bc5d..bfee8545d4 100644 --- a/src/surf/ns3/my-point-to-point-helper.cc +++ b/src/surf/ns3/my-point-to-point-helper.cc @@ -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 a, e_ns3_network_element_type_t type_a, Ptr b, e_ns3_network_element_type_t type_b) -{ - NetDeviceContainer container; - Ptr queueA; - Ptr queueB; - - Ptr devA = m_deviceFactory.Create (); - devA->SetAddress (Mac48Address::Allocate ()); - a->AddDevice (devA); - - if(type_a == NS3_NETWORK_ELEMENT_ROUTER){ - queueA = m_queueFactory_red.Create (); - } - else - queueA = m_queueFactory.Create (); - devA->SetQueue (queueA); - - Ptr devB = m_deviceFactory.Create (); - devB->SetAddress (Mac48Address::Allocate ()); - b->AddDevice (devB); - - if(type_b == NS3_NETWORK_ELEMENT_ROUTER){ - queueB = m_queueFactory_red.Create (); - } - else - queueB = m_queueFactory.Create (); - 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 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 (); - } - else - { - channel = m_remoteChannelFactory.Create (); - Ptr mpiRecA = CreateObject (); - Ptr mpiRecB = CreateObject (); - 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 a, Ptr b) { @@ -330,20 +265,16 @@ MyPointToPointHelper::Install (Ptr a, Ptr b) //use a normal p2p channel, otherwise use a remote channel bool useNormalChannel = true; Ptr 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 (); - } - else - { + else { channel = m_remoteChannelFactory.Create (); Ptr mpiRecA = CreateObject (); Ptr mpiRecB = CreateObject (); diff --git a/src/surf/ns3/my-point-to-point-helper.h b/src/surf/ns3/my-point-to-point-helper.h index 3911f0098d..e199cee3de 100644 --- a/src/surf/ns3/my-point-to-point-helper.h +++ b/src/surf/ns3/my-point-to-point-helper.h @@ -133,16 +133,6 @@ public: */ NetDeviceContainer Install (Ptr a, Ptr 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 a, e_ns3_network_element_type_t type_a, Ptr b, e_ns3_network_element_type_t type_b); - /** * \param a first node * \param bName name of second node diff --git a/src/surf/ns3/ns3_interface.h b/src/surf/ns3/ns3_interface.h index 33ce2eb510..07ccc66f1e 100644 --- a/src/surf/ns3/ns3_interface.h +++ b/src/surf/ns3/ns3_interface.h @@ -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) -- 2.20.1