author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 4264 | 9d2e96c4e6e4 |
permissions | -rw-r--r-- |
3828 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008 University of Washington |
|
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 |
||
19 |
#ifndef EMU_HELPER_H |
|
20 |
#define EMU_HELPER_H |
|
21 |
||
22 |
#include <string> |
|
23 |
#include <ostream> |
|
24 |
#include "ns3/attribute.h" |
|
25 |
#include "ns3/object-factory.h" |
|
26 |
#include "ns3/net-device-container.h" |
|
27 |
#include "ns3/node-container.h" |
|
3830
8862b9be62bb
rework to address suid root issues
Craig Dowell <craigdo@ee.washington.edu>
parents:
3828
diff
changeset
|
28 |
#include "ns3/emu-net-device.h" |
3828 | 29 |
|
30 |
namespace ns3 { |
|
31 |
||
32 |
class Packet; |
|
33 |
class PcapWriter; |
|
34 |
||
35 |
/** |
|
36 |
* \brief build a set of EmuNetDevice objects |
|
37 |
*/ |
|
38 |
class EmuHelper |
|
39 |
{ |
|
40 |
public: |
|
41 |
EmuHelper (); |
|
42 |
||
43 |
/** |
|
44 |
* \param type the type of queue |
|
45 |
* \param n1 the name of the attribute to set on the queue |
|
46 |
* \param v1 the value of the attribute to set on the queue |
|
47 |
* \param n2 the name of the attribute to set on the queue |
|
48 |
* \param v2 the value of the attribute to set on the queue |
|
49 |
* \param n3 the name of the attribute to set on the queue |
|
50 |
* \param v3 the value of the attribute to set on the queue |
|
51 |
* \param n4 the name of the attribute to set on the queue |
|
52 |
* \param v4 the value of the attribute to set on the queue |
|
53 |
* |
|
54 |
* Set the type of queue to create and associated to each |
|
55 |
* EmuNetDevice created through EmuHelper::Install. |
|
56 |
*/ |
|
57 |
void SetQueue (std::string type, |
|
58 |
std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), |
|
59 |
std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), |
|
60 |
std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), |
|
61 |
std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue ()); |
|
62 |
||
63 |
/** |
|
64 |
* \param n1 the name of the attribute to set |
|
65 |
* \param v1 the value of the attribute to set |
|
66 |
* |
|
67 |
* Set these attributes on each ns3::EmuNetDevice created |
|
68 |
* by EmuHelper::Install |
|
69 |
*/ |
|
70 |
void SetAttribute (std::string n1, const AttributeValue &v1); |
|
71 |
||
72 |
/** |
|
73 |
* \param filename filename prefix to use for pcap files. |
|
74 |
* \param nodeid the id of the node to generate pcap output for. |
|
75 |
* \param deviceid the id of the device to generate pcap output for. |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
76 |
* \param promiscuous If true capture all possible packets available at the device. |
3828 | 77 |
* |
78 |
* Generate a pcap file which contains the link-level data observed |
|
79 |
* by the specified deviceid within the specified nodeid. The pcap |
|
80 |
* data is stored in the file prefix-nodeid-deviceid.pcap. |
|
81 |
* |
|
82 |
* This method should be invoked after the network topology has |
|
83 |
* been fully constructed. |
|
84 |
*/ |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
85 |
static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid, bool promiscuous); |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
86 |
|
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
87 |
/** |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
88 |
* \param filename filename prefix to use for pcap files. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
89 |
* \param nd Indicates net device on which you want to enable tracing. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
90 |
* \param promiscuous If true capture all possible packets available at the device. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
91 |
* |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
92 |
* Enable pcap output on each input device which is of the |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
93 |
* ns3::EmuNetDevice type. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
94 |
*/ |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
95 |
static void EnablePcap (std::string filename, Ptr<NetDevice> nd, bool promiscuous); |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
96 |
|
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
97 |
/** |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
98 |
* \param filename filename prefix to use for pcap files. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
99 |
* \param ndName Name of net device on which you want to enable tracing. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
100 |
* \param promiscuous If true capture all possible packets available at the device. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
101 |
* |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
102 |
* Enable pcap output on each input device which is of the |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
103 |
* ns3::EmuNetDevice type. |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
104 |
*/ |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
105 |
static void EnablePcap (std::string filename, std::string ndName, bool promiscuous); |
3828 | 106 |
|
107 |
/** |
|
108 |
* \param filename filename prefix to use for pcap files. |
|
109 |
* \param d container of devices of type ns3::EmuNetDevice |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
110 |
* \param promiscuous If true capture all possible packets available at the device. |
3828 | 111 |
* |
112 |
* Enable pcap output on each input device which is of the |
|
113 |
* ns3::EmuNetDevice type. |
|
114 |
*/ |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
115 |
static void EnablePcap (std::string filename, NetDeviceContainer d, bool promiscuous); |
3828 | 116 |
|
117 |
/** |
|
118 |
* \param filename filename prefix to use for pcap files. |
|
119 |
* \param n container of nodes. |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
120 |
* \param promiscuous If true capture all possible packets available at the device. |
3828 | 121 |
* |
122 |
* Enable pcap output on each device which is of the |
|
123 |
* ns3::EmuNetDevice type and which is located in one of the |
|
124 |
* input nodes. |
|
125 |
*/ |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
126 |
static void EnablePcap (std::string filename, NodeContainer n, bool promiscuous); |
3828 | 127 |
|
128 |
/** |
|
129 |
* \param filename filename prefix to use for pcap files. |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
130 |
* \param promiscuous If true capture all possible packets available at the device. |
3828 | 131 |
* |
132 |
* Enable pcap output on each device which is of the |
|
133 |
* ns3::EmuNetDevice type |
|
134 |
*/ |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
135 |
static void EnablePcapAll (std::string filename, bool promiscuous); |
3828 | 136 |
|
137 |
/** |
|
138 |
* \param os output stream |
|
139 |
* \param nodeid the id of the node to generate ascii output for. |
|
140 |
* \param deviceid the id of the device to generate ascii output for. |
|
141 |
* |
|
142 |
* Enable ascii output on the specified deviceid within the |
|
143 |
* specified nodeid if it is of type ns3::EmuNetDevice and dump |
|
144 |
* that to the specified stdc++ output stream. |
|
145 |
*/ |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
146 |
static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid); |
3828 | 147 |
|
148 |
/** |
|
149 |
* \param os output stream |
|
150 |
* \param d device container |
|
151 |
* |
|
152 |
* Enable ascii output on each device which is of the |
|
153 |
* ns3::EmuNetDevice type and which is located in the input |
|
154 |
* device container and dump that to the specified |
|
155 |
* stdc++ output stream. |
|
156 |
*/ |
|
157 |
static void EnableAscii (std::ostream &os, NetDeviceContainer d); |
|
158 |
||
159 |
/** |
|
160 |
* \param os output stream |
|
161 |
* \param n node container |
|
162 |
* |
|
163 |
* Enable ascii output on each device which is of the |
|
164 |
* ns3::EmuNetDevice type and which is located in one |
|
165 |
* of the input node and dump that to the specified |
|
166 |
* stdc++ output stream. |
|
167 |
*/ |
|
168 |
static void EnableAscii (std::ostream &os, NodeContainer n); |
|
169 |
||
170 |
/** |
|
171 |
* \param os output stream |
|
172 |
* |
|
173 |
* Enable ascii output on each device which is of the |
|
174 |
* ns3::EmuNetDevice type and dump that to the specified |
|
175 |
* stdc++ output stream. |
|
176 |
*/ |
|
177 |
static void EnableAsciiAll (std::ostream &os); |
|
178 |
||
179 |
/** |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
180 |
* This method creates an ns3::EmuNetDevice with the attributes configured by |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
181 |
* EmuHelper::SetDeviceAttribute and then adds the device to the node. |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
182 |
* |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
183 |
* \param node The node to install the device in |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
184 |
* \returns A containter holding the added net device. |
3828 | 185 |
*/ |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
186 |
NetDeviceContainer Install (Ptr<Node> node) const; |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
187 |
|
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
188 |
/** |
4140
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
189 |
* This method creates an ns3::EmuNetDevice with the attributes configured by |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
190 |
* EmuHelper::SetDeviceAttribute and then adds the device to the node. |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
191 |
* |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
192 |
* \param nodeName The name of the node to install the device in |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
193 |
* \returns A containter holding the added net device. |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
194 |
*/ |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
195 |
NetDeviceContainer Install (std::string nodeName) const; |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
196 |
|
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
197 |
/** |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
198 |
* For each Ptr<node> in the provided container this method creates an |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
199 |
* ns3::EmuNetDevice (with the attributes configured by |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
200 |
* EmuHelper::SetDeviceAttribute); adds the device to the node. |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
201 |
* |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
202 |
* \param c The NodeContainer holding the nodes to be changed. |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
203 |
* \returns A containter holding the added net devices. |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
204 |
*/ |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
205 |
NetDeviceContainer Install (const NodeContainer &c) const; |
3828 | 206 |
|
207 |
private: |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
208 |
Ptr<NetDevice> InstallPriv (Ptr<Node> node) const; |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
209 |
static void SniffEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
210 |
|
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
211 |
static void AsciiRxEvent (std::ostream *os, std::string path, Ptr<const Packet> packet); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
212 |
static void AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
213 |
static void AsciiDequeueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
214 |
static void AsciiDropEvent (std::ostream *os, std::string path, Ptr<const Packet> packet); |
3828 | 215 |
|
216 |
ObjectFactory m_queueFactory; |
|
217 |
ObjectFactory m_deviceFactory; |
|
218 |
}; |
|
219 |
||
220 |
||
221 |
} // namespace ns3 |
|
222 |
||
223 |
#endif /* EMU_HELPER_H */ |