From cecf0fa7498d10a6f272ee9ef6c8f3b93ad18d82 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 27 Apr 2022 09:01:42 +0200 Subject: [PATCH] wifi: (fixes #639) Remove FCS before deserializing Wi-Fi frames --- src/wifi/helper/wifi-helper.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 6738cce56..7f5565774 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -37,6 +37,7 @@ #include "ns3/vht-configuration.h" #include "ns3/he-configuration.h" #include "ns3/obss-pd-algorithm.h" +#include "ns3/wifi-mac-trailer.h" #include "wifi-helper.h" namespace ns3 { @@ -62,7 +63,10 @@ AsciiPhyTransmitSinkWithContext ( uint8_t txLevel) { NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel); - *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << mode << " " << *p << std::endl; + auto pCopy = p->Copy (); + WifiMacTrailer fcs; + pCopy->RemoveTrailer (fcs); + *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << mode << " " << *pCopy << " " << fcs << std::endl; } /** @@ -82,7 +86,10 @@ AsciiPhyTransmitSinkWithoutContext ( uint8_t txLevel) { NS_LOG_FUNCTION (stream << p << mode << preamble << txLevel); - *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << mode << " " << *p << std::endl; + auto pCopy = p->Copy (); + WifiMacTrailer fcs; + pCopy->RemoveTrailer (fcs); + *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << mode << " " << *pCopy << " " << fcs << std::endl; } /** @@ -104,7 +111,10 @@ AsciiPhyReceiveSinkWithContext ( WifiPreamble preamble) { NS_LOG_FUNCTION (stream << context << p << snr << mode << preamble); - *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << mode << " " << context << " " << *p << std::endl; + auto pCopy = p->Copy (); + WifiMacTrailer fcs; + pCopy->RemoveTrailer (fcs); + *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << mode << " " << context << " " << *pCopy << " " << fcs << std::endl; } /** @@ -124,7 +134,10 @@ AsciiPhyReceiveSinkWithoutContext ( WifiPreamble preamble) { NS_LOG_FUNCTION (stream << p << snr << mode << preamble); - *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << mode << " " << *p << std::endl; + auto pCopy = p->Copy (); + WifiMacTrailer fcs; + pCopy->RemoveTrailer (fcs); + *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << mode << " " << *pCopy << " " << fcs << std::endl; } WifiPhyHelper::WifiPhyHelper () @@ -560,7 +573,7 @@ WifiPhyHelper::GetRadiotapHeader ( header.SetHeFields (data1, data2, data3, data4, data5, 0); } - + if (preamble == WIFI_PREAMBLE_HE_MU) { //TODO: fill in fields (everything is set to 0 so far)