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 | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 17 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 18 | // Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210)); |
| 19 | // Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s")); |
| 20 | |
| 21 | Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("10Mbps")); |
| 22 | Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("1ms")); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 23 | |
| 24 | CommandLine cmd; |
| 25 | cmd.Parse (argc, argv); |
| 26 | |
| 27 | // Here, we will explicitly create seven nodes. |
| 28 | NodeContainer c; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 29 | c.Create (3); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 30 | |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 31 | NodeContainer n1 = NodeContainer (c.Get (0), c.Get (1)); |
| 32 | NodeContainer n2 = NodeContainer (c.Get (1), c.Get (2)); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 33 | |
| 34 | // Ipv4StaticRoutingHelper staticRouting; |
| 35 | |
| 36 | // Ipv4ListRoutingHelper list; |
| 37 | // list.Add (staticRouting, 1); |
| 38 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 39 | NS_LOG_INFO ("Create channels."); |
| 40 | PointToPointHelper p2p; |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 41 | // NetDeviceContainer nd = |
| 42 | p2p.Install (n1); |
| 43 | p2p.Install (n2); |
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 | |
| 49 | // ? set up forwarding |
| 50 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 51 | |
| 52 | //Add static routing |
| 53 | // InternetStackHelper internet; |
| 54 | // internet.SetRoutingHelper (list); // has effect on the next Install () |
| 55 | // internet.Install (c); |
| 56 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 57 | // Create the OnOff application to send UDP datagrams of size |
| 58 | // 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] | 59 | // NS_LOG_INFO ("Create Applications."); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 60 | |
| 61 | // std::string sendsizeattr = "SendSize"; |
| 62 | // //flow2 7-->2 |
| 63 | // BulkSendHelper bulksend0 ("ns3::CcnxLocalFaceFactory", InetSocketAddress (i23.GetAddress (0), port)); |
| 64 | // //bulksend0.SetAttribute(sendsizeattr, AttributeValue(ConstantVariable(2560))); |
| 65 | // bulksend0.SetAttribute("MaxBytes", UintegerValue(2560)); |
| 66 | // ApplicationContainer apps = bulksend0.Install(c.Get(6)); |
| 67 | // apps.Start(Seconds (1.0)); |
| 68 | // apps.Stop(Seconds (10.0)); |
| 69 | |
| 70 | // AsciiTraceHelper ascii; |
| 71 | // p2p.EnableAsciiAll (ascii.CreateFileStream ("ccnx-test.tr")); |
| 72 | // p2p.EnablePcapAll ("ccnx-test"); |
| 73 | |
| 74 | Simulator::Stop (Seconds (20)); |
| 75 | |
| 76 | NS_LOG_INFO ("Run Simulation."); |
| 77 | Simulator::Run (); |
| 78 | Simulator::Destroy (); |
| 79 | NS_LOG_INFO ("Done."); |
| 80 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 81 | return 0; |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 82 | } |