Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | |
| 22 | #include "ns3/core-module.h" |
| 23 | #include "ns3/network-module.h" |
| 24 | #include "ns3/point-to-point-module.h" |
| 25 | #include "ns3/NDNabstraction-module.h" |
| 26 | #include "ns3/point-to-point-grid.h" |
| 27 | #include "ns3/ipv4-global-routing-helper.h" |
| 28 | |
| 29 | #include <iostream> |
| 30 | #include <sstream> |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 31 | #include "ns3/annotated-topology-reader.h" |
| 32 | |
| 33 | using namespace ns3; |
| 34 | using namespace std; |
| 35 | |
| 36 | NS_LOG_COMPONENT_DEFINE ("CcnxAbileneTopology"); |
| 37 | |
| 38 | int |
| 39 | main (int argc, char *argv[]) |
| 40 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 41 | // Packet::EnableChecking(); |
| 42 | // Packet::EnablePrinting(); |
| 43 | string input ("./src/NDNabstraction/examples/abilene-topology.txt"); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 44 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 45 | CommandLine cmd; |
| 46 | cmd.Parse (argc, argv); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 47 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 48 | // ------------------------------------------------------------ |
| 49 | // -- Read topology data. |
| 50 | // -------------------------------------------- |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 51 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 52 | Ptr<AnnotatedTopologyReader> reader = CreateObject<AnnotatedTopologyReader> (); |
| 53 | reader->SetFileName (input); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 54 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 55 | NodeContainer nodes; |
| 56 | if (reader != 0) |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 57 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 58 | nodes = reader->Read (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 59 | } |
| 60 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 61 | if (reader->LinksSize () == 0) |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 62 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 63 | NS_LOG_ERROR ("Problems reading the topology file. Failing."); |
| 64 | return -1; |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 67 | NS_LOG_INFO("Nodes = " << nodes.GetN()); |
| 68 | NS_LOG_INFO("Links = " << reader->LinksSize ()); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 69 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 70 | int totlinks = reader->LinksSize (); |
| 71 | ///*** applying settings |
| 72 | NS_LOG_INFO ("creating node containers"); |
| 73 | NodeContainer* nc = new NodeContainer[totlinks]; |
| 74 | TopologyReader::ConstLinksIterator iter; |
| 75 | int i = 0; |
| 76 | for ( iter = reader->LinksBegin (); iter != reader->LinksEnd (); iter++, i++ ) |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 77 | { |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 78 | nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ()); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 79 | } |
| 80 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 81 | NetDeviceContainer* ndc = new NetDeviceContainer[totlinks]; |
| 82 | reader->ApplySettings(ndc,nc); |
| 83 | reader->BoundingBox(nc, 100.0, 100.0, 400.0,400.0); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 84 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 85 | // Install CCNx stack |
| 86 | NS_LOG_INFO ("Installing CCNx stack"); |
| 87 | CcnxStackHelper ccnxHelper; |
| 88 | // ccnxHelper.SetForwardingStrategy (strategy); |
| 89 | ccnxHelper.EnableLimits (true, Seconds(0.1)); |
| 90 | ccnxHelper.InstallAll (); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 91 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 92 | NS_LOG_INFO ("Installing Applications"); |
| 93 | CcnxConsumerHelper consumerHelper ("preved"); |
| 94 | ApplicationContainer consumers = consumerHelper.Install (nc[0]); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 95 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 96 | consumers.Start (Seconds (0)); |
| 97 | consumers.Stop (Seconds (20)); |
Ilya Moiseenko | 58d2667 | 2011-12-08 13:48:06 -0800 | [diff] [blame] | 98 | |
Alexander Afanasyev | 3406f3e | 2011-12-08 14:11:31 -0800 | [diff] [blame^] | 99 | Simulator::Stop (Seconds (20)); |
| 100 | NS_LOG_INFO ("Run Simulation."); |
| 101 | Simulator::Run (); |
| 102 | Simulator::Destroy (); |
| 103 | NS_LOG_INFO ("Done."); |
| 104 | return 0; |
| 105 | } |