View | Details | Raw Unified | Return to bug 2897
Collapse All | Expand All

(-)a/src/wifi/examples/wifi-trans-example.cc (-17 / +33 lines)
 Lines 31-38   using namespace ns3; Link Here 
31
/**
31
/**
32
 * This example (inspired from tv-trans-example) enables to generate the transmitted spectra of
32
 * This example (inspired from tv-trans-example) enables to generate the transmitted spectra of
33
 * Wi-Fi stations, so as to model transmit mask imperfections of OFDM-based Wi-Fi standards.
33
 * Wi-Fi stations, so as to model transmit mask imperfections of OFDM-based Wi-Fi standards.
34
 * Only the first moments of an association procedure of a station to an access point have been
34
 * Only one data packet is sent from access point to station (once association has been performed)
35
 * considered to reduce execution time.
35
 * so as to reduce execution time.
36
 *
36
 *
37
 * A spectrum analyzer is used to measure the transmitted spectra from Wi-Fi stations.
37
 * A spectrum analyzer is used to measure the transmitted spectra from Wi-Fi stations.
38
 * The file "spectrum-analyzer-wifi-[standard]-[bandwidth]MHz-sim-2-0.tr" contains its
38
 * The file "spectrum-analyzer-wifi-[standard]-[bandwidth]MHz-sim-2-0.tr" contains its
 Lines 41-46   using namespace ns3; Link Here 
41
 * The wifi-trans-example.sh script runs this example for all combinations, plots transmitted spectra,
41
 * The wifi-trans-example.sh script runs this example for all combinations, plots transmitted spectra,
42
 * and puts resulting png images in wifi-trans-results folder.
42
 * and puts resulting png images in wifi-trans-results folder.
43
 */
43
 */
44
45
void
46
SendPacket (Ptr<NetDevice> sourceDevice, Address& destination)
47
{
48
  Ptr<Packet> pkt = Create<Packet> (100);  // dummy bytes of data
49
  sourceDevice->Send (pkt, destination, 0);
50
}
51
44
int main (int argc, char** argv)
52
int main (int argc, char** argv)
45
{
53
{
46
  std::string standard = "11a";
54
  std::string standard = "11a";
 Lines 60-65   int main (int argc, char** argv) Link Here 
60
  Ssid ssid;
68
  Ssid ssid;
61
  std::string dataRate;
69
  std::string dataRate;
62
  int freq;
70
  int freq;
71
  Time dataStartTime = MicroSeconds (800); // leaving enough time for beacon and association procedure
72
  Time dataDuration = MicroSeconds (300); // leaving enough time for data transfer (+ acknowledgment)
63
  if (standard == "11a")
73
  if (standard == "11a")
64
    {
74
    {
65
      wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
75
      wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
 Lines 76-83   int main (int argc, char** argv) Link Here 
76
    {
86
    {
77
      wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
87
      wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
78
      ssid = Ssid ("ns380211_10MHZ");
88
      ssid = Ssid ("ns380211_10MHZ");
79
      dataRate = "OfdmRate6Mbps";
89
      dataRate = "OfdmRate3MbpsBW10MHz";
80
      freq = 5860;
90
      freq = 5860;
91
      dataStartTime = MicroSeconds (1400);
92
      dataDuration = MicroSeconds (600);
81
      if (bw != 10)
93
      if (bw != 10)
82
        {
94
        {
83
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
95
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 88-95   int main (int argc, char** argv) Link Here 
88
    {
100
    {
89
      wifi.SetStandard (WIFI_PHY_STANDARD_80211_5MHZ);
101
      wifi.SetStandard (WIFI_PHY_STANDARD_80211_5MHZ);
90
      ssid = Ssid ("ns380211_5MHZ");
102
      ssid = Ssid ("ns380211_5MHZ");
91
      dataRate = "OfdmRate6Mbps";
103
      dataRate = "OfdmRate1_5MbpsBW5MHz";
92
      freq = 5860;
104
      freq = 5860;
105
      dataStartTime = MicroSeconds (2500);
106
      dataDuration = MicroSeconds (1200);
93
      if (bw != 5)
107
      if (bw != 5)
94
        {
108
        {
95
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
109
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 102-107   int main (int argc, char** argv) Link Here 
102
      ssid = Ssid ("ns380211n_2_4GHZ");
116
      ssid = Ssid ("ns380211n_2_4GHZ");
103
      dataRate = "HtMcs0";
117
      dataRate = "HtMcs0";
104
      freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
118
      freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
119
      dataStartTime = MicroSeconds (4700);
120
      dataDuration = MicroSeconds (400);
105
      if (bw != 20 && bw != 40)
121
      if (bw != 20 && bw != 40)
106
        {
122
        {
107
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
123
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 114-119   int main (int argc, char** argv) Link Here 
114
      ssid = Ssid ("ns380211n_5GHZ");
130
      ssid = Ssid ("ns380211n_5GHZ");
115
      dataRate = "HtMcs0";
131
      dataRate = "HtMcs0";
116
      freq = 5170 + (bw / 2); //so as to have 5180/5190 for 20/40
132
      freq = 5170 + (bw / 2); //so as to have 5180/5190 for 20/40
133
      dataStartTime = MicroSeconds (1000);
117
      if (bw != 20 && bw != 40)
134
      if (bw != 20 && bw != 40)
118
        {
135
        {
119
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
136
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 126-131   int main (int argc, char** argv) Link Here 
126
      ssid = Ssid ("ns380211ac");
143
      ssid = Ssid ("ns380211ac");
127
      dataRate = "VhtMcs0";
144
      dataRate = "VhtMcs0";
128
      freq = 5170 + (bw / 2); //so as to have 5180/5190/5210/5250 for 20/40/80/160
145
      freq = 5170 + (bw / 2); //so as to have 5180/5190/5210/5250 for 20/40/80/160
146
      dataStartTime = MicroSeconds (1100);
147
      dataDuration += MicroSeconds (400); //account for ADDBA procedure
129
      if (bw != 20 && bw != 40 && bw != 80 && bw != 160)
148
      if (bw != 20 && bw != 40 && bw != 80 && bw != 160)
130
        {
149
        {
131
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
150
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 138-143   int main (int argc, char** argv) Link Here 
138
      ssid = Ssid ("ns380211ax_2_4GHZ");
157
      ssid = Ssid ("ns380211ax_2_4GHZ");
139
      dataRate = "HeMcs0";
158
      dataRate = "HeMcs0";
140
      freq = 2402 + (bw / 2); //so as to have 2412/2422/2442 for 20/40/80
159
      freq = 2402 + (bw / 2); //so as to have 2412/2422/2442 for 20/40/80
160
      dataStartTime = MicroSeconds (5500);
161
      dataDuration += MicroSeconds (2000); //account for ADDBA procedure
141
      if (bw != 20 && bw != 40 && bw != 80)
162
      if (bw != 20 && bw != 40 && bw != 80)
142
        {
163
        {
143
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
164
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 150-155   int main (int argc, char** argv) Link Here 
150
      ssid = Ssid ("ns380211ax_5GHZ");
171
      ssid = Ssid ("ns380211ax_5GHZ");
151
      dataRate = "HeMcs0";
172
      dataRate = "HeMcs0";
152
      freq = 5170 + (bw / 2); //so as to have 5180/5190/5210/5250 for 20/40/80/160
173
      freq = 5170 + (bw / 2); //so as to have 5180/5190/5210/5250 for 20/40/80/160
174
      dataStartTime = MicroSeconds (1200);
175
      dataDuration += MicroSeconds (500); //account for ADDBA procedure
153
      if (bw != 20 && bw != 40 && bw != 80 && bw != 160)
176
      if (bw != 20 && bw != 40 && bw != 80 && bw != 160)
154
        {
177
        {
155
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
178
          std::cout << "Bandwidth is not compatible with standard" << std::endl;
 Lines 164-173   int main (int argc, char** argv) Link Here 
164
187
165
  if (verbose)
188
  if (verbose)
166
    {
189
    {
190
      LogComponentEnableAll (LOG_PREFIX_ALL);
167
      LogComponentEnable ("WifiSpectrumValueHelper", LOG_LEVEL_ALL);
191
      LogComponentEnable ("WifiSpectrumValueHelper", LOG_LEVEL_ALL);
168
      LogComponentEnable ("WifiSpectrumValueHelper", LOG_PREFIX_ALL);
169
      LogComponentEnable ("SpectrumWifiPhy", LOG_LEVEL_ALL);
192
      LogComponentEnable ("SpectrumWifiPhy", LOG_LEVEL_ALL);
170
      LogComponentEnable ("SpectrumWifiPhy", LOG_PREFIX_ALL);
171
    }
193
    }
172
194
173
  /* nodes and positions */
195
  /* nodes and positions */
 Lines 214-220   int main (int argc, char** argv) Link Here 
214
               "EnableBeaconJitter", BooleanValue (false)); // so as to be sure that first beacon arrives quickly
236
               "EnableBeaconJitter", BooleanValue (false)); // so as to be sure that first beacon arrives quickly
215
  NetDeviceContainer apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
237
  NetDeviceContainer apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
216
238
217
218
  MobilityHelper mobility;
239
  MobilityHelper mobility;
219
  Ptr<ListPositionAllocator> nodePositionList = CreateObject<ListPositionAllocator> ();
240
  Ptr<ListPositionAllocator> nodePositionList = CreateObject<ListPositionAllocator> ();
220
  nodePositionList->Add (Vector (0.0, 1.0, 0.0)); // AP
241
  nodePositionList->Add (Vector (0.0, 1.0, 0.0)); // AP
 Lines 224-230   int main (int argc, char** argv) Link Here 
224
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
245
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
225
  mobility.Install (allNodes);
246
  mobility.Install (allNodes);
226
247
227
  /* No need to have Internet stack nor applications because beacon/association frames shall illustrate principle */
248
  /* Need to send data packet because beacon and association frames shall be sent using lowest rate */
249
  // Send one data packet (this packet is sent using data rate / MCS defined above) once association is done (otherwise dropped)
250
  Simulator::Schedule (dataStartTime, &SendPacket, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
228
251
229
  /* frequency range for spectrum analyzer */
252
  /* frequency range for spectrum analyzer */
230
  std::vector<double> freqs;
253
  std::vector<double> freqs;
 Lines 246-260   int main (int argc, char** argv) Link Here 
246
  spectrumAnalyzerHelper.EnableAsciiAll (ossFileName.str ());
269
  spectrumAnalyzerHelper.EnableAsciiAll (ossFileName.str ());
247
  NetDeviceContainer spectrumAnalyzerDevices = spectrumAnalyzerHelper.Install (spectrumAnalyzerNodes);
270
  NetDeviceContainer spectrumAnalyzerDevices = spectrumAnalyzerHelper.Install (spectrumAnalyzerNodes);
248
271
249
  /* Let enough time for beacon (even in 2.4 GHz, i.e. DSSS) and association procedure */
272
  /* Let enough time for first beacon, association procedure, and first data (+acknowledgment and eventually preceding ADDBA procedure) */
250
  if (freq > 5000)
273
  Simulator::Stop (dataStartTime + dataDuration);
251
    {
252
      Simulator::Stop (MicroSeconds (1500));
253
    }
254
  else
255
    {
256
      Simulator::Stop (MicroSeconds (2500)); //beacon in DSSS takes more time
257
    }
258
274
259
  Simulator::Run ();
275
  Simulator::Run ();
260
276

Return to bug 2897