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) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
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 |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ns3/random-variable.h" | 29 #include "ns3/random-variable.h" |
30 #include "ns3/assert.h" | 30 #include "ns3/assert.h" |
31 #include "ns3/log.h" | 31 #include "ns3/log.h" |
32 #include "ns3/double.h" | 32 #include "ns3/double.h" |
33 #include "ns3/uinteger.h" | 33 #include "ns3/uinteger.h" |
34 #include "ns3/enum.h" | 34 #include "ns3/enum.h" |
35 #include "ns3/pointer.h" | 35 #include "ns3/pointer.h" |
36 #include "ns3/net-device.h" | 36 #include "ns3/net-device.h" |
37 #include "ns3/trace-source-accessor.h" | 37 #include "ns3/trace-source-accessor.h" |
38 #include "ns3/radiotap-header.h" | 38 #include "ns3/radiotap-header.h" |
| 39 #include "wifi-mac-header.h" |
39 #include <math.h> | 40 #include <math.h> |
40 | 41 |
41 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy"); | 42 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy"); |
42 | 43 |
43 namespace ns3 { | 44 namespace ns3 { |
44 | 45 |
45 NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy); | 46 NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy); |
46 | 47 |
47 TypeId | 48 TypeId |
48 YansWifiPhy::GetTypeId (void) | 49 YansWifiPhy::GetTypeId (void) |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" <<
packet->GetSize ()); | 784 ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" <<
packet->GetSize ()); |
784 if (m_random.GetValue () > snrPer.per) | 785 if (m_random.GetValue () > snrPer.per) |
785 { | 786 { |
786 NotifyRxEnd (packet); | 787 NotifyRxEnd (packet); |
787 uint32_t rate = event->GetPayloadMode ().GetDataRate () / 500000; | 788 uint32_t rate = event->GetPayloadMode ().GetDataRate () / 500000; |
788 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); | 789 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); |
789 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; | 790 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; |
790 double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNo
iseFigure () + 30; | 791 double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNo
iseFigure () + 30; |
791 uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE; | 792 uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE; |
792 Ptr<Packet> p = packet->Copy (); | 793 Ptr<Packet> p = packet->Copy (); |
793 RadiotapHeader header; | 794 WifiMacHeader wifimacheader; |
794 header.SetTsft (Simulator::Now ().GetMicroSeconds ()); | 795 p->RemoveHeader (wifimacheader); |
795 | 796 |
796 frameFlags |= RadiotapHeader::FRAME_FLAG_FCS_INCLUDED; | 797 // The real-time control frames for monitor devices shouldn't have radiota
p headers |
797 | 798 // Thus, we can check for data and mgt headers for this purpose |
798 if (isShortPreamble) | 799 |
799 { | 800 if (wifimacheader.IsData () || wifimacheader.IsMgt ()) |
800 frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE; | 801 » { |
| 802 » RadiotapHeader header; |
| 803 header.SetTsft (Simulator::Now ().GetMicroSeconds ()); |
| 804 |
| 805 frameFlags |= RadiotapHeader::FRAME_FLAG_FCS_INCLUDED; |
| 806 |
| 807 if (isShortPreamble) |
| 808 { |
| 809 frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE; |
| 810 } |
| 811 |
| 812 header.SetFrameFlags (frameFlags); |
| 813 header.SetRate (rate); |
| 814 |
| 815 uint16_t channelFlags = 0; |
| 816 switch (rate) |
| 817 { |
| 818 case 2: // 1Mbps |
| 819 case 4: // 2Mbps |
| 820 case 10: // 5Mbps |
| 821 case 22: // 11Mbps |
| 822 channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK; |
| 823 break; |
| 824 |
| 825 default: |
| 826 channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM; |
| 827 break; |
| 828 } |
| 829 |
| 830 if (GetChannelFrequencyMhz () < 2500) |
| 831 { |
| 832 channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ; |
| 833 } |
| 834 else |
| 835 { |
| 836 channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ; |
| 837 } |
| 838 |
| 839 header.SetChannelFrequencyAndFlags (GetChannelFrequencyMhz (), channel
Flags); |
| 840 |
| 841 header.SetAntennaSignalPower (signalDbm); |
| 842 header.SetAntennaNoisePower (noiseDbm); |
| 843 |
| 844 p->AddHeader (header); |
| 845 |
| 846 NotifyMonitorSniffRx (p, (uint16_t)GetChannelFrequencyMhz (), GetChann
elNumber (), rate, isShortPreamble, signalDbm, noiseDbm); |
| 847 m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode
(), event->GetPreambleType (), header); |
801 } | 848 } |
802 | 849 } |
803 header.SetFrameFlags (frameFlags); | |
804 header.SetRate (rate); | |
805 | |
806 uint16_t channelFlags = 0; | |
807 switch (rate) | |
808 { | |
809 case 2: // 1Mbps | |
810 case 4: // 2Mbps | |
811 case 10: // 5Mbps | |
812 case 22: // 11Mbps | |
813 channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK; | |
814 break; | |
815 | |
816 default: | |
817 channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM; | |
818 break; | |
819 } | |
820 | |
821 if (GetChannelFrequencyMhz () < 2500) | |
822 { | |
823 channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ; | |
824 } | |
825 else | |
826 { | |
827 channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ; | |
828 } | |
829 | |
830 header.SetChannelFrequencyAndFlags (GetChannelFrequencyMhz (), channelFlag
s); | |
831 | |
832 header.SetAntennaSignalPower (signalDbm); | |
833 header.SetAntennaNoisePower (noiseDbm); | |
834 | |
835 p->AddHeader (header); | |
836 | |
837 NotifyMonitorSniffRx (p, (uint16_t)GetChannelFrequencyMhz (), GetChannelNu
mber (), rate, isShortPreamble, signalDbm, noiseDbm); | |
838 m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (),
event->GetPreambleType (), header); | |
839 } | |
840 else | 850 else |
841 { | 851 { |
842 /* failure. */ | 852 /* failure. */ |
843 NotifyRxDrop (packet); | 853 NotifyRxDrop (packet); |
844 m_state->SwitchFromRxEndError (packet, snrPer.snr); | 854 m_state->SwitchFromRxEndError (packet, snrPer.snr); |
845 } | 855 } |
846 } | 856 } |
847 } // namespace ns3 | 857 } // namespace ns3 |
LEFT | RIGHT |