blob: cc9be09e29ad2bafaba1dc55ae69f9a2ebbf0722 [file] [log] [blame]
Lucas64b85362012-01-30 16:28:37 -08001#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
9using namespace ns3;
10
11NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
12
Alexander Afanasyev2188a252012-02-07 12:00:35 -080013static void
14ExactTimePrinter (std::ostream &os)
15{
16 os << Simulator::Now ();
17}
18
19
Lucas64b85362012-01-30 16:28:37 -080020int
21main (int argc, char *argv[])
22{
Alexander Afanasyevde009992012-02-04 18:54:54 -080023 // disable fragmentation
24 Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
25 Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
Alexander Afanasyev2188a252012-02-07 12:00:35 -080026 Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue ("OfdmRate24Mbps"));
Alexander Afanasyevde009992012-02-04 18:54:54 -080027
28 // vanet hacks to CcnxL3Protocol
29 Config::SetDefault ("ns3::CcnxL3Protocol::EnableNACKs", StringValue ("false"));
30 Config::SetDefault ("ns3::CcnxL3Protocol::CacheUnsolicitedData", StringValue ("true"));
31
Lucas64b85362012-01-30 16:28:37 -080032 CommandLine cmd;
33 cmd.Parse (argc,argv);
Alexander Afanasyevde009992012-02-04 18:54:54 -080034
35 //////////////////////
36 //////////////////////
37 //////////////////////
38
39 WifiHelper wifi = WifiHelper::Default ();
40 // wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
41 wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
42 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
Alexander Afanasyev2188a252012-02-07 12:00:35 -080043 "DataMode", StringValue ("OfdmRate24Mbps"));
Alexander Afanasyevde009992012-02-04 18:54:54 -080044
45 YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
46
47 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
48 wifiPhy.SetChannel (wifiChannel.Create ());
49
50 NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
51 wifiMac.SetType("ns3::AdhocWifiMac");
52
53 //////////////////////
54 //////////////////////
55 //////////////////////
56
57
Lucas64b85362012-01-30 16:28:37 -080058 NodeContainer producerNode;
59 producerNode.Create (1);
Lucasa3295ab2012-02-04 13:36:31 -080060 NodeContainer consumerNodes;
61 consumerNodes.Create(2);
Alexander Afanasyevde009992012-02-04 18:54:54 -080062
63 wifi.Install (wifiPhy, wifiMac, producerNode);
64 wifi.Install (wifiPhy, wifiMac, consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080065
66 MobilityHelper mobility;
Lucasa3295ab2012-02-04 13:36:31 -080067 mobility.SetPositionAllocator ("ns3::HighwayPositionAllocator",
68 "Start", VectorValue(Vector(0.0, 0.0, 0.0)),
69 "Direction", DoubleValue(0.0),
70 "Length", DoubleValue(1000.0));
71
Lucas64b85362012-01-30 16:28:37 -080072 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
Alexander Afanasyevde009992012-02-04 18:54:54 -080073 "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0)));
Lucas64b85362012-01-30 16:28:37 -080074 mobility.Install (producerNode);
75
76 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
Alexander Afanasyevde009992012-02-04 18:54:54 -080077 "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0)));
Lucasa3295ab2012-02-04 13:36:31 -080078 mobility.Install (consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080079
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080080
Lucas64b85362012-01-30 16:28:37 -080081 // 2. Install CCNx stack
82 NS_LOG_INFO ("Installing CCNx stack");
83 CcnxStackHelper ccnxHelper;
Lucas64b85362012-01-30 16:28:37 -080084 ccnxHelper.SetDefaultRoutes(true);
Lucas64b85362012-01-30 16:28:37 -080085 ccnxHelper.InstallAll ();
86
Lucas64b85362012-01-30 16:28:37 -080087 // 6. Set up applications
88 NS_LOG_INFO ("Installing Applications");
Lucas64b85362012-01-30 16:28:37 -080089
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080090 CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
Alexander Afanasyev2188a252012-02-07 12:00:35 -080091 consumerHelper.SetPrefix ("/very-long-prefix-requested-by-client/this-interest-hundred-bytes-long-");
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080092 consumerHelper.SetAttribute ("Frequency", StringValue ("1"));
Alexander Afanasyev2188a252012-02-07 12:00:35 -080093 consumerHelper.SetAttribute ("Randomize", StringValue ("exponential"));
94 consumerHelper.Install (consumerNodes.Get (0));
95
96 consumerHelper.Install (consumerNodes.Get (1));
Lucas64b85362012-01-30 16:28:37 -080097
98 // consumers.Start (Seconds (0.0));
99 // consumers.Stop (finishTime);
100
101 CcnxAppHelper producerHelper ("ns3::CcnxProducer");
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -0800102 producerHelper.SetPrefix ("/");
Lucas64b85362012-01-30 16:28:37 -0800103 producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
104 ApplicationContainer producers = producerHelper.Install (producerNode);
105
Alexander Afanasyev2188a252012-02-07 12:00:35 -0800106 Simulator::Schedule (Seconds(0.0), LogSetTimePrinter, ExactTimePrinter);
107
108
109 Simulator::Stop (Seconds (10));
Lucas64b85362012-01-30 16:28:37 -0800110 Simulator::Run ();
111 Simulator::Destroy ();
112 return 0;
113}