blob: 2ef9f5e679fddecc2f7a539617621c0a3831e543 [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
56 // 1. Set RoutingHelper to support prefix
57 //InternetStackHelper stack;
58 //Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
59 //stack.SetRoutingHelper (ipv4RoutingHelper);
60
61 // 2. Install CCNx stack
62 NS_LOG_INFO ("Installing CCNx stack");
63 CcnxStackHelper ccnxHelper;
64 std::string strategy = "ns3::CcnxFloodingStrategy";
65 ccnxHelper.SetForwardingStrategy (strategy);
66 ccnxHelper.SetDefaultRoutes(true);
67 //ccnxHelper.EnableLimits (false, Seconds(0.1));
68 ccnxHelper.InstallAll ();
69
70 // 3. Install IP stack
71 //stack.Install (consumerNode);
72 //stack.Install (producerNode);
73
74 // 4. Assign Addresses
75 //Ipv4AddressHelper address;
76 //address.SetBase ("10.1.3.0", "255.255.255.0");
77 //address.Assign (consumerDevices);
78 //Ipv4InterfaceContainer producerInterface = address.Assign (producerDevices);
79
80 // 5. Populate FIB based on IPv4 global routing controller
81 //ccnxHelper.InstallFakeGlobalRoutes ();
82 //ccnxHelper.InstallRouteTo (producerNode.Get(0));
83
84 // 6. Set up applications
85 NS_LOG_INFO ("Installing Applications");
86 std::ostringstream prefix;
87 prefix << "/" << producerNode.Get(0)->GetId ();
88
89 CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
90 consumerHelper.SetPrefix (prefix.str ());
91 consumerHelper.SetAttribute ("MeanRate", StringValue ("1Mbps"));
Lucasa3295ab2012-02-04 13:36:31 -080092 ApplicationContainer consumers = consumerHelper.Install (consumerNodes);
Lucas64b85362012-01-30 16:28:37 -080093
94 // consumers.Start (Seconds (0.0));
95 // consumers.Stop (finishTime);
96
97 CcnxAppHelper producerHelper ("ns3::CcnxProducer");
98 producerHelper.SetPrefix (prefix.str ());
99 producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
100 ApplicationContainer producers = producerHelper.Install (producerNode);
101
102 Simulator::Stop (Seconds (10.0));
103 Simulator::Run ();
104 Simulator::Destroy ();
105 return 0;
106}