LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #include <ctime> | 25 #include <ctime> |
26 | 26 |
27 #include <sstream> | 27 #include <sstream> |
28 | 28 |
29 #include "ns3/core-module.h" | 29 #include "ns3/core-module.h" |
30 #include "ns3/common-module.h" | 30 #include "ns3/common-module.h" |
31 #include "ns3/node-module.h" | 31 #include "ns3/node-module.h" |
32 #include "ns3/helper-module.h" | 32 #include "ns3/helper-module.h" |
33 #include "ns3/mobility-module.h" | 33 #include "ns3/simulator-module.h" |
34 #include "ns3/wifi-module.h" | |
35 | |
36 #include "ns3/stats-module.h" | |
37 | 34 |
38 #include "ns3/topology-read-module.h" | 35 #include "ns3/topology-read-module.h" |
| 36 #include "ns3/topology-reader-helper.h" |
39 #include <list> | 37 #include <list> |
40 | 38 |
41 using namespace ns3; | 39 using namespace ns3; |
42 using namespace std; | 40 using namespace std; |
43 | 41 |
44 NS_LOG_COMPONENT_DEFINE ("TopologyCreationExperiment"); | 42 NS_LOG_COMPONENT_DEFINE ("TopologyCreationExperiment"); |
45 | 43 |
46 | 44 |
47 static list<unsigned int> data; | 45 static list<unsigned int> data; |
48 | 46 |
(...skipping 15 matching lines...) Expand all Loading... |
64 string input ("examples/topology-read/Inet_small_toposample.txt"); | 62 string input ("examples/topology-read/Inet_small_toposample.txt"); |
65 | 63 |
66 // Set up command line parameters used to control the experiment. | 64 // Set up command line parameters used to control the experiment. |
67 CommandLine cmd; | 65 CommandLine cmd; |
68 cmd.AddValue ("format", "Format to use for data input [Orbis|Inet].", | 66 cmd.AddValue ("format", "Format to use for data input [Orbis|Inet].", |
69 format); | 67 format); |
70 cmd.AddValue ("input", "Name of the input file.", | 68 cmd.AddValue ("input", "Name of the input file.", |
71 input); | 69 input); |
72 cmd.Parse (argc, argv); | 70 cmd.Parse (argc, argv); |
73 | 71 |
74 if (format != "Orbis" && format != "Inet") | |
75 { | |
76 NS_LOG_ERROR ("Unknown input format '" << format << "'"); | |
77 return -1; | |
78 } | |
79 | 72 |
80 // ------------------------------------------------------------ | 73 // ------------------------------------------------------------ |
81 // -- Read topology data. | 74 // -- Read topology data. |
82 // -------------------------------------------- | 75 // -------------------------------------------- |
83 | 76 |
84 // Pick a topology reader based in the requested format. | 77 // Pick a topology reader based in the requested format. |
85 | 78 |
86 Ptr<TopologyReader> inFile = 0; | 79 Ptr<TopologyReader> inFile = 0; |
87 | 80 TopologyReaderHelper topoHelp; |
| 81 ·· |
88 NodeContainer nodes; | 82 NodeContainer nodes; |
89 | 83 ·· |
90 if (format == "Orbis") | 84 topoHelp.SetFileName(input); |
91 { | 85 topoHelp.SetFileType(format); |
92 NS_LOG_INFO ("Reading Orbis formatted data input."); | 86 inFile = topoHelp.GetTopologyReader(); |
93 inFile = CreateObject<OrbisTopologyReader> (); | |
94 } | |
95 else if (format == "Inet") | |
96 { | |
97 NS_LOG_INFO ("Reading Inet formatted data input."); | |
98 inFile = CreateObject<InetTopologyReader> (); | |
99 } | |
100 | 87 |
101 if (inFile != 0) | 88 if (inFile != 0) |
102 { | 89 { |
103 inFile->SetFileName (input); | |
104 nodes = inFile->Read (); | 90 nodes = inFile->Read (); |
105 } | 91 } |
106 | 92 |
107 if (inFile->LinksSize () == 0) | 93 if (inFile->LinksSize () == 0) |
108 { | 94 { |
109 NS_LOG_ERROR ("Problems reading the topology file. Failing."); | 95 NS_LOG_ERROR ("Problems reading the topology file. Failing."); |
110 return -1; | 96 return -1; |
111 } | 97 } |
112 | 98 |
113 // ------------------------------------------------------------ | 99 // ------------------------------------------------------------ |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 NS_LOG_INFO ("Run Simulation."); | 200 NS_LOG_INFO ("Run Simulation."); |
215 Simulator::Run (); | 201 Simulator::Run (); |
216 Simulator::Destroy (); | 202 Simulator::Destroy (); |
217 | 203 |
218 NS_LOG_INFO ("Done."); | 204 NS_LOG_INFO ("Done."); |
219 | 205 |
220 return 0; | 206 return 0; |
221 | 207 |
222 // end main | 208 // end main |
223 } | 209 } |
LEFT | RIGHT |