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 | { |
Alexander Afanasyev | de00999 | 2012-02-04 18:54:54 -0800 | [diff] [blame] | 16 | // disable fragmentation |
| 17 | Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); |
| 18 | Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); |
| 19 | |
| 20 | // vanet hacks to CcnxL3Protocol |
| 21 | Config::SetDefault ("ns3::CcnxL3Protocol::EnableNACKs", StringValue ("false")); |
| 22 | Config::SetDefault ("ns3::CcnxL3Protocol::CacheUnsolicitedData", StringValue ("true")); |
| 23 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 24 | CommandLine cmd; |
| 25 | cmd.Parse (argc,argv); |
Alexander Afanasyev | de00999 | 2012-02-04 18:54:54 -0800 | [diff] [blame] | 26 | |
| 27 | ////////////////////// |
| 28 | ////////////////////// |
| 29 | ////////////////////// |
| 30 | |
| 31 | WifiHelper wifi = WifiHelper::Default (); |
| 32 | // wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); |
| 33 | wifi.SetStandard (WIFI_PHY_STANDARD_80211a); |
| 34 | wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
| 35 | "DataMode", StringValue ("OfdmRate54Mbps")); |
| 36 | |
| 37 | YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
| 38 | |
| 39 | YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
| 40 | wifiPhy.SetChannel (wifiChannel.Create ()); |
| 41 | |
| 42 | NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); |
| 43 | wifiMac.SetType("ns3::AdhocWifiMac"); |
| 44 | |
| 45 | ////////////////////// |
| 46 | ////////////////////// |
| 47 | ////////////////////// |
| 48 | |
| 49 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 50 | NodeContainer producerNode; |
| 51 | producerNode.Create (1); |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 52 | NodeContainer consumerNodes; |
| 53 | consumerNodes.Create(2); |
Alexander Afanasyev | de00999 | 2012-02-04 18:54:54 -0800 | [diff] [blame] | 54 | |
| 55 | wifi.Install (wifiPhy, wifiMac, producerNode); |
| 56 | wifi.Install (wifiPhy, wifiMac, consumerNodes); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 57 | |
| 58 | MobilityHelper mobility; |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 59 | mobility.SetPositionAllocator ("ns3::HighwayPositionAllocator", |
| 60 | "Start", VectorValue(Vector(0.0, 0.0, 0.0)), |
| 61 | "Direction", DoubleValue(0.0), |
| 62 | "Length", DoubleValue(1000.0)); |
| 63 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 64 | mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel", |
Alexander Afanasyev | de00999 | 2012-02-04 18:54:54 -0800 | [diff] [blame] | 65 | "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0))); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 66 | mobility.Install (producerNode); |
| 67 | |
| 68 | mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel", |
Alexander Afanasyev | de00999 | 2012-02-04 18:54:54 -0800 | [diff] [blame] | 69 | "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0))); |
Lucas | a3295ab | 2012-02-04 13:36:31 -0800 | [diff] [blame] | 70 | mobility.Install (consumerNodes); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 71 | |
Alexander Afanasyev | fa3b3d3 | 2012-02-04 14:34:00 -0800 | [diff] [blame] | 72 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 73 | // 2. Install CCNx stack |
| 74 | NS_LOG_INFO ("Installing CCNx stack"); |
| 75 | CcnxStackHelper ccnxHelper; |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 76 | ccnxHelper.SetDefaultRoutes(true); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 77 | ccnxHelper.InstallAll (); |
| 78 | |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 79 | // 6. Set up applications |
| 80 | NS_LOG_INFO ("Installing Applications"); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 81 | |
Alexander Afanasyev | fa3b3d3 | 2012-02-04 14:34:00 -0800 | [diff] [blame] | 82 | CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr"); |
| 83 | consumerHelper.SetPrefix ("/"); |
| 84 | consumerHelper.SetAttribute ("Frequency", StringValue ("1")); |
Alexander Afanasyev | de00999 | 2012-02-04 18:54:54 -0800 | [diff] [blame] | 85 | ApplicationContainer consumers = consumerHelper.Install (consumerNodes.Get (0)); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 86 | |
| 87 | // consumers.Start (Seconds (0.0)); |
| 88 | // consumers.Stop (finishTime); |
| 89 | |
| 90 | CcnxAppHelper producerHelper ("ns3::CcnxProducer"); |
Alexander Afanasyev | fa3b3d3 | 2012-02-04 14:34:00 -0800 | [diff] [blame] | 91 | producerHelper.SetPrefix ("/"); |
Lucas | 64b8536 | 2012-01-30 16:28:37 -0800 | [diff] [blame] | 92 | producerHelper.SetAttribute ("PayloadSize", StringValue("1024")); |
| 93 | ApplicationContainer producers = producerHelper.Install (producerNode); |
| 94 | |
| 95 | Simulator::Stop (Seconds (10.0)); |
| 96 | Simulator::Run (); |
| 97 | Simulator::Destroy (); |
| 98 | return 0; |
| 99 | } |