4
|
1 |
diff -r 137184880c3b example/dce-quagga-bgpd-caida.cc
|
|
2 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
3 |
+++ b/example/dce-quagga-bgpd-caida.cc Tue Jan 24 17:31:19 2012 +0900
|
|
4 |
@@ -0,0 +1,159 @@
|
|
5 |
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
6 |
+
|
|
7 |
+#include "ns3/network-module.h"
|
|
8 |
+#include "ns3/core-module.h"
|
|
9 |
+#include "ns3/internet-module.h"
|
|
10 |
+#include "ns3/dce-module.h"
|
|
11 |
+#include "ns3/quagga-helper.h"
|
|
12 |
+#include "ns3/point-to-point-helper.h"
|
|
13 |
+#include "../helper/ipv4-dce-routing-helper.h"
|
|
14 |
+#include "ns3/topology-read-module.h"
|
|
15 |
+#include <sys/resource.h>
|
|
16 |
+
|
|
17 |
+using namespace ns3;
|
|
18 |
+NS_LOG_COMPONENT_DEFINE ("DceQuaggaBgpd");
|
|
19 |
+
|
|
20 |
+// Parameters
|
|
21 |
+uint32_t nNodes = 2;
|
|
22 |
+uint32_t stopTime = 6000;
|
|
23 |
+
|
|
24 |
+static void
|
|
25 |
+SetRlimit ()
|
|
26 |
+{
|
|
27 |
+ int ret;
|
|
28 |
+ struct rlimit limit;
|
|
29 |
+ limit.rlim_cur = 1000000;
|
|
30 |
+ limit.rlim_max = 1000000;
|
|
31 |
+
|
|
32 |
+ ret = setrlimit(RLIMIT_NOFILE, &limit);
|
|
33 |
+ if (ret == -1)
|
|
34 |
+ {
|
|
35 |
+ perror ("setrlimit");
|
|
36 |
+ }
|
|
37 |
+ return;
|
|
38 |
+}
|
|
39 |
+
|
|
40 |
+static void RunIp (Ptr<Node> node, Time at, std::string str)
|
|
41 |
+{
|
|
42 |
+ DceApplicationHelper process;
|
|
43 |
+ ApplicationContainer apps;
|
|
44 |
+ process.SetBinary ("ip");
|
|
45 |
+ process.SetStackSize (1<<16);
|
|
46 |
+ process.ResetArguments();
|
|
47 |
+ process.ParseArguments(str.c_str ());
|
|
48 |
+ apps = process.Install (node);
|
|
49 |
+ apps.Start (at);
|
|
50 |
+}
|
|
51 |
+
|
|
52 |
+static void AddAddress (Ptr<Node> node, Time at, const char *name, const char *address)
|
|
53 |
+{
|
|
54 |
+ std::ostringstream oss;
|
|
55 |
+ oss << "-f inet addr add " << address << " dev " << name;
|
|
56 |
+ RunIp (node, at, oss.str ());
|
|
57 |
+}
|
|
58 |
+
|
|
59 |
+int main (int argc, char *argv[]) {
|
|
60 |
+ //
|
|
61 |
+ // Step 0
|
|
62 |
+ // Node Basic Configuration
|
|
63 |
+ //
|
|
64 |
+
|
|
65 |
+ CommandLine cmd;
|
|
66 |
+ cmd.AddValue ("stopTime", "Time to stop(seconds)", stopTime);
|
|
67 |
+ cmd.Parse (argc,argv);
|
|
68 |
+
|
|
69 |
+ //
|
|
70 |
+ // Step 1
|
|
71 |
+ // Node Basic Configuration
|
|
72 |
+ //
|
|
73 |
+ Ptr<TopologyReader> inFile = 0;
|
|
74 |
+ TopologyReaderHelper topoHelp;
|
|
75 |
+ NodeContainer nodes;
|
|
76 |
+
|
|
77 |
+ std::string format ("Caida");
|
|
78 |
+ std::string input ("./asrel-as2500.txt");
|
|
79 |
+
|
|
80 |
+ topoHelp.SetFileName(input);
|
|
81 |
+ topoHelp.SetFileType(format);
|
|
82 |
+ inFile = topoHelp.GetTopologyReader();
|
|
83 |
+
|
|
84 |
+ if (inFile != 0)
|
|
85 |
+ {
|
|
86 |
+ nodes = inFile->Read ();
|
|
87 |
+ }
|
|
88 |
+
|
|
89 |
+ if (nodes.GetN () == 0)
|
|
90 |
+ {
|
|
91 |
+ NS_LOG_ERROR ("Problems reading node information the topology file. Failing.");
|
|
92 |
+ return -1;
|
|
93 |
+ }
|
|
94 |
+ if (inFile->LinksSize () == 0)
|
|
95 |
+ {
|
|
96 |
+ NS_LOG_ERROR ("Problems reading the topology file. Failing.");
|
|
97 |
+ return -1;
|
|
98 |
+ }
|
|
99 |
+ NS_LOG_INFO ("Caida topology created with " << nodes.GetN () << " nodes and " <<
|
|
100 |
+ inFile->LinksSize () << " links (from " << input << ")");
|
|
101 |
+
|
|
102 |
+ // Address conf In virtual topology
|
|
103 |
+ PointToPointHelper p2p;
|
|
104 |
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
|
105 |
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
|
106 |
+
|
|
107 |
+ int totlinks = inFile->LinksSize ();
|
|
108 |
+ NS_LOG_INFO ("creating node containers");
|
|
109 |
+ NodeContainer nc[totlinks];
|
|
110 |
+ TopologyReader::ConstLinksIterator iter;
|
|
111 |
+ int i = 0;
|
|
112 |
+ for ( iter = inFile->LinksBegin (); iter != inFile->LinksEnd (); iter++, i++ )
|
|
113 |
+ {
|
|
114 |
+ nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
|
|
115 |
+ }
|
|
116 |
+
|
|
117 |
+ DceManagerHelper processManager;
|
|
118 |
+ processManager.SetLoader ("ns3::DlmLoaderFactory");
|
|
119 |
+ processManager.SetTaskManagerAttribute ("FiberManagerType",
|
|
120 |
+ EnumValue (0));
|
|
121 |
+ processManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
|
|
122 |
+ "Library", StringValue ("libnet-next-2.6.so"));
|
|
123 |
+ processManager.Install (nodes);
|
|
124 |
+ QuaggaHelper quagga;
|
|
125 |
+ quagga.EnableBgp (nodes);
|
|
126 |
+
|
|
127 |
+ NS_LOG_INFO ("creating net device containers");
|
|
128 |
+ NetDeviceContainer ndc[totlinks];
|
|
129 |
+ for (int i = 0; i < totlinks; i++)
|
|
130 |
+ {
|
|
131 |
+ ndc[i] = p2p.Install (nc[i]);
|
|
132 |
+
|
|
133 |
+#if 0
|
|
134 |
+ // IP address configuration
|
|
135 |
+ AddAddress (nodes.Get (0), Seconds (0.1), "sim0", "10.0.0.1/24");
|
|
136 |
+ RunIp (nodes.Get (0), Seconds (0.11), "link set lo up");
|
|
137 |
+ RunIp (nodes.Get (0), Seconds (0.11), "link set sim0 up");
|
|
138 |
+
|
|
139 |
+ AddAddress (nodes.Get (1), Seconds (0.1), "sim0", "10.0.0.2/24");
|
|
140 |
+ RunIp (nodes.Get (1), Seconds (0.11), "link set lo up");
|
|
141 |
+ RunIp (nodes.Get (1), Seconds (0.11), "link set sim0 up");
|
|
142 |
+
|
|
143 |
+ quagga.BgpAddNeighbor (nodes.Get (0), "10.0.0.2", quagga.GetAsn(nodes.Get (1)));
|
|
144 |
+ quagga.BgpAddNeighbor (nodes.Get (1), "10.0.0.1", quagga.GetAsn(nodes.Get (0)));
|
|
145 |
+ quagga.Install (nodes);
|
|
146 |
+#endif
|
|
147 |
+ }
|
|
148 |
+
|
|
149 |
+
|
|
150 |
+ // p2p.EnablePcapAll ("dce-quagga-bgpd-caida");
|
|
151 |
+
|
|
152 |
+ //
|
|
153 |
+ // Now It's ready to GO!
|
|
154 |
+ //
|
|
155 |
+ if (stopTime != 0)
|
|
156 |
+ {
|
|
157 |
+ Simulator::Stop (Seconds (stopTime));
|
|
158 |
+ }
|
|
159 |
+ Simulator::Run ();
|
|
160 |
+ Simulator::Destroy ();
|
|
161 |
+
|
|
162 |
+ return 0;
|
|
163 |
+}
|
|
164 |
diff -r 137184880c3b wscript
|
|
165 |
--- a/wscript Tue Jan 24 16:33:26 2012 +0900
|
|
166 |
+++ b/wscript Tue Jan 24 17:31:19 2012 +0900
|
|
167 |
@@ -266,6 +266,10 @@
|
|
168 |
target='bin/dce-quagga-ospfd',
|
|
169 |
source=['example/dce-quagga-ospfd.cc'])
|
|
170 |
|
|
171 |
+ module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point', 'visualizer', 'topology-read'],
|
|
172 |
+ target='bin/dce-quagga-bgpd-caida',
|
|
173 |
+ source=['example/dce-quagga-bgpd-caida.cc'])
|
|
174 |
+
|
|
175 |
module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
|
|
176 |
target='bin/dce-quagga-bgpd',
|
|
177 |
source=['example/dce-quagga-bgpd.cc'])
|