author | Ghada Badawy <gbadawy@gmail.com> |
Tue, 13 Aug 2013 22:05:25 -0700 | |
changeset 10139 | 17a71cd49da3 |
parent 9005 | 245e1d5c2777 |
child 10968 | 2d29fee2b7b8 |
permissions | -rw-r--r-- |
3912 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008 INRIA |
|
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
19 |
*/ |
|
6013 | 20 |
|
6834
036f9a0b9899
Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents:
6459
diff
changeset
|
21 |
#include "ns3/trace-helper.h" |
4000
07bf8da834e0
bug 435: file names are not consistent
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3912
diff
changeset
|
22 |
#include "yans-wifi-helper.h" |
3912 | 23 |
#include "ns3/error-rate-model.h" |
24 |
#include "ns3/propagation-loss-model.h" |
|
25 |
#include "ns3/propagation-delay-model.h" |
|
26 |
#include "ns3/yans-wifi-channel.h" |
|
27 |
#include "ns3/yans-wifi-phy.h" |
|
28 |
#include "ns3/wifi-net-device.h" |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
29 |
#include "ns3/radiotap-header.h" |
6052
e146b9c9c7e7
PcapFileObject to PcapFileWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents:
6049
diff
changeset
|
30 |
#include "ns3/pcap-file-wrapper.h" |
3912 | 31 |
#include "ns3/simulator.h" |
32 |
#include "ns3/config.h" |
|
4147
5d8530130930
rename object-names.{cc,h} to names.{cc,h} per convention
Craig Dowell <craigdo@ee.washington.edu>
parents:
4140
diff
changeset
|
33 |
#include "ns3/names.h" |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
34 |
#include "ns3/abort.h" |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
35 |
#include "ns3/log.h" |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
36 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
37 |
NS_LOG_COMPONENT_DEFINE ("YansWifiHelper"); |
3912 | 38 |
|
39 |
namespace ns3 { |
|
40 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
41 |
static void |
6013 | 42 |
AsciiPhyTransmitSinkWithContext ( |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
43 |
Ptr<OutputStreamWrapper> stream, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
44 |
std::string context, |
6013 | 45 |
Ptr<const Packet> p, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
46 |
WifiMode mode, |
6013 | 47 |
WifiPreamble preamble, |
48 |
uint8_t txLevel) |
|
3912 | 49 |
{ |
6013 | 50 |
NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel); |
51 |
*stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl; |
|
52 |
} |
|
53 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
54 |
static void |
6013 | 55 |
AsciiPhyTransmitSinkWithoutContext ( |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
56 |
Ptr<OutputStreamWrapper> stream, |
6013 | 57 |
Ptr<const Packet> p, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
58 |
WifiMode mode, |
6013 | 59 |
WifiPreamble preamble, |
60 |
uint8_t txLevel) |
|
61 |
{ |
|
62 |
NS_LOG_FUNCTION (stream << p << mode << preamble << txLevel); |
|
63 |
*stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *p << std::endl; |
|
3912 | 64 |
} |
65 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
66 |
static void |
6013 | 67 |
AsciiPhyReceiveSinkWithContext ( |
6053
b17ea72acee9
OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents:
6052
diff
changeset
|
68 |
Ptr<OutputStreamWrapper> stream, |
6013 | 69 |
std::string context, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
70 |
Ptr<const Packet> p, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
71 |
double snr, |
6013 | 72 |
WifiMode mode, |
73 |
enum WifiPreamble preamble) |
|
3912 | 74 |
{ |
6013 | 75 |
NS_LOG_FUNCTION (stream << context << p << snr << mode << preamble); |
76 |
*stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl; |
|
3912 | 77 |
} |
78 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
79 |
static void |
6013 | 80 |
AsciiPhyReceiveSinkWithoutContext ( |
6053
b17ea72acee9
OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents:
6052
diff
changeset
|
81 |
Ptr<OutputStreamWrapper> stream, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
82 |
Ptr<const Packet> p, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
83 |
double snr, |
6013 | 84 |
WifiMode mode, |
85 |
enum WifiPreamble preamble) |
|
86 |
{ |
|
87 |
NS_LOG_FUNCTION (stream << p << snr << mode << preamble); |
|
88 |
*stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *p << std::endl; |
|
89 |
} |
|
3912 | 90 |
|
91 |
YansWifiChannelHelper::YansWifiChannelHelper () |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
92 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
93 |
} |
3912 | 94 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
95 |
YansWifiChannelHelper |
3912 | 96 |
YansWifiChannelHelper::Default (void) |
97 |
{ |
|
98 |
YansWifiChannelHelper helper; |
|
99 |
helper.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); |
|
100 |
helper.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); |
|
101 |
return helper; |
|
102 |
} |
|
103 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
104 |
void |
3912 | 105 |
YansWifiChannelHelper::AddPropagationLoss (std::string type, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
106 |
std::string n0, const AttributeValue &v0, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
107 |
std::string n1, const AttributeValue &v1, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
108 |
std::string n2, const AttributeValue &v2, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
109 |
std::string n3, const AttributeValue &v3, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
110 |
std::string n4, const AttributeValue &v4, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
111 |
std::string n5, const AttributeValue &v5, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
112 |
std::string n6, const AttributeValue &v6, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
113 |
std::string n7, const AttributeValue &v7) |
3912 | 114 |
{ |
115 |
ObjectFactory factory; |
|
116 |
factory.SetTypeId (type); |
|
117 |
factory.Set (n0, v0); |
|
118 |
factory.Set (n1, v1); |
|
119 |
factory.Set (n2, v2); |
|
120 |
factory.Set (n3, v3); |
|
121 |
factory.Set (n4, v4); |
|
122 |
factory.Set (n5, v5); |
|
123 |
factory.Set (n6, v6); |
|
124 |
factory.Set (n7, v7); |
|
125 |
m_propagationLoss.push_back (factory); |
|
126 |
} |
|
127 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
128 |
void |
3912 | 129 |
YansWifiChannelHelper::SetPropagationDelay (std::string type, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
130 |
std::string n0, const AttributeValue &v0, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
131 |
std::string n1, const AttributeValue &v1, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
132 |
std::string n2, const AttributeValue &v2, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
133 |
std::string n3, const AttributeValue &v3, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
134 |
std::string n4, const AttributeValue &v4, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
135 |
std::string n5, const AttributeValue &v5, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
136 |
std::string n6, const AttributeValue &v6, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
137 |
std::string n7, const AttributeValue &v7) |
3912 | 138 |
{ |
139 |
ObjectFactory factory; |
|
140 |
factory.SetTypeId (type); |
|
141 |
factory.Set (n0, v0); |
|
142 |
factory.Set (n1, v1); |
|
143 |
factory.Set (n2, v2); |
|
144 |
factory.Set (n3, v3); |
|
145 |
factory.Set (n4, v4); |
|
146 |
factory.Set (n5, v5); |
|
147 |
factory.Set (n6, v6); |
|
148 |
factory.Set (n7, v7); |
|
149 |
m_propagationDelay = factory; |
|
150 |
} |
|
151 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
152 |
Ptr<YansWifiChannel> |
3912 | 153 |
YansWifiChannelHelper::Create (void) const |
154 |
{ |
|
155 |
Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> (); |
|
156 |
Ptr<PropagationLossModel> prev = 0; |
|
157 |
for (std::vector<ObjectFactory>::const_iterator i = m_propagationLoss.begin (); i != m_propagationLoss.end (); ++i) |
|
158 |
{ |
|
159 |
Ptr<PropagationLossModel> cur = (*i).Create<PropagationLossModel> (); |
|
160 |
if (prev != 0) |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
161 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
162 |
prev->SetNext (cur); |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
163 |
} |
3912 | 164 |
if (m_propagationLoss.begin () == i) |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
165 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
166 |
channel->SetPropagationLossModel (cur); |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
167 |
} |
4058
5c7df2c1cfc5
update prev even if it is null
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
4038
diff
changeset
|
168 |
prev = cur; |
3912 | 169 |
} |
170 |
Ptr<PropagationDelayModel> delay = m_propagationDelay.Create<PropagationDelayModel> (); |
|
171 |
channel->SetPropagationDelayModel (delay); |
|
172 |
return channel; |
|
173 |
} |
|
174 |
||
9005
245e1d5c2777
adjust API for wifi helpers for AssignStreams()
Tom Henderson <tomh@tomh.org>
parents:
8985
diff
changeset
|
175 |
int64_t |
245e1d5c2777
adjust API for wifi helpers for AssignStreams()
Tom Henderson <tomh@tomh.org>
parents:
8985
diff
changeset
|
176 |
YansWifiChannelHelper::AssignStreams (Ptr<YansWifiChannel> c, int64_t stream) |
245e1d5c2777
adjust API for wifi helpers for AssignStreams()
Tom Henderson <tomh@tomh.org>
parents:
8985
diff
changeset
|
177 |
{ |
245e1d5c2777
adjust API for wifi helpers for AssignStreams()
Tom Henderson <tomh@tomh.org>
parents:
8985
diff
changeset
|
178 |
return c->AssignStreams (stream); |
245e1d5c2777
adjust API for wifi helpers for AssignStreams()
Tom Henderson <tomh@tomh.org>
parents:
8985
diff
changeset
|
179 |
} |
245e1d5c2777
adjust API for wifi helpers for AssignStreams()
Tom Henderson <tomh@tomh.org>
parents:
8985
diff
changeset
|
180 |
|
3912 | 181 |
YansWifiPhyHelper::YansWifiPhyHelper () |
4492
3ebeb7bf3c15
added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents:
4264
diff
changeset
|
182 |
: m_channel (0), |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
183 |
m_pcapDlt (PcapHelper::DLT_IEEE802_11) |
3912 | 184 |
{ |
185 |
m_phy.SetTypeId ("ns3::YansWifiPhy"); |
|
186 |
} |
|
187 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
188 |
YansWifiPhyHelper |
3912 | 189 |
YansWifiPhyHelper::Default (void) |
190 |
{ |
|
191 |
YansWifiPhyHelper helper; |
|
6459
d5cfe99001f0
Change default OFDM error rate model to NistErrorRateModel (issue 944)
Tom Henderson <tomh@tomh.org>
parents:
6313
diff
changeset
|
192 |
helper.SetErrorRateModel ("ns3::NistErrorRateModel"); |
3912 | 193 |
return helper; |
194 |
} |
|
195 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
196 |
void |
3912 | 197 |
YansWifiPhyHelper::SetChannel (Ptr<YansWifiChannel> channel) |
198 |
{ |
|
199 |
m_channel = channel; |
|
200 |
} |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
201 |
void |
4140
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
4058
diff
changeset
|
202 |
YansWifiPhyHelper::SetChannel (std::string channelName) |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
4058
diff
changeset
|
203 |
{ |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
4058
diff
changeset
|
204 |
Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel> (channelName); |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
4058
diff
changeset
|
205 |
m_channel = channel; |
6bbf05bf4826
Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents:
4058
diff
changeset
|
206 |
} |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
207 |
void |
3912 | 208 |
YansWifiPhyHelper::Set (std::string name, const AttributeValue &v) |
209 |
{ |
|
210 |
m_phy.Set (name, v); |
|
211 |
} |
|
212 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
213 |
void |
3912 | 214 |
YansWifiPhyHelper::SetErrorRateModel (std::string name, |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
215 |
std::string n0, const AttributeValue &v0, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
216 |
std::string n1, const AttributeValue &v1, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
217 |
std::string n2, const AttributeValue &v2, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
218 |
std::string n3, const AttributeValue &v3, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
219 |
std::string n4, const AttributeValue &v4, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
220 |
std::string n5, const AttributeValue &v5, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
221 |
std::string n6, const AttributeValue &v6, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
222 |
std::string n7, const AttributeValue &v7) |
3912 | 223 |
{ |
224 |
m_errorRateModel = ObjectFactory (); |
|
225 |
m_errorRateModel.SetTypeId (name); |
|
226 |
m_errorRateModel.Set (n0, v0); |
|
227 |
m_errorRateModel.Set (n1, v1); |
|
228 |
m_errorRateModel.Set (n2, v2); |
|
229 |
m_errorRateModel.Set (n3, v3); |
|
230 |
m_errorRateModel.Set (n4, v4); |
|
231 |
m_errorRateModel.Set (n5, v5); |
|
232 |
m_errorRateModel.Set (n6, v6); |
|
233 |
m_errorRateModel.Set (n7, v7); |
|
234 |
} |
|
235 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
236 |
Ptr<WifiPhy> |
3912 | 237 |
YansWifiPhyHelper::Create (Ptr<Node> node, Ptr<WifiNetDevice> device) const |
238 |
{ |
|
239 |
Ptr<YansWifiPhy> phy = m_phy.Create<YansWifiPhy> (); |
|
240 |
Ptr<ErrorRateModel> error = m_errorRateModel.Create<ErrorRateModel> (); |
|
241 |
phy->SetErrorRateModel (error); |
|
242 |
phy->SetChannel (m_channel); |
|
243 |
phy->SetMobility (node); |
|
244 |
phy->SetDevice (device); |
|
245 |
return phy; |
|
246 |
} |
|
247 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
248 |
static void |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
249 |
PcapSniffTxEvent ( |
6052
e146b9c9c7e7
PcapFileObject to PcapFileWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents:
6049
diff
changeset
|
250 |
Ptr<PcapFileWrapper> file, |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
251 |
Ptr<const Packet> packet, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
252 |
uint16_t channelFreqMhz, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
253 |
uint16_t channelNumber, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
254 |
uint32_t rate, |
10139 | 255 |
bool isShortPreamble, |
256 |
uint8_t txPower) |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
257 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
258 |
uint32_t dlt = file->GetDataLinkType (); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
259 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
260 |
switch (dlt) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
261 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
262 |
case PcapHelper::DLT_IEEE802_11: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
263 |
file->Write (Simulator::Now (), packet); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
264 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
265 |
case PcapHelper::DLT_PRISM_HEADER: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
266 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
267 |
NS_FATAL_ERROR ("PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented"); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
268 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
269 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
270 |
case PcapHelper::DLT_IEEE802_11_RADIO: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
271 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
272 |
Ptr<Packet> p = packet->Copy (); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
273 |
RadiotapHeader header; |
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
274 |
uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
275 |
header.SetTsft (Simulator::Now ().GetMicroSeconds ()); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
276 |
|
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
277 |
// Our capture includes the FCS, so we set the flag to say so. |
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
278 |
frameFlags |= RadiotapHeader::FRAME_FLAG_FCS_INCLUDED; |
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
279 |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
280 |
if (isShortPreamble) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
281 |
{ |
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
282 |
frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
283 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
284 |
|
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
285 |
header.SetFrameFlags (frameFlags); |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
286 |
header.SetRate (rate); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
287 |
|
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
288 |
uint16_t channelFlags = 0; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
289 |
switch (rate) |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
290 |
{ |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
291 |
case 2: // 1Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
292 |
case 4: // 2Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
293 |
case 10: // 5Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
294 |
case 22: // 11Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
295 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK; |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
296 |
break; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
297 |
|
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
298 |
default: |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
299 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
300 |
break; |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
301 |
} |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
302 |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
303 |
if (channelFreqMhz < 2500) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
304 |
{ |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
305 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
306 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
307 |
else |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
308 |
{ |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
309 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
310 |
} |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
311 |
|
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
312 |
header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags); |
10139 | 313 |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
314 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
315 |
p->AddHeader (header); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
316 |
file->Write (Simulator::Now (), p); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
317 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
318 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
319 |
default: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
320 |
NS_ABORT_MSG ("PcapSniffTxEvent(): Unexpected data link type " << dlt); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
321 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
322 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
323 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
324 |
static void |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
325 |
PcapSniffRxEvent ( |
6052
e146b9c9c7e7
PcapFileObject to PcapFileWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents:
6049
diff
changeset
|
326 |
Ptr<PcapFileWrapper> file, |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
327 |
Ptr<const Packet> packet, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
328 |
uint16_t channelFreqMhz, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
329 |
uint16_t channelNumber, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
330 |
uint32_t rate, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
331 |
bool isShortPreamble, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
332 |
double signalDbm, |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
333 |
double noiseDbm) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
334 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
335 |
uint32_t dlt = file->GetDataLinkType (); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
336 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
337 |
switch (dlt) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
338 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
339 |
case PcapHelper::DLT_IEEE802_11: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
340 |
file->Write (Simulator::Now (), packet); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
341 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
342 |
case PcapHelper::DLT_PRISM_HEADER: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
343 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
344 |
NS_FATAL_ERROR ("PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented"); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
345 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
346 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
347 |
case PcapHelper::DLT_IEEE802_11_RADIO: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
348 |
{ |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
349 |
Ptr<Packet> p = packet->Copy (); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
350 |
RadiotapHeader header; |
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
351 |
uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
352 |
header.SetTsft (Simulator::Now ().GetMicroSeconds ()); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
353 |
|
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
354 |
// Our capture includes the FCS, so we set the flag to say so. |
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
355 |
frameFlags |= RadiotapHeader::FRAME_FLAG_FCS_INCLUDED; |
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
356 |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
357 |
if (isShortPreamble) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
358 |
{ |
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
359 |
frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
360 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
361 |
|
6299
56ac87d0f2f9
Set FCS included flag in Radiotap header
Dean Armstrong <deanarm@gmail.com>
parents:
6206
diff
changeset
|
362 |
header.SetFrameFlags (frameFlags); |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
363 |
header.SetRate (rate); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
364 |
|
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
365 |
uint16_t channelFlags = 0; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
366 |
switch (rate) |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
367 |
{ |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
368 |
case 2: // 1Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
369 |
case 4: // 2Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
370 |
case 10: // 5Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
371 |
case 22: // 11Mbps |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
372 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK; |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
373 |
break; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
374 |
|
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
375 |
default: |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
376 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM; |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
377 |
break; |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
378 |
} |
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
379 |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
380 |
if (channelFreqMhz < 2500) |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
381 |
{ |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
382 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
383 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
384 |
else |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
385 |
{ |
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
386 |
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ; |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
387 |
} |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
388 |
|
7012
67ca195ea166
fixed Bug 1066 - Set Radiotap modulation type flags correctly
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
389 |
header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags); |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
390 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
391 |
header.SetAntennaSignalPower (signalDbm); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
392 |
header.SetAntennaNoisePower (noiseDbm); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
393 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
394 |
p->AddHeader (header); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
395 |
file->Write (Simulator::Now (), p); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
396 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
397 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
398 |
default: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
399 |
NS_ABORT_MSG ("PcapSniffRxEvent(): Unexpected data link type " << dlt); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
400 |
} |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
401 |
} |
4492
3ebeb7bf3c15
added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents:
4264
diff
changeset
|
402 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
403 |
void |
6041 | 404 |
YansWifiPhyHelper::SetPcapDataLinkType (enum SupportedPcapDataLinkTypes dlt) |
4492
3ebeb7bf3c15
added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents:
4264
diff
changeset
|
405 |
{ |
6041 | 406 |
switch (dlt) |
3912 | 407 |
{ |
6041 | 408 |
case DLT_IEEE802_11: |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
409 |
m_pcapDlt = PcapHelper::DLT_IEEE802_11; |
3912 | 410 |
return; |
6041 | 411 |
case DLT_PRISM_HEADER: |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
412 |
m_pcapDlt = PcapHelper::DLT_PRISM_HEADER; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
413 |
return; |
6041 | 414 |
case DLT_IEEE802_11_RADIO: |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
415 |
m_pcapDlt = PcapHelper::DLT_IEEE802_11_RADIO; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
416 |
return; |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
417 |
default: |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
418 |
NS_ABORT_MSG ("YansWifiPhyHelper::SetPcapFormat(): Unexpected format"); |
3912 | 419 |
} |
420 |
} |
|
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
421 |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
422 |
void |
6091
ab0d5e641fd7
fix thinko in fix for explicit pcap names
Craig Dowell <craigdo@ee.washington.edu>
parents:
6085
diff
changeset
|
423 |
YansWifiPhyHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename) |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
424 |
{ |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
425 |
// |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
426 |
// All of the Pcap enable functions vector through here including the ones |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
427 |
// that are wandering through all of devices on perhaps all of the nodes in |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
428 |
// the system. We can only deal with devices of type WifiNetDevice. |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
429 |
// |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
430 |
Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> (); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
431 |
if (device == 0) |
3912 | 432 |
{ |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
433 |
NS_LOG_INFO ("YansWifiHelper::EnablePcapInternal(): Device " << &device << " not of type ns3::WifiNetDevice"); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
434 |
return; |
3912 | 435 |
} |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
436 |
|
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
437 |
Ptr<WifiPhy> phy = device->GetPhy (); |
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
438 |
NS_ABORT_MSG_IF (phy == 0, "YansWifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set"); |
3912 | 439 |
|
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
440 |
PcapHelper pcapHelper; |
6096
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
441 |
|
6085
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
442 |
std::string filename; |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
443 |
if (explicitFilename) |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
444 |
{ |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
445 |
filename = prefix; |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
446 |
} |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
447 |
else |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
448 |
{ |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
449 |
filename = pcapHelper.GetFilenameFromDevice (prefix, device); |
94b282f335d2
allow explicit filenames in pcap trace files
Craig Dowell <craigdo@ee.washington.edu>
parents:
6053
diff
changeset
|
450 |
} |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
451 |
|
6206
9787dc9fdd84
bug 872: ns3::PcapFileWrapper::Write explodes stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
6096
diff
changeset
|
452 |
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, m_pcapDlt); |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
4715
diff
changeset
|
453 |
|
7334
21b6b53ba0d5
[Bug 827] Rename promisc trace to monitor in WifiPhy
Ruben Merz <ruben@net.t-labs.tu-berlin.de>
parents:
7141
diff
changeset
|
454 |
phy->TraceConnectWithoutContext ("MonitorSnifferTx", MakeBoundCallback (&PcapSniffTxEvent, file)); |
21b6b53ba0d5
[Bug 827] Rename promisc trace to monitor in WifiPhy
Ruben Merz <ruben@net.t-labs.tu-berlin.de>
parents:
7141
diff
changeset
|
455 |
phy->TraceConnectWithoutContext ("MonitorSnifferRx", MakeBoundCallback (&PcapSniffRxEvent, file)); |
3912 | 456 |
} |
457 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
458 |
void |
6096
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
459 |
YansWifiPhyHelper::EnableAsciiInternal ( |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
460 |
Ptr<OutputStreamWrapper> stream, |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
461 |
std::string prefix, |
6096
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
462 |
Ptr<NetDevice> nd, |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
463 |
bool explicitFilename) |
3912 | 464 |
{ |
6013 | 465 |
// |
466 |
// All of the ascii enable functions vector through here including the ones |
|
467 |
// that are wandering through all of devices on perhaps all of the nodes in |
|
7464 | 468 |
// the system. We can only deal with devices of type WifiNetDevice. |
6013 | 469 |
// |
470 |
Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> (); |
|
471 |
if (device == 0) |
|
472 |
{ |
|
473 |
NS_LOG_INFO ("YansWifiHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::WifiNetDevice"); |
|
474 |
return; |
|
475 |
} |
|
476 |
||
477 |
// |
|
478 |
// Our trace sinks are going to use packet printing, so we have to make sure |
|
479 |
// that is turned on. |
|
480 |
// |
|
3912 | 481 |
Packet::EnablePrinting (); |
6013 | 482 |
|
483 |
uint32_t nodeid = nd->GetNode ()->GetId (); |
|
484 |
uint32_t deviceid = nd->GetIfIndex (); |
|
3912 | 485 |
std::ostringstream oss; |
6013 | 486 |
|
487 |
// |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
488 |
// If we are not provided an OutputStreamWrapper, we are expected to create |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
489 |
// one using the usual trace filename conventions and write our traces |
6013 | 490 |
// without a context since there will be one file per context and therefore |
491 |
// the context would be redundant. |
|
492 |
// |
|
493 |
if (stream == 0) |
|
494 |
{ |
|
495 |
// |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
496 |
// Set up an output stream object to deal with private ofstream copy |
6013 | 497 |
// constructor and lifetime issues. Let the helper decide the actual |
498 |
// name of the file given the prefix. |
|
499 |
// |
|
500 |
AsciiTraceHelper asciiTraceHelper; |
|
6096
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
501 |
|
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
502 |
std::string filename; |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
503 |
if (explicitFilename) |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
504 |
{ |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
505 |
filename = prefix; |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
506 |
} |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
507 |
else |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
508 |
{ |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
509 |
filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device); |
96deefc231fa
plumb explicitFilename everywhere and update manual and tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
6091
diff
changeset
|
510 |
} |
6013 | 511 |
|
6313 | 512 |
Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename); |
6013 | 513 |
// |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
514 |
// We could go poking through the phy and the state looking for the |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
515 |
// correct trace source, but we can let Config deal with that with |
6013 | 516 |
// some search cost. Since this is presumably happening at topology |
517 |
// creation time, it doesn't seem much of a price to pay. |
|
518 |
// |
|
519 |
oss.str (""); |
|
520 |
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; |
|
6313 | 521 |
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&AsciiPhyReceiveSinkWithoutContext, theStream)); |
6013 | 522 |
|
523 |
oss.str (""); |
|
524 |
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; |
|
6313 | 525 |
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&AsciiPhyTransmitSinkWithoutContext, theStream)); |
6013 | 526 |
|
527 |
return; |
|
528 |
} |
|
529 |
||
530 |
// |
|
6053
b17ea72acee9
OutputStreamKeeper to OutputStreamWrapper
Craig Dowell <craigdo@ee.washington.edu>
parents:
6052
diff
changeset
|
531 |
// If we are provided an OutputStreamWrapper, we are expected to use it, and |
6013 | 532 |
// to provide a context. We are free to come up with our own context if we |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
7012
diff
changeset
|
533 |
// want, and use the AsciiTraceHelper Hook*WithContext functions, but for |
6013 | 534 |
// compatibility and simplicity, we just use Config::Connect and let it deal |
535 |
// with coming up with a context. |
|
536 |
// |
|
537 |
oss.str (""); |
|
3912 | 538 |
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk"; |
6013 | 539 |
Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyReceiveSinkWithContext, stream)); |
540 |
||
3912 | 541 |
oss.str (""); |
542 |
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx"; |
|
6013 | 543 |
Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyTransmitSinkWithContext, stream)); |
3912 | 544 |
} |
545 |
||
546 |
} // namespace ns3 |