blob: 417ea2d3532d5ac61f1d219efd9e593565710813 [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{
16 CommandLine cmd;
17 cmd.Parse (argc,argv);
18 NodeContainer producerNode;
19 producerNode.Create (1);
Lucasa3295ab2012-02-04 13:36:31 -080020 NodeContainer consumerNodes;
21 consumerNodes.Create(2);
Lucas64b85362012-01-30 16:28:37 -080022 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;
Lucasa3295ab2012-02-04 13:36:31 -080039 consumerDevices = wifi.Install (phy, mac, consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080040
41 MobilityHelper mobility;
Lucasa3295ab2012-02-04 13:36:31 -080042 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
Lucas64b85362012-01-30 16:28:37 -080047 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
48 "ConstantVelocity", VectorValue(Vector(26.8224, 0, 0)));
49 mobility.Install (producerNode);
50
51 mobility.SetMobilityModel("ns3::ConstantVelocityMobilityModel",
Lucasa3295ab2012-02-04 13:36:31 -080052 "ConstantVelocity", VectorValue(Vector(26.8224, 0, 0)));
53 mobility.Install (consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080054
55
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080056
Lucas64b85362012-01-30 16:28:37 -080057 // 2. Install CCNx stack
58 NS_LOG_INFO ("Installing CCNx stack");
59 CcnxStackHelper ccnxHelper;
Lucas64b85362012-01-30 16:28:37 -080060 ccnxHelper.SetDefaultRoutes(true);
Lucas64b85362012-01-30 16:28:37 -080061 ccnxHelper.InstallAll ();
62
Lucas64b85362012-01-30 16:28:37 -080063 // 6. Set up applications
64 NS_LOG_INFO ("Installing Applications");
Lucas64b85362012-01-30 16:28:37 -080065
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080066 CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
67 consumerHelper.SetPrefix ("/");
68 consumerHelper.SetAttribute ("Frequency", StringValue ("1"));
Lucasa3295ab2012-02-04 13:36:31 -080069 ApplicationContainer consumers = consumerHelper.Install (consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080070
71 // consumers.Start (Seconds (0.0));
72 // consumers.Stop (finishTime);
73
74 CcnxAppHelper producerHelper ("ns3::CcnxProducer");
Alexander Afanasyevfa3b3d32012-02-04 14:34:00 -080075 producerHelper.SetPrefix ("/");
Lucas64b85362012-01-30 16:28:37 -080076 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}