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 | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 15 | LogComponentEnable ("CcnxTest", LOG_ALL); |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 16 | LogComponentEnable ("CcnxStackHelper", LOG_ALL); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 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 | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 24 | |
| 25 | CommandLine cmd; |
| 26 | cmd.Parse (argc, argv); |
| 27 | |
| 28 | // Here, we will explicitly create seven nodes. |
| 29 | NodeContainer c; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 30 | c.Create (3); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 31 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 32 | NodeContainer n1 = NodeContainer (c.Get (0), c.Get (1)); |
| 33 | NodeContainer n2 = NodeContainer (c.Get (1), c.Get (2)); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 34 | |
| 35 | // Ipv4StaticRoutingHelper staticRouting; |
| 36 | |
| 37 | // Ipv4ListRoutingHelper list; |
| 38 | // list.Add (staticRouting, 1); |
| 39 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 40 | NS_LOG_INFO ("Create channels."); |
| 41 | PointToPointHelper p2p; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 42 | // NetDeviceContainer nd = |
| 43 | p2p.Install (n1); |
| 44 | p2p.Install (n2); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 45 | |
| 46 | NS_LOG_INFO ("Installing NDN stack"); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 47 | CcnxStackHelper ccnx; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 48 | Ptr<CcnxFaceContainer> cf = ccnx.Install (c); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 49 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 50 | // // test RIT |
| 51 | // NS_LOG_INFO ("Creating RIT"); |
| 52 | // Ptr<CcnxRit> rit = CreateObject<CcnxRit> (); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 53 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 54 | // CcnxInterestHeader header; |
| 55 | // Ptr<CcnxNameComponents> testname = Create<CcnxNameComponents> (); |
| 56 | // (*testname) ("test") ("test2"); |
| 57 | // header.SetName (testname); |
| 58 | // header.SetNonce (1); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 59 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 60 | // rit->SetRecentlySatisfied (header); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 61 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 62 | // NS_LOG_INFO (rit->WasRecentlySatisfied (header)); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 63 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 64 | // (*testname) ("test3"); // should have a side effect of changing name in the packet |
| 65 | // rit->SetRecentlySatisfied (header); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 66 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 67 | // NS_LOG_INFO (rit->WasRecentlySatisfied (header)); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 68 | |
Alexander Afanasyev | a67e28c | 2011-08-31 21:16:25 -0700 | [diff] [blame] | 69 | // header.SetNonce (2); |
| 70 | // NS_LOG_INFO (rit->WasRecentlySatisfied (header)); |
Alexander Afanasyev | fccdb9e | 2011-08-22 19:27:14 -0700 | [diff] [blame] | 71 | |
| 72 | // rit->SetRecentlySatisfied (header); |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 73 | // ? set up forwarding |
| 74 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 75 | |
| 76 | //Add static routing |
| 77 | // InternetStackHelper internet; |
| 78 | // internet.SetRoutingHelper (list); // has effect on the next Install () |
| 79 | // internet.Install (c); |
| 80 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 81 | // 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 Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 83 | // NS_LOG_INFO ("Create Applications."); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 84 | |
| 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 Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 105 | return 0; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 106 | } |