Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | |
| 3 | #include "ns3/core-module.h" |
| 4 | #include "ns3/network-module.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 5 | #include "ns3/point-to-point-module.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 6 | #include "ns3/NDNabstraction-module.h" |
| 7 | |
| 8 | using namespace ns3; |
| 9 | |
| 10 | NS_LOG_COMPONENT_DEFINE ("CcnxTest"); |
| 11 | |
| 12 | int |
| 13 | main (int argc, char *argv[]) |
| 14 | { |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 15 | // LogComponentEnable ("CcnxTest", LOG_ALL); |
| 16 | // LogComponentEnable ("CcnxStackHelper", LOG_ALL); |
| 17 | // LogComponentEnable ("CcnxRit", LOG_ALL); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 18 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 19 | // 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 Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 24 | |
| 25 | Packet::EnableChecking(); |
| 26 | Packet::EnablePrinting(); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 27 | CommandLine cmd; |
| 28 | cmd.Parse (argc, argv); |
| 29 | |
| 30 | // Here, we will explicitly create seven nodes. |
| 31 | NodeContainer c; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 32 | c.Create (3); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 33 | Names::Add ("1", c.Get (0)); |
| 34 | Names::Add ("2", c.Get (1)); |
| 35 | Names::Add ("3", c.Get (2)); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 36 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 37 | // NodeContainer n1 = NodeContainer ("1") ("2"); |
| 38 | // NodeContainer n2 = NodeContainer ("2") ("3"); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 39 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 40 | NS_LOG_INFO ("Create channels."); |
| 41 | PointToPointHelper p2p; |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 42 | p2p.Install ("1", "2"); |
| 43 | p2p.Install ("2", "3"); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 44 | |
| 45 | NS_LOG_INFO ("Installing NDN stack"); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 46 | CcnxStackHelper ccnx; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 47 | Ptr<CcnxFaceContainer> cf = ccnx.Install (c); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 49 | CcnxAppHelper helper ("ns3::CcnxConsumer"); |
| 50 | helper.SetPrefix ("/3"); |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 51 | ApplicationContainer app = helper.Install ("1"); |
| 52 | app.Start (Seconds (1.0)); |
Ilya Moiseenko | 25f7d4d | 2011-09-29 18:41:06 -0700 | [diff] [blame] | 53 | app.Stop (Seconds (10.05)); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 54 | |
| 55 | CcnxAppHelper helper2 ("ns3::CcnxProducer"); |
| 56 | helper2.SetPrefix ("/3"); |
| 57 | helper2.SetAttribute ("PayloadSize", StringValue("1024")); |
Ilya Moiseenko | 6851632 | 2011-10-28 13:03:11 -0700 | [diff] [blame] | 58 | ApplicationContainer app2 = helper2.Install("3"); |
Alexander Afanasyev | 4975f73 | 2011-12-20 17:52:19 -0800 | [diff] [blame] | 59 | |
Ilya Moiseenko | 6851632 | 2011-10-28 13:03:11 -0700 | [diff] [blame] | 60 | app2.Start(Seconds(0.0)); |
| 61 | app2.Stop(Seconds(15.0)); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 62 | |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 63 | /** |
| 64 | * \brief Add forwarding entry in FIB |
| 65 | * |
| 66 | * \param node Node |
| 67 | * \param prefix Routing prefix |
| 68 | * \param face Face index |
| 69 | * \param metric Routing metric |
| 70 | */ |
| 71 | ccnx.AddRoute ("1", "/3", 0, 1); |
| 72 | ccnx.AddRoute ("2", "/3", 1, 1); |
| 73 | ccnx.AddRoute ("2", "/3", 0, 10000); |
| 74 | NS_LOG_INFO ("FIB dump:\n" << *c.Get(0)->GetObject<CcnxFib> ()); |
| 75 | NS_LOG_INFO ("FIB dump:\n" << *c.Get(1)->GetObject<CcnxFib> ()); |
| 76 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 77 | // Create the OnOff application to send UDP datagrams of size |
| 78 | // 210 bytes at a rate of 448 Kb/s from n0 to n4 |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 79 | // NS_LOG_INFO ("Create Applications."); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 80 | |
| 81 | // std::string sendsizeattr = "SendSize"; |
| 82 | // //flow2 7-->2 |
| 83 | // BulkSendHelper bulksend0 ("ns3::CcnxLocalFaceFactory", InetSocketAddress (i23.GetAddress (0), port)); |
| 84 | // //bulksend0.SetAttribute(sendsizeattr, AttributeValue(ConstantVariable(2560))); |
| 85 | // bulksend0.SetAttribute("MaxBytes", UintegerValue(2560)); |
| 86 | // ApplicationContainer apps = bulksend0.Install(c.Get(6)); |
| 87 | // apps.Start(Seconds (1.0)); |
| 88 | // apps.Stop(Seconds (10.0)); |
| 89 | |
| 90 | // AsciiTraceHelper ascii; |
| 91 | // p2p.EnableAsciiAll (ascii.CreateFileStream ("ccnx-test.tr")); |
| 92 | // p2p.EnablePcapAll ("ccnx-test"); |
| 93 | |
| 94 | Simulator::Stop (Seconds (20)); |
| 95 | |
| 96 | NS_LOG_INFO ("Run Simulation."); |
| 97 | Simulator::Run (); |
| 98 | Simulator::Destroy (); |
| 99 | NS_LOG_INFO ("Done."); |
| 100 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 101 | return 0; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 102 | } |