LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2016 | 3 * Copyright (c) 2016 |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Sébastien Deronne <sebastien.deronne@gmail.com> | 18 * Author: Sébastien Deronne <sebastien.deronne@gmail.com> |
19 */ | 19 */ |
20 | 20 |
| 21 #include "ns3/packet.h" |
| 22 #include "ns3/nstime.h" |
21 #include "wifi-utils.h" | 23 #include "wifi-utils.h" |
| 24 #include "ctrl-headers.h" |
22 #include "wifi-mac-header.h" | 25 #include "wifi-mac-header.h" |
23 #include <cmath> | 26 #include "wifi-mac-trailer.h" |
| 27 #include "wifi-mode.h" |
24 | 28 |
25 namespace ns3 { | 29 namespace ns3 { |
26 | 30 |
27 double | 31 double |
28 Log2 (double val) | 32 Log2 (double val) |
29 { | 33 { |
30 return std::log (val) / std::log (2.0); | 34 return std::log (val) / std::log (2.0); |
31 } | 35 } |
32 | 36 |
33 | 37 |
(...skipping 16 matching lines...) Expand all Loading... |
50 { | 54 { |
51 return 10.0 * std::log10 (w * 1000.0); | 55 return 10.0 * std::log10 (w * 1000.0); |
52 } | 56 } |
53 | 57 |
54 double | 58 double |
55 RatioToDb (double ratio) | 59 RatioToDb (double ratio) |
56 { | 60 { |
57 return 10.0 * std::log10 (ratio); | 61 return 10.0 * std::log10 (ratio); |
58 } | 62 } |
59 | 63 |
| 64 bool |
| 65 Is2_4Ghz (double frequency) |
| 66 { |
| 67 if (frequency >= 2400 && frequency <= 2500) |
| 68 { |
| 69 return true; |
| 70 } |
| 71 return false; |
| 72 } |
| 73 |
| 74 bool |
| 75 Is5Ghz (double frequency) |
| 76 { |
| 77 if (frequency >= 5000 && frequency <= 6000) |
| 78 { |
| 79 return true; |
| 80 } |
| 81 return false; |
| 82 } |
| 83 |
60 uint16_t | 84 uint16_t |
61 ConvertGuardIntervalToNanoSeconds (WifiMode mode, bool htShortGuardInterval, Tim
e heGuardInterval) | 85 ConvertGuardIntervalToNanoSeconds (WifiMode mode, bool htShortGuardInterval, Tim
e heGuardInterval) |
62 { | 86 { |
63 uint16_t gi; | 87 uint16_t gi; |
64 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE) | 88 if (mode.GetModulationClass () == WIFI_MOD_CLASS_HE) |
65 { | 89 { |
66 gi = static_cast<uint16_t>(heGuardInterval.GetNanoSeconds ()); | 90 gi = static_cast<uint16_t> (heGuardInterval.GetNanoSeconds ()); |
67 } | 91 } |
68 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT || mode.GetModulation
Class () == WIFI_MOD_CLASS_VHT) | 92 else if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT || mode.GetModulation
Class () == WIFI_MOD_CLASS_VHT) |
69 { | 93 { |
70 gi = htShortGuardInterval ? 400 : 800; | 94 gi = htShortGuardInterval ? 400 : 800; |
71 } | 95 } |
72 else | 96 else |
73 { | 97 { |
74 gi = 800; | 98 gi = 800; |
75 } | 99 } |
76 return gi; | 100 return gi; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 cts.SetType (WIFI_MAC_CTL_CTS); | 145 cts.SetType (WIFI_MAC_CTL_CTS); |
122 return cts.GetSize () + 4; | 146 return cts.GetSize () + 4; |
123 } | 147 } |
124 | 148 |
125 bool | 149 bool |
126 IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize) | 150 IsInWindow (uint16_t seq, uint16_t winstart, uint16_t winsize) |
127 { | 151 { |
128 return ((seq - winstart + 4096) % 4096) < winsize; | 152 return ((seq - winstart + 4096) % 4096) < winsize; |
129 } | 153 } |
130 | 154 |
| 155 void |
| 156 AddWifiMacTrailer (Ptr<Packet> packet) |
| 157 { |
| 158 WifiMacTrailer fcs; |
| 159 packet->AddTrailer (fcs); |
| 160 } |
| 161 |
| 162 uint32_t |
| 163 GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr, bool isAmpdu) |
| 164 { |
| 165 uint32_t size; |
| 166 WifiMacTrailer fcs; |
| 167 if (isAmpdu) |
| 168 { |
| 169 size = packet->GetSize (); |
| 170 } |
| 171 else |
| 172 { |
| 173 size = packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); |
| 174 } |
| 175 return size; |
| 176 } |
| 177 |
131 } //namespace ns3 | 178 } //namespace ns3 |
LEFT | RIGHT |