nodes.Add(node);
ns3netcard->node_num = number_of_nodes++;
-
xbt_lib_set(as_router_lib, id, NS3_ASR_LEVEL, ns3netcard );
}
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);
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);
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);
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");
//
// 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.
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)
{
//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> ();
*/
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
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;
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)