blob: e6242ab5e4e4dc17b895047d10b5879790c35051 [file] [log] [blame]
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2
3#include "ns3/core-module.h"
4#include "ns3/network-module.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07005#include "ns3/point-to-point-module.h"
Alexander Afanasyev45b92d42011-08-14 23:11:38 -07006#include "ns3/NDNabstraction-module.h"
7
8using namespace ns3;
9
10NS_LOG_COMPONENT_DEFINE ("CcnxTest");
11
12int
13main (int argc, char *argv[])
14{
Alexander Afanasyev7112f482011-08-17 14:05:57 -070015 LogComponentEnable ("CcnxTest", LOG_ALL);
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070016 LogComponentEnable ("CcnxStackHelper", LOG_ALL);
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070017 LogComponentEnable ("CcnxRit", LOG_ALL);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070018
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070019 // Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
20 // Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
21
22 Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("10Mbps"));
23 Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("1ms"));
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070024
25 CommandLine cmd;
26 cmd.Parse (argc, argv);
27
28 // Here, we will explicitly create seven nodes.
29 NodeContainer c;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070030 c.Create (3);
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070031
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070032 NodeContainer n1 = NodeContainer (c.Get (0), c.Get (1));
33 NodeContainer n2 = NodeContainer (c.Get (1), c.Get (2));
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070034
35 // Ipv4StaticRoutingHelper staticRouting;
36
37 // Ipv4ListRoutingHelper list;
38 // list.Add (staticRouting, 1);
39
Alexander Afanasyev7112f482011-08-17 14:05:57 -070040 NS_LOG_INFO ("Create channels.");
41 PointToPointHelper p2p;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070042 // NetDeviceContainer nd =
43 p2p.Install (n1);
44 p2p.Install (n2);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070045
46 NS_LOG_INFO ("Installing NDN stack");
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070047 CcnxStackHelper ccnx;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070048 Ptr<CcnxFaceContainer> cf = ccnx.Install (c);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070049
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070050 // test RIT
51 NS_LOG_INFO ("Creating RIT");
52 Ptr<CcnxRit> rit = CreateObject<CcnxRit> ();
53
54 CcnxInterestHeader header;
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070055 Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> ();
Alexander Afanasyevfccdb9e2011-08-22 19:27:14 -070056 (*testname) ("test") ("test2");
57 header.SetName (testname);
58 header.SetNonce (1);
59
60 rit->SetRecentlySatisfied (header);
61
62 NS_LOG_INFO (rit->WasRecentlySatisfied (header));
63
64 (*testname) ("test3"); // should have a side effect of changing name in the packet
65 rit->SetRecentlySatisfied (header);
66
67 NS_LOG_INFO (rit->WasRecentlySatisfied (header));
68
69 header.SetNonce (2);
70 NS_LOG_INFO (rit->WasRecentlySatisfied (header));
71
72 // rit->SetRecentlySatisfied (header);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070073 // ? set up forwarding
74
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070075
76 //Add static routing
77 // InternetStackHelper internet;
78 // internet.SetRoutingHelper (list); // has effect on the next Install ()
79 // internet.Install (c);
80
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070081 // Create the OnOff application to send UDP datagrams of size
82 // 210 bytes at a rate of 448 Kb/s from n0 to n4
Alexander Afanasyev7112f482011-08-17 14:05:57 -070083 // NS_LOG_INFO ("Create Applications.");
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070084
85 // std::string sendsizeattr = "SendSize";
86 // //flow2 7-->2
87 // BulkSendHelper bulksend0 ("ns3::CcnxLocalFaceFactory", InetSocketAddress (i23.GetAddress (0), port));
88 // //bulksend0.SetAttribute(sendsizeattr, AttributeValue(ConstantVariable(2560)));
89 // bulksend0.SetAttribute("MaxBytes", UintegerValue(2560));
90 // ApplicationContainer apps = bulksend0.Install(c.Get(6));
91 // apps.Start(Seconds (1.0));
92 // apps.Stop(Seconds (10.0));
93
94 // AsciiTraceHelper ascii;
95 // p2p.EnableAsciiAll (ascii.CreateFileStream ("ccnx-test.tr"));
96 // p2p.EnablePcapAll ("ccnx-test");
97
98 Simulator::Stop (Seconds (20));
99
100 NS_LOG_INFO ("Run Simulation.");
101 Simulator::Run ();
102 Simulator::Destroy ();
103 NS_LOG_INFO ("Done.");
104
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700105 return 0;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700106}