blob: 58db981185caa2f7095e17e79ca3f7a67fec1f05 [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
13int
14main (int argc, char *argv[])
15{
Alexander Afanasyevde009992012-02-04 18:54:54 -080016 // 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
Lucas64b85362012-01-30 16:28:37 -080024 CommandLine cmd;
25 cmd.Parse (argc,argv);
Alexander Afanasyevde009992012-02-04 18:54:54 -080026
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
Lucas64b85362012-01-30 16:28:37 -080050 NodeContainer producerNode;
51 producerNode.Create (1);
Lucasa3295ab2012-02-04 13:36:31 -080052 NodeContainer consumerNodes;
53 consumerNodes.Create(2);
Alexander Afanasyevde009992012-02-04 18:54:54 -080054
55 wifi.Install (wifiPhy, wifiMac, producerNode);
56 wifi.Install (wifiPhy, wifiMac, consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080057
58 MobilityHelper mobility;
Lucasa3295ab2012-02-04 13:36:31 -080059 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
Lucas64b85362012-01-30 16:28:37 -080064 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
Alexander Afanasyevde009992012-02-04 18:54:54 -080065 "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0)));
Lucas64b85362012-01-30 16:28:37 -080066 mobility.Install (producerNode);
67
68 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
Alexander Afanasyevde009992012-02-04 18:54:54 -080069 "ConstantVelocity", VectorValue(Vector(0/*26.8224*/, 0, 0)));
Lucasa3295ab2012-02-04 13:36:31 -080070 mobility.Install (consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080071
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080072
Lucas64b85362012-01-30 16:28:37 -080073 // 2. Install CCNx stack
74 NS_LOG_INFO ("Installing CCNx stack");
75 CcnxStackHelper ccnxHelper;
Lucas64b85362012-01-30 16:28:37 -080076 ccnxHelper.SetDefaultRoutes(true);
Lucas64b85362012-01-30 16:28:37 -080077 ccnxHelper.InstallAll ();
78
Lucas64b85362012-01-30 16:28:37 -080079 // 6. Set up applications
80 NS_LOG_INFO ("Installing Applications");
Lucas64b85362012-01-30 16:28:37 -080081
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080082 CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
83 consumerHelper.SetPrefix ("/");
84 consumerHelper.SetAttribute ("Frequency", StringValue ("1"));
Alexander Afanasyevde009992012-02-04 18:54:54 -080085 ApplicationContainer consumers = consumerHelper.Install (consumerNodes.Get (0));
Lucas64b85362012-01-30 16:28:37 -080086
87 // consumers.Start (Seconds (0.0));
88 // consumers.Stop (finishTime);
89
90 CcnxAppHelper producerHelper ("ns3::CcnxProducer");
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080091 producerHelper.SetPrefix ("/");
Lucas64b85362012-01-30 16:28:37 -080092 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}