int main(int argc, char* argv[]) { // Setting default parameters for PointToPoint links and channels Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps")); Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")); Config::SetDefault("ns3::QueueBase::MaxPackets", UintegerValue(10)); // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize CommandLine cmd; cmd.Parse(argc, argv); // Creating 3x3 topology PointToPointHelper p2p; PointToPointGridHelper grid(3, 3, p2p); grid.BoundingBox(100, 100, 200, 200); // Install NDN stack on all nodes ndn::StackHelper ndnHelper; ndnHelper.InstallAll(); // Set BestRoute strategy ndn::StrategyChoiceHelper::InstallAll("/", "/localhost/nfd/strategy/best-route"); // Installing global routing interface on all nodes ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); // Getting containers for the consumer/producer Ptr<Node> producer = grid.GetNode(2, 2); NodeContainer consumerNodes; consumerNodes.Add(grid.GetNode(0, 0)); // Install NDN applications std::string prefix = "/prefix"; ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); consumerHelper.SetPrefix(prefix); consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second consumerHelper.Install(consumerNodes); ndn::AppHelper producerHelper("ns3::ndn::Producer"); producerHelper.SetPrefix(prefix); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.Install(producer); // Add /prefix origins to ndn::GlobalRouter ndnGlobalRoutingHelper.AddOrigins(prefix, producer); // Calculate and install FIBs ndn::GlobalRoutingHelper::CalculateRoutes(); Simulator::Stop(Seconds(20.0)); Simulator::Run(); Simulator::Destroy(); return 0; }
int main(int argc, char* argv[]) { CommandLine cmd; cmd.Parse(argc, argv); AnnotatedTopologyReader topologyReader("", 25); topologyReader.SetFileName("src/ndnSIM/examples/topologies/topo-grid-3x3-red-queues.txt"); topologyReader.Read(); // Install NDN stack on all nodes ndn::StackHelper ndnHelper; ndnHelper.InstallAll(); ndn::StrategyChoiceHelper::InstallAll("/", "ndn:/localhost/nfd/strategy/best-route"); // Installing global routing interface on all nodes ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); // Getting containers for the consumer/producer Ptr<Node> producer = Names::Find<Node>("Node8"); NodeContainer consumerNodes; consumerNodes.Add(Names::Find<Node>("Node0")); // Install NDN applications std::string prefix = "/prefix"; ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr"); consumerHelper.SetPrefix(prefix); consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second consumerHelper.Install(consumerNodes); ndn::AppHelper producerHelper("ns3::ndn::Producer"); producerHelper.SetPrefix(prefix); producerHelper.SetAttribute("PayloadSize", StringValue("1024")); producerHelper.Install(producer); // Add /prefix origins to ndn::GlobalRouter ndnGlobalRoutingHelper.AddOrigins(prefix, producer); // Calculate and install FIBs ndn::GlobalRoutingHelper::CalculateRoutes(); Simulator::Stop(Seconds(20.0)); Simulator::Run(); Simulator::Destroy(); return 0; }
// Network topology (default) // // n2 + + n3 . // | ... |\ /| ... | . // ======= \ / ======= . // CSMA \ / CSMA . // \ / . // n1 +--- n0 ---+ n4 . // | ... | / \ | ... | . // ======= / \ ======= . // CSMA / \ CSMA . // / \ . // n6 + + n5 . // | ... | | ... | . // ======= ======= . // CSMA CSMA . // void CsmaStarTestCase::DoRun (void) { // // Default number of nodes in the star. // uint32_t nSpokes = 7; CsmaHelper csma; csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); csma.SetChannelAttribute ("Delay", StringValue ("1ms")); CsmaStarHelper star (nSpokes, csma); NodeContainer fillNodes; // // Just to be nasy, hang some more nodes off of the CSMA channel for each // spoke, so that there are a total of 16 nodes on each channel. Stash // all of these new devices into a container. // NetDeviceContainer fillDevices; uint32_t nFill = 14; for (uint32_t i = 0; i < star.GetSpokeDevices ().GetN (); ++i) { Ptr<Channel> channel = star.GetSpokeDevices ().Get (i)->GetChannel (); Ptr<CsmaChannel> csmaChannel = channel->GetObject<CsmaChannel> (); NodeContainer newNodes; newNodes.Create (nFill); fillNodes.Add (newNodes); fillDevices.Add (csma.Install (newNodes, csmaChannel)); } InternetStackHelper internet; star.InstallStack (internet); internet.Install (fillNodes); star.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.0.0", "255.255.255.0")); // // We assigned addresses to the logical hub and the first "drop" of the // CSMA network that acts as the spoke, but we also have a number of fill // devices (nFill) also hanging off the CSMA network. We have got to // assign addresses to them as well. We put all of the fill devices into // a single device container, so the first nFill devices are associated // with the channel connected to spokeDevices.Get (0), the second nFill // devices afe associated with the channel connected to spokeDevices.Get (1) // etc. // Ipv4AddressHelper address; for(uint32_t i = 0; i < star.SpokeCount (); ++i) { std::ostringstream subnet; subnet << "10.1." << i << ".0"; address.SetBase (subnet.str ().c_str (), "255.255.255.0", "0.0.0.3"); for (uint32_t j = 0; j < nFill; ++j) { address.Assign (fillDevices.Get (i * nFill + j)); } } // // Create a packet sink on the star "hub" to receive packets. // uint16_t port = 50000; Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress); ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ()); hubApp.Start (Seconds (1.0)); hubApp.Stop (Seconds (10.0)); // // Create OnOff applications to send TCP to the hub, one on each spoke node. // // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); onOffHelper.SetConstantRate (DataRate (5000)); ApplicationContainer spokeApps; for (uint32_t i = 0; i < star.SpokeCount (); ++i) { AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i), port)); onOffHelper.SetAttribute ("Remote", remoteAddress); spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i))); } spokeApps.Start (Seconds (1.0)); spokeApps.Stop (Seconds (10.0)); // // Because we are evil, we also add OnOff applications to send TCP to the hub // from the fill devices on each CSMA link. The first nFill nodes in the // fillNodes container are on the CSMA network talking to the zeroth device // on the hub node. The next nFill nodes are on the CSMA network talking to // the first device on the hub node, etc. So the ith fillNode is associated // with the hub address found on the (i / nFill)th device on the hub node. // ApplicationContainer fillApps; for (uint32_t i = 0; i < fillNodes.GetN (); ++i) { AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i / nFill), port)); onOffHelper.SetAttribute ("Remote", remoteAddress); fillApps.Add (onOffHelper.Install (fillNodes.Get (i))); } fillApps.Start (Seconds (1.0)); fillApps.Stop (Seconds (10.0)); // // Turn on global static routing so we can actually be routed across the star. // Ipv4GlobalRoutingHelper::PopulateRoutingTables (); // Trace receptions Config::ConnectWithoutContext ("/NodeList/0/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&CsmaStarTestCase::SinkRx, this)); Simulator::Run (); Simulator::Destroy (); // The hub node should have received 10 packets from the nFill + 1 // nodes on each spoke. NS_TEST_ASSERT_MSG_EQ (m_count, 10 * ( nSpokes * (nFill + 1)), "Hub node did not receive the proper number of packets"); }
// Network topology // // n0 n1 n2 n3 // | | | | // ===================== // // node n0,n1,n3 pings to node n2 // node n0 generates protocol 2 (IGMP) to node n3 // void CsmaPingTestCase::DoRun (void) { // Here, we will explicitly create four nodes. NodeContainer c; c.Create (4); // connect all our nodes to a shared channel. CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); NetDeviceContainer devs = csma.Install (c); // add an ip stack to all nodes. InternetStackHelper ipStack; ipStack.Install (c); // assign ip addresses Ipv4AddressHelper ip; ip.SetBase ("192.168.1.0", "255.255.255.0"); Ipv4InterfaceContainer addresses = ip.Assign (devs); // Create the OnOff application to send UDP datagrams from n0 to n1. // // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate (DataRate (5000)); ApplicationContainer apps = onoff.Install (c.Get (0)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst); apps = sink.Install (c.Get (3)); apps.Start (Seconds (0.0)); apps.Stop (Seconds (11.0)); V4PingHelper ping = V4PingHelper (addresses.GetAddress (2)); NodeContainer pingers; pingers.Add (c.Get (0)); pingers.Add (c.Get (1)); pingers.Add (c.Get (3)); apps = ping.Install (pingers); apps.Start (Seconds (2.0)); apps.Stop (Seconds (5.0)); // Trace receptions Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&CsmaPingTestCase::SinkRx, this)); // Trace pings Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", MakeCallback (&CsmaPingTestCase::PingRtt, this)); Simulator::Run (); Simulator::Destroy (); // We should have sent and received 10 packets NS_TEST_ASSERT_MSG_EQ (m_countSinkRx, 10, "Node 3 should have received 10 packets"); // We should have 3 pingers that ping every second for 3 seconds. NS_TEST_ASSERT_MSG_EQ (m_countPingRtt, 9, "Node 2 should have been pinged 9 times"); }
int main (int argc, char *argv[]) { CommandLine cmd; cmd.Parse (argc, argv); // Here, we will explicitly create four nodes. NS_LOG_INFO ("Create nodes."); NodeContainer c; c.Create (4); // connect all our nodes to a shared channel. NS_LOG_INFO ("Build Topology."); CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc")); NetDeviceContainer devs = csma.Install (c); // add an ip stack to all nodes. NS_LOG_INFO ("Add ip stack."); InternetStackHelper ipStack; ipStack.Install (c); // assign ip addresses NS_LOG_INFO ("Assign ip addresses."); Ipv4AddressHelper ip; ip.SetBase ("192.168.1.0", "255.255.255.0"); Ipv4InterfaceContainer addresses = ip.Assign (devs); NS_LOG_INFO ("Create Source"); Config::SetDefault ("ns3::Ipv4RawSocketImpl::Protocol", StringValue ("2")); InetSocketAddress dst = InetSocketAddress (addresses.GetAddress (3)); OnOffHelper onoff = OnOffHelper ("ns3::Ipv4RawSocketFactory", dst); onoff.SetConstantRate (DataRate (15000)); onoff.SetAttribute ("PacketSize", UintegerValue (1200)); ApplicationContainer apps = onoff.Install (c.Get (0)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); NS_LOG_INFO ("Create Sink."); PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst); apps = sink.Install (c.Get (3)); apps.Start (Seconds (0.0)); apps.Stop (Seconds (11.0)); NS_LOG_INFO ("Create pinger"); V4PingHelper ping = V4PingHelper (addresses.GetAddress (2)); NodeContainer pingers; pingers.Add (c.Get (0)); pingers.Add (c.Get (1)); pingers.Add (c.Get (3)); apps = ping.Install (pingers); apps.Start (Seconds (2.0)); apps.Stop (Seconds (5.0)); NS_LOG_INFO ("Configure Tracing."); // first, pcap tracing in non-promiscuous mode csma.EnablePcapAll ("csma-ping", false); // then, print what the packet sink receives. Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&SinkRx)); // finally, print the ping rtts. Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", MakeCallback (&PingRtt)); Packet::EnablePrinting (); NS_LOG_INFO ("Run Simulation."); Simulator::Run (); Simulator::Destroy (); NS_LOG_INFO ("Done."); }
int main (int argc, char *argv[]) { #ifdef NS3_MPI // Distributed simulation setup MpiInterface::Enable (&argc, &argv); GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::DistributedSimulatorImpl")); LogComponentEnable ("BriteMPITest", LOG_LEVEL_ALL); LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO); uint32_t systemId = MpiInterface::GetSystemId (); uint32_t systemCount = MpiInterface::GetSize (); // Check for valid distributed parameters. // For just this particular example, must have 2 and only 2 Logical Processors (LPs) NS_ASSERT_MSG (systemCount == 2, "This demonstration requires 2 and only 2 logical processors."); // BRITE needs a configuration file to build its graph. By default, this // example will use the TD_ASBarabasi_RTWaxman.conf file. There are many others // which can be found in the BRITE/conf_files directory std::string confFile = "src/brite/examples/conf_files/TD_ASBarabasi_RTWaxman.conf"; bool tracing = false; bool nix = false; CommandLine cmd; cmd.AddValue ("confFile", "BRITE conf file", confFile); cmd.AddValue ("tracing", "Enable or disable ascii tracing", tracing); cmd.AddValue ("nix", "Enable or disable nix-vector routing", nix); cmd.Parse (argc,argv); // Invoke the BriteTopologyHelper and pass in a BRITE // configuration file and a seed file. This will use // BRITE to build a graph from which we can build the ns-3 topology BriteTopologyHelper bth (confFile); PointToPointHelper p2p; Ipv4StaticRoutingHelper staticRouting; Ipv4GlobalRoutingHelper globalRouting; Ipv4ListRoutingHelper listRouting; Ipv4NixVectorHelper nixRouting; InternetStackHelper stack; if (nix) { listRouting.Add (staticRouting, 0); listRouting.Add (nixRouting, 10); } else { listRouting.Add (staticRouting, 0); listRouting.Add (globalRouting, 10); } stack.SetRoutingHelper (listRouting); Ipv4AddressHelper address; address.SetBase ("10.0.0.0", "255.255.255.252"); //build topology as normal but also pass systemCount bth.BuildBriteTopology (stack, systemCount); bth.AssignIpv4Addresses (address); NS_LOG_LOGIC ("Number of AS created " << bth.GetNAs ()); uint16_t port = 5001; NodeContainer client; NodeContainer server; //For this example will use AS 0 and AS 1 which will be on seperate systems //due to the mod divide used to assign AS to system. //GetSystemNumberForAs (uint32_t) can be used to determine which system an //AS is assigned to NS_LOG_LOGIC ("AS 0 has been assigned to system " << bth.GetSystemNumberForAs (0)); NS_LOG_LOGIC ("As 1 has been assigned to system " << bth.GetSystemNumberForAs (1)); //install client node on last leaf node of AS 0 client.Add (CreateObject<Node> (0)); stack.Install (client); int numLeafNodesInAsZero = bth.GetNLeafNodesForAs (0); client.Add (bth.GetLeafNodeForAs (0, numLeafNodesInAsZero - 1)); //install server node on last leaf node on AS 1 server.Add (CreateObject<Node> (1)); stack.Install (server); int numLeafNodesInAsOne = bth.GetNLeafNodesForAs (1); server.Add (bth.GetLeafNodeForAs (1, numLeafNodesInAsOne - 1)); p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); NetDeviceContainer p2pClientDevices; NetDeviceContainer p2pServerDevices; p2pClientDevices = p2p.Install (client); p2pServerDevices = p2p.Install (server); address.SetBase ("10.1.0.0", "255.255.0.0"); Ipv4InterfaceContainer clientInterfaces; clientInterfaces = address.Assign (p2pClientDevices); address.SetBase ("10.2.0.0", "255.255.0.0"); Ipv4InterfaceContainer serverInterfaces; serverInterfaces = address.Assign (p2pServerDevices); if (!nix) { Ipv4GlobalRoutingHelper::PopulateRoutingTables (); } //only has two systems in this example. Install applications only on nodes in my system //Moved here to get totalRX at end ApplicationContainer sinkApps; if (systemId == 1) { Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress); sinkApps.Add (packetSinkHelper.Install (server.Get (0))); sinkApps.Start (Seconds (0.0)); sinkApps.Stop (Seconds (10.0)); } if (systemId == 0) { OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ()); clientHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); clientHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); ApplicationContainer clientApps; AddressValue remoteAddress (InetSocketAddress (serverInterfaces.GetAddress (0), port)); clientHelper.SetAttribute ("Remote", remoteAddress); clientApps.Add (clientHelper.Install (client.Get (0))); clientApps.Start (Seconds (1.0)); // Start 1 second after sink clientApps.Stop (Seconds (9.0)); // Stop before the sink } if (!nix) { Ipv4GlobalRoutingHelper::PopulateRoutingTables (); } if (tracing) { AsciiTraceHelper ascii; p2p.EnableAsciiAll (ascii.CreateFileStream ("briteLeaves.tr")); } // Run the simulator Simulator::Stop (Seconds (200.0)); Simulator::Run (); Simulator::Destroy (); if (systemId == 1) { Ptr<PacketSink> sink1 = DynamicCast<PacketSink> (sinkApps.Get (0)); NS_LOG_DEBUG ("Total Bytes Received: " << sink1->GetTotalRx ()); } MpiInterface::Disable (); return 0; #else NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in"); #endif }
void EpcS1uDlTestCase::DoRun () { Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> (); Ptr<Node> pgw = epcHelper->GetPgwNode (); // allow jumbo packets Config::SetDefault ("ns3::CsmaNetDevice::Mtu", UintegerValue (30000)); Config::SetDefault ("ns3::PointToPointNetDevice::Mtu", UintegerValue (30000)); epcHelper->SetAttribute ("S1uLinkMtu", UintegerValue (30000)); // Create a single RemoteHost NodeContainer remoteHostContainer; remoteHostContainer.Create (1); Ptr<Node> remoteHost = remoteHostContainer.Get (0); InternetStackHelper internet; internet.Install (remoteHostContainer); // Create the internet PointToPointHelper p2ph; p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s"))); NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost); Ipv4AddressHelper ipv4h; ipv4h.SetBase ("1.0.0.0", "255.0.0.0"); ipv4h.Assign (internetDevices); // setup default gateway for the remote hosts Ipv4StaticRoutingHelper ipv4RoutingHelper; Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ()); // hardcoded UE addresses for now remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.255.255.0"), 1); NodeContainer enbs; uint16_t cellIdCounter = 0; for (std::vector<EnbDlTestData>::iterator enbit = m_enbDlTestData.begin (); enbit < m_enbDlTestData.end (); ++enbit) { Ptr<Node> enb = CreateObject<Node> (); enbs.Add (enb); // we test EPC without LTE, hence we use: // 1) a CSMA network to simulate the cell // 2) a raw socket opened on the CSMA device to simulate the LTE socket uint16_t cellId = ++cellIdCounter; NodeContainer ues; ues.Create (enbit->ues.size ()); NodeContainer cell; cell.Add (ues); cell.Add (enb); CsmaHelper csmaCell; NetDeviceContainer cellDevices = csmaCell.Install (cell); // the eNB's CSMA NetDevice acting as an LTE NetDevice. Ptr<NetDevice> enbDevice = cellDevices.Get (cellDevices.GetN () - 1); // Note that the EpcEnbApplication won't care of the actual NetDevice type epcHelper->AddEnb (enb, enbDevice, cellId); // Plug test RRC entity Ptr<EpcEnbApplication> enbApp = enb->GetApplication (0)->GetObject<EpcEnbApplication> (); NS_ASSERT_MSG (enbApp != 0, "cannot retrieve EpcEnbApplication"); Ptr<EpcTestRrc> rrc = CreateObject<EpcTestRrc> (); rrc->SetS1SapProvider (enbApp->GetS1SapProvider ()); enbApp->SetS1SapUser (rrc->GetS1SapUser ()); // we install the IP stack on UEs only InternetStackHelper internet; internet.Install (ues); // assign IP address to UEs, and install applications for (uint32_t u = 0; u < ues.GetN (); ++u) { Ptr<NetDevice> ueLteDevice = cellDevices.Get (u); Ipv4InterfaceContainer ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevice)); Ptr<Node> ue = ues.Get (u); // disable IP Forwarding on the UE. This is because we use // CSMA broadcast MAC addresses for this test. The problem // won't happen with a LteUeNetDevice. ue->GetObject<Ipv4> ()->SetAttribute ("IpForward", BooleanValue (false)); uint16_t port = 1234; PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), port)); ApplicationContainer apps = packetSinkHelper.Install (ue); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); enbit->ues[u].serverApp = apps.Get (0)->GetObject<PacketSink> (); Time interPacketInterval = Seconds (0.01); UdpEchoClientHelper client (ueIpIface.GetAddress (0), port); client.SetAttribute ("MaxPackets", UintegerValue (enbit->ues[u].numPkts)); client.SetAttribute ("Interval", TimeValue (interPacketInterval)); client.SetAttribute ("PacketSize", UintegerValue (enbit->ues[u].pktSize)); apps = client.Install (remoteHost); apps.Start (Seconds (2.0)); apps.Stop (Seconds (10.0)); enbit->ues[u].clientApp = apps.Get (0); uint64_t imsi = u+1; epcHelper->AddUe (ueLteDevice, imsi); epcHelper->ActivateEpsBearer (ueLteDevice, imsi, EpcTft::Default (), EpsBearer (EpsBearer::NGBR_VIDEO_TCP_DEFAULT)); enbApp->GetS1SapProvider ()->InitialUeMessage (imsi, (uint16_t) imsi); } } Simulator::Run (); for (std::vector<EnbDlTestData>::iterator enbit = m_enbDlTestData.begin (); enbit < m_enbDlTestData.end (); ++enbit) { for (std::vector<UeDlTestData>::iterator ueit = enbit->ues.begin (); ueit < enbit->ues.end (); ++ueit) { NS_TEST_ASSERT_MSG_EQ (ueit->serverApp->GetTotalRx (), (ueit->numPkts) * (ueit->pktSize), "wrong total received bytes"); } } Simulator::Destroy (); }
int main(int argc, char* argv[]) { // LogComponentEnable("ndn.CbisGlobalRoutingHelper", LOG_LEVEL_INFO); // Setting default parameters for PointToPoint links and channels Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps")); Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("1ms")); Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("10p")); // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize CommandLine cmd; cmd.Parse(argc, argv); // Creating 3x3 topology PointToPointHelper p2p; PointToPointGridHelper grid(3, 3, p2p); grid.BoundingBox(100, 100, 200, 200); // Install CCNx stack on all nodes ndn::StackHelper ndnHelper; // ndnHelper.SetForwardingStrategy ("ns3::ndn::fw::SmartFlooding"); // ndnHelper.SetContentStore ("ns3::ndn::cs::Lru", "MaxSize", "10"); ndnHelper.InstallAll(); // Choosing forwarding strategy ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/ncc"); // Installing global routing interface on all nodes // ndn::CbisGlobalRoutingHelper ndnGlobalRoutingHelper; ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.InstallAll(); // Getting containers for the consumer/producer Ptr<Node> producer = grid.GetNode(2, 2); NodeContainer consumerNodes; consumerNodes.Add(grid.GetNode(0, 0)); // Install CCNx applications std::string prefix = "/prefix"; ndn::AppHelper consumerHelper("ns3::ndn::ConsumerZipfMandelbrot"); // ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr"); consumerHelper.SetPrefix(prefix); consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second consumerHelper.SetAttribute("NumberOfContents", StringValue("100")); // 10 different contents // consumerHelper.SetAttribute ("Randomize", StringValue ("uniform")); // 100 interests a second consumerHelper.Install(consumerNodes); ndn::AppHelper producerHelper("ns3::ndn::Producer"); producerHelper.SetPrefix(prefix); producerHelper.SetAttribute("PayloadSize", StringValue("100")); producerHelper.Install(producer); ndnGlobalRoutingHelper.AddOrigins(prefix, producer); // Calculate and install FIBs ndn::GlobalRoutingHelper::CalculateRoutes(); Simulator::Stop(Seconds(1.0)); Simulator::Run(); Simulator::Destroy(); return 0; }