author | Craig Dowell <craigdo@ee.washington.edu> |
Tue, 20 Jan 2009 17:39:18 -0800 | |
changeset 4140 | 6bbf05bf4826 |
parent 3848 | affd0834debc |
child 4263 | fec2f830d015 |
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. |
|
76 |
* |
|
77 |
* Generate a pcap file which contains the link-level data observed |
|
78 |
* by the specified deviceid within the specified nodeid. The pcap |
|
79 |
* data is stored in the file prefix-nodeid-deviceid.pcap. |
|
80 |
* |
|
81 |
* This method should be invoked after the network topology has |
|
82 |
* been fully constructed. |
|
83 |
*/ |
|
84 |
static void EnablePcap (std::string filename, uint32_t nodeid, |
|
85 |
uint32_t deviceid); |
|
86 |
||
87 |
/** |
|
88 |
* \param filename filename prefix to use for pcap files. |
|
89 |
* \param d container of devices of type ns3::EmuNetDevice |
|
90 |
* |
|
91 |
* Enable pcap output on each input device which is of the |
|
92 |
* ns3::EmuNetDevice type. |
|
93 |
*/ |
|
94 |
static void EnablePcap (std::string filename, NetDeviceContainer d); |
|
95 |
||
96 |
/** |
|
97 |
* \param filename filename prefix to use for pcap files. |
|
98 |
* \param n container of nodes. |
|
99 |
* |
|
100 |
* Enable pcap output on each device which is of the |
|
101 |
* ns3::EmuNetDevice type and which is located in one of the |
|
102 |
* input nodes. |
|
103 |
*/ |
|
104 |
static void EnablePcap (std::string filename, NodeContainer n); |
|
105 |
||
106 |
/** |
|
107 |
* \param filename filename prefix to use for pcap files. |
|
108 |
* |
|
109 |
* Enable pcap output on each device which is of the |
|
110 |
* ns3::EmuNetDevice type |
|
111 |
*/ |
|
112 |
static void EnablePcapAll (std::string filename); |
|
113 |
||
114 |
/** |
|
115 |
* \param os output stream |
|
116 |
* \param nodeid the id of the node to generate ascii output for. |
|
117 |
* \param deviceid the id of the device to generate ascii output for. |
|
118 |
* |
|
119 |
* Enable ascii output on the specified deviceid within the |
|
120 |
* specified nodeid if it is of type ns3::EmuNetDevice and dump |
|
121 |
* that to the specified stdc++ output stream. |
|
122 |
*/ |
|
123 |
static void EnableAscii (std::ostream &os, uint32_t nodeid, |
|
124 |
uint32_t deviceid); |
|
125 |
||
126 |
/** |
|
127 |
* \param os output stream |
|
128 |
* \param d device container |
|
129 |
* |
|
130 |
* Enable ascii output on each device which is of the |
|
131 |
* ns3::EmuNetDevice type and which is located in the input |
|
132 |
* device container and dump that to the specified |
|
133 |
* stdc++ output stream. |
|
134 |
*/ |
|
135 |
static void EnableAscii (std::ostream &os, NetDeviceContainer d); |
|
136 |
||
137 |
/** |
|
138 |
* \param os output stream |
|
139 |
* \param n node container |
|
140 |
* |
|
141 |
* Enable ascii output on each device which is of the |
|
142 |
* ns3::EmuNetDevice type and which is located in one |
|
143 |
* of the input node and dump that to the specified |
|
144 |
* stdc++ output stream. |
|
145 |
*/ |
|
146 |
static void EnableAscii (std::ostream &os, NodeContainer n); |
|
147 |
||
148 |
/** |
|
149 |
* \param os output stream |
|
150 |
* |
|
151 |
* Enable ascii output on each device which is of the |
|
152 |
* ns3::EmuNetDevice type and dump that to the specified |
|
153 |
* stdc++ output stream. |
|
154 |
*/ |
|
155 |
static void EnableAsciiAll (std::ostream &os); |
|
156 |
||
157 |
/** |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
158 |
* 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
|
159 |
* 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
|
160 |
* |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
161 |
* \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
|
162 |
* \returns A containter holding the added net device. |
3828 | 163 |
*/ |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
164 |
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
|
165 |
|
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
166 |
/** |
4140
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
167 |
* 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
|
168 |
* 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
|
169 |
* |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
170 |
* \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
|
171 |
* \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
|
172 |
*/ |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
173 |
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
|
174 |
|
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
3848
diff
changeset
|
175 |
/** |
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
176 |
* 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
|
177 |
* 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
|
178 |
* 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
|
179 |
* |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
180 |
* \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
|
181 |
* \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
|
182 |
*/ |
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
183 |
NetDeviceContainer Install (const NodeContainer &c) const; |
3828 | 184 |
|
185 |
private: |
|
3848
affd0834debc
address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents:
3830
diff
changeset
|
186 |
Ptr<NetDevice> InstallPriv (Ptr<Node> node) const; |
3828 | 187 |
static void RxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet); |
188 |
static void EnqueueEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet); |
|
189 |
static void AsciiEnqueueEvent (std::ostream *os, std::string path, |
|
190 |
Ptr<const Packet> packet); |
|
191 |
static void AsciiDequeueEvent (std::ostream *os, std::string path, |
|
192 |
Ptr<const Packet> packet); |
|
193 |
static void AsciiDropEvent (std::ostream *os, std::string path, |
|
194 |
Ptr<const Packet> packet); |
|
195 |
static void AsciiRxEvent (std::ostream *os, std::string path, |
|
196 |
Ptr<const Packet> packet); |
|
197 |
||
198 |
ObjectFactory m_queueFactory; |
|
199 |
ObjectFactory m_deviceFactory; |
|
200 |
}; |
|
201 |
||
202 |
||
203 |
} // namespace ns3 |
|
204 |
||
205 |
#endif /* EMU_HELPER_H */ |