Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 1 | #include "ns3/core-module.h" |
| 2 | #include "ns3/network-module.h" |
| 3 | #include "ns3/applications-module.h" |
| 4 | #include "ns3/wifi-module.h" |
| 5 | #include "ns3/mobility-module.h" |
| 6 | #include "ns3/internet-module.h" |
| 7 | #include "ns3/NDNabstraction-module.h" |
| 8 | |
| 9 | using namespace ns3; |
| 10 | |
| 11 | NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample"); |
| 12 | |
| 13 | int |
| 14 | main (int argc, char *argv[]) |
| 15 | { |
| 16 | CommandLine cmd; |
| 17 | cmd.Parse (argc,argv); |
| 18 | NodeContainer producerNode; |
| 19 | producerNode.Create (1); |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 20 | NodeContainer consumerNodes; |
| 21 | consumerNodes.Create(2); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 22 | YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
| 23 | YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
| 24 | phy.SetChannel (channel.Create ()); |
| 25 | WifiHelper wifi = WifiHelper::Default (); |
| 26 | wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); |
| 27 | NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); |
| 28 | /*Ssid ssid = Ssid ("ns-3-ssid"); |
| 29 | mac.SetType ("ns3::StaWifiMac", |
| 30 | "Ssid", SsidValue (ssid), |
| 31 | "ActiveProbing", BooleanValue (false));*/ |
| 32 | mac.SetType("ns3::AdhocWifiMac"); |
| 33 | NetDeviceContainer producerDevices; |
| 34 | producerDevices = wifi.Install (phy, mac, producerNode); |
| 35 | /*mac.SetType ("ns3::ApWifiMac", |
| 36 | "Ssid", SsidValue (ssid)); |
| 37 | */ |
| 38 | NetDeviceContainer consumerDevices; |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 39 | consumerDevices = wifi.Install (phy, mac, consumerNodes); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 40 | |
| 41 | MobilityHelper mobility; |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 42 | mobility.SetPositionAllocator ("ns3::HighwayPositionAllocator", |
| 43 | "Start", VectorValue(Vector(0.0, 0.0, 0.0)), |
| 44 | "Direction", DoubleValue(0.0), |
| 45 | "Length", DoubleValue(1000.0)); |
| 46 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 47 | mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel", |
| 48 | "ConstantVelocity", VectorValue(Vector(26.8224, 0, 0))); |
| 49 | mobility.Install (producerNode); |
| 50 | |
| 51 | mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel", |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 52 | "ConstantVelocity", VectorValue(Vector(26.8224, 0, 0))); |
| 53 | mobility.Install (consumerNodes); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 54 | |
| 55 | |
Alexander Afanasyev | fa3b3d3 | 2012-02-04 14:34:00 -0800 | [diff] [blame^] | 56 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 57 | // 2. Install CCNx stack |
| 58 | NS_LOG_INFO ("Installing CCNx stack"); |
| 59 | CcnxStackHelper ccnxHelper; |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 60 | ccnxHelper.SetDefaultRoutes(true); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 61 | ccnxHelper.InstallAll (); |
| 62 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 63 | // 6. Set up applications |
| 64 | NS_LOG_INFO ("Installing Applications"); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 65 | |
Alexander Afanasyev | fa3b3d3 | 2012-02-04 14:34:00 -0800 | [diff] [blame^] | 66 | CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr"); |
| 67 | consumerHelper.SetPrefix ("/"); |
| 68 | consumerHelper.SetAttribute ("Frequency", StringValue ("1")); |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 69 | ApplicationContainer consumers = consumerHelper.Install (consumerNodes); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 70 | |
| 71 | // consumers.Start (Seconds (0.0)); |
| 72 | // consumers.Stop (finishTime); |
| 73 | |
| 74 | CcnxAppHelper producerHelper ("ns3::CcnxProducer"); |
Alexander Afanasyev | fa3b3d3 | 2012-02-04 14:34:00 -0800 | [diff] [blame^] | 75 | producerHelper.SetPrefix ("/"); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 76 | producerHelper.SetAttribute ("PayloadSize", StringValue("1024")); |
| 77 | ApplicationContainer producers = producerHelper.Install (producerNode); |
| 78 | |
| 79 | Simulator::Stop (Seconds (10.0)); |
| 80 | Simulator::Run (); |
| 81 | Simulator::Destroy (); |
| 82 | return 0; |
| 83 | } |