blob: d5cb1ad47fe1ed4e1d06e6e2353714ff2c490eab [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 Afanasyevc5a23e22011-09-07 00:37:36 -070015 // LogComponentEnable ("CcnxTest", LOG_ALL);
16 // LogComponentEnable ("CcnxStackHelper", LOG_ALL);
17 // 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 Afanasyevc5a23e22011-09-07 00:37:36 -070024
25 Packet::EnableChecking();
26 Packet::EnablePrinting();
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070027 CommandLine cmd;
28 cmd.Parse (argc, argv);
29
30 // Here, we will explicitly create seven nodes.
31 NodeContainer c;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070032 c.Create (3);
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070033 Names::Add ("1", c.Get (0));
34 Names::Add ("2", c.Get (1));
35 Names::Add ("3", c.Get (2));
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070036
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070037 // NodeContainer n1 = NodeContainer ("1") ("2");
38 // NodeContainer n2 = NodeContainer ("2") ("3");
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070039
Alexander Afanasyev7112f482011-08-17 14:05:57 -070040 NS_LOG_INFO ("Create channels.");
41 PointToPointHelper p2p;
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070042 p2p.Install ("1", "2");
43 p2p.Install ("2", "3");
Alexander Afanasyev7112f482011-08-17 14:05:57 -070044
45 NS_LOG_INFO ("Installing NDN stack");
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070046 CcnxStackHelper ccnx;
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070047 Ptr<CcnxFaceContainer> cf = ccnx.Install (c);
Alexander Afanasyev7112f482011-08-17 14:05:57 -070048
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070049 CcnxConsumerHelper helper ("/3");
50 ApplicationContainer app = helper.Install ("1");
51 app.Start (Seconds (1.0));
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -070052 app.Stop (Seconds (10.05));
Ilya Moiseenko68516322011-10-28 13:03:11 -070053
54 CcnxProducerHelper helper2 ("/3",120);
55 ApplicationContainer app2 = helper2.Install("3");
56 app2.Start(Seconds(0.0));
57 app2.Stop(Seconds(15.0));
Alexander Afanasyev7112f482011-08-17 14:05:57 -070058
Alexander Afanasyevc5a23e22011-09-07 00:37:36 -070059 /**
60 * \brief Add forwarding entry in FIB
61 *
62 * \param node Node
63 * \param prefix Routing prefix
64 * \param face Face index
65 * \param metric Routing metric
66 */
67 ccnx.AddRoute ("1", "/3", 0, 1);
68 ccnx.AddRoute ("2", "/3", 1, 1);
69 ccnx.AddRoute ("2", "/3", 0, 10000);
70 NS_LOG_INFO ("FIB dump:\n" << *c.Get(0)->GetObject<CcnxFib> ());
71 NS_LOG_INFO ("FIB dump:\n" << *c.Get(1)->GetObject<CcnxFib> ());
72
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070073 // Create the OnOff application to send UDP datagrams of size
74 // 210 bytes at a rate of 448 Kb/s from n0 to n4
Alexander Afanasyev7112f482011-08-17 14:05:57 -070075 // NS_LOG_INFO ("Create Applications.");
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070076
77 // std::string sendsizeattr = "SendSize";
78 // //flow2 7-->2
79 // BulkSendHelper bulksend0 ("ns3::CcnxLocalFaceFactory", InetSocketAddress (i23.GetAddress (0), port));
80 // //bulksend0.SetAttribute(sendsizeattr, AttributeValue(ConstantVariable(2560)));
81 // bulksend0.SetAttribute("MaxBytes", UintegerValue(2560));
82 // ApplicationContainer apps = bulksend0.Install(c.Get(6));
83 // apps.Start(Seconds (1.0));
84 // apps.Stop(Seconds (10.0));
85
86 // AsciiTraceHelper ascii;
87 // p2p.EnableAsciiAll (ascii.CreateFileStream ("ccnx-test.tr"));
88 // p2p.EnablePcapAll ("ccnx-test");
89
90 Simulator::Stop (Seconds (20));
91
92 NS_LOG_INFO ("Run Simulation.");
93 Simulator::Run ();
94 Simulator::Destroy ();
95 NS_LOG_INFO ("Done.");
96
Alexander Afanasyev7112f482011-08-17 14:05:57 -070097 return 0;
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070098}