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