diff options
Diffstat (limited to 'ns3-simulator/modules/platform.cc')
| -rw-r--r-- | ns3-simulator/modules/platform.cc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/ns3-simulator/modules/platform.cc b/ns3-simulator/modules/platform.cc index 81d53cb..82c293d 100644 --- a/ns3-simulator/modules/platform.cc +++ b/ns3-simulator/modules/platform.cc @@ -58,7 +58,7 @@ Cell createCell(uint32_t nbSensors, Ptr<ns3::Node> ap){ /** * Install network stack and applications */ -void applyScenarios(Cell cell,int sensorsPktSize, int sensorsSendInterval, CloudInfos cloudInfos){ +void setupScenario(Cell cell, CloudInfos cloudInfos, int sensorsPktSize, int sensorsSendInterval){ NodeContainer ap=cell.first.first; NodeContainer sensors=cell.first.second; NetDeviceContainer apNetDev= cell.second.first; @@ -69,7 +69,7 @@ void applyScenarios(Cell cell,int sensorsPktSize, int sensorsSendInterval, Cloud // internet.Install (ap); internet.Install (sensors); Ipv4AddressHelper ipv4; - ipv4.SetBase ("10.0.0.0", "255.255.255.0"); + ipv4.SetBase ("10.0.0.0", "255.255.0.0"); Ipv4InterfaceContainer apInt,sensorsInt; apInt=ipv4.Assign(apNetDev); sensorsInt=ipv4.Assign(sensorsNetDev); @@ -85,22 +85,22 @@ void applyScenarios(Cell cell,int sensorsPktSize, int sensorsSendInterval, Cloud echoClientHelper.Install (sensors); } -CloudInfos buildEdgeAndCloud(int nbOp){ - - NodeContainer OpNodes; - OpNodes.Create(nbOp); +CloudInfos createCloud(int nbHop, uint32_t bandwidth, uint32_t latency){ + + NodeContainer HopNodes; + HopNodes.Create(nbHop); InternetStackHelper stack; - stack.Install(OpNodes); + stack.Install(HopNodes); - Ipv4Address cloudIP; - int cloudPort=99; - for(int i=0;i<nbOp-1;i++){ - NodeContainer curNodes(OpNodes.Get(i),OpNodes.Get(i+1)); + Ipv4Address cloudIP; // Will be fill in the following for loop + int cloudPort=80; + for(int i=0;i<nbHop-1;i++){ + NodeContainer curNodes(HopNodes.Get(i),HopNodes.Get(i+1)); PointToPointHelper pointToPoint; - pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); - pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); + pointToPoint.SetDeviceAttribute ("DataRate", StringValue ((std::to_string(bandwidth)+"Mbps").c_str())); + pointToPoint.SetChannelAttribute ("Delay", StringValue ((std::to_string(latency)+"ms").c_str())); NetDeviceContainer p2pDevices; p2pDevices = pointToPoint.Install (curNodes); @@ -110,7 +110,7 @@ CloudInfos buildEdgeAndCloud(int nbOp){ Ipv4InterfaceContainer p2pInterfaces; p2pInterfaces = address.Assign (p2pDevices); - if(i==nbOp-2){ // If we are on the last FOR LOOP + if(i==nbHop-2){ // If we are on the last for loop (before last node) cloudIP=p2pInterfaces.GetAddress (1); // Get Last node interface PacketSinkHelper apSink("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), cloudPort)); ApplicationContainer sinkApp=apSink.Install(curNodes.Get(1)); // Instal sink on last node @@ -119,6 +119,6 @@ CloudInfos buildEdgeAndCloud(int nbOp){ } } - return(std::make_pair(OpNodes,std::make_pair(cloudIP,cloudPort))); + return(std::make_pair(HopNodes,std::make_pair(cloudIP,cloudPort))); } |
