NSOC2011ClickMac: Difference between revisions
Line 11: | Line 11: | ||
YansWifiPhy (Creation of Radiotap Header) --> MacLow --> MacRxMiddle --> RegularWifiMac --> NetDevice | YansWifiPhy (Creation of Radiotap Header) --> MacLow --> MacRxMiddle --> RegularWifiMac --> NetDevice | ||
| | |||
WifiNetDevice (if in monitor mode, remove LLC header from packet, else just extract LLC information) <--- | |||
== Creation of Radiotap Header == | == Creation of Radiotap Header == |
Revision as of 04:08, 22 July 2011
Click-MAC Extensions for ns-3-click
- Student: Ashwin Narayan
- Mentors: Ruben Merz and Lalith Suresh
- Abstract: This project deals with the MAC extensions for ns-3 click. The current integration of the Click Modular Router with ns-3 is confined to only ns-3’s network device types and doesn’t yet permit the use of Click’s Wifi MAC specific elements. This project aims to enable the same, provide RadiotapHeader support for ns-3's Wifi model and a Monitor Wifi Mac interface to support a Monitor Mode within ns-3.
Mid-term report: [1]
RadiotapHeader support
A major step in the project would be the implementation of full radiotap headers support. The radiotap header cannot simply be added in YansWifiPhy as this would create issues with the current implementations of MacLow and MacRxMiddle. The current NS-3 Click integration is limited to L3 and leaves ns-3 to handle L2. The radiotap header would probably best be added on the receiver path as close to NetDevice as possible. The implementation would require a redesign in the method of packet forwarding with the radiotap pertinent data. The radiotap header could be created in YansWifiPhy and the necessary modifications must be made for sending the header upwards.
YansWifiPhy (Creation of Radiotap Header) --> MacLow --> MacRxMiddle --> RegularWifiMac --> NetDevice | WifiNetDevice (if in monitor mode, remove LLC header from packet, else just extract LLC information) <---
Creation of Radiotap Header
The Radiotap Header can be created in YansWifiPhy::EndReceive().
uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000; bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE; RadiotapHeader radiotaphdr; radiotaphdr.SetTsft (Simulator::Now ().GetMicroSeconds ()); Ptr<Packet> p = packet->Copy (); p->AddHeader (radiotaphdr); radiotaphdr.SetFrameFlags (frameFlags); radiotaphdr.SetRate (dataRate500KbpsUnits); if (GetChannelFrequencyMhz () < 2500) { radiotaphdr.SetChannelFrequencyAndFlags (GetChannelFrequencyMhz (), RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ | RadiotapHeader::CHANNEL_FLAG_CCK); } else { radiotaphdr.SetChannelFrequencyAndFlags (GetChannelFrequencyMhz (), RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ | RadiotapHeader::CHANNEL_FLAG_OFDM); } radiotaphdr.SetAntennaSignalPower (signalDbm); radiotaphdr.SetAntennaNoisePower (noiseDbm);
The necessary modifications must be made in MacLow and MacRxMiddle to send the RadiotapHeaders up the stack.
m_state->SwitchFromRxEndOk (packet, event->GetPayloadMode (), radiotaphdr);
The radiotap header can be added as arguments as shown above for MacLow::ReceiveOk(). I'm attempting to reduce the redundancy in using such a set of parameters. Since we're passing the radiotap header, I've eliminated the need for a variable storing SNR and the need for WifiPreamble. This information is available within the radiotap header content.
double rxSnr; enum WifiPreamble preamble; Ptr<YansWifiPhy> yanswifiphy = new YansWifiPhy (); double RxPowerW; RxPowerW = DbToRatio (radiotaphdr.GetAntennaSignalPower () - 30); rxSnr = RxPowerW / (DbToRatio (radiotaphdr.GetAntennaNoisePower () + yanswifiphy->GetRxNoiseFigure () - 30)); preamble = (radiotaphdr.GetFrameFlags () == 0x02) ? WIFI_PREAMBLE_SHORT:WIFI_PREAMBLE_LONG;
I'm also investigating to see if the removal of WifiMode is possible.
Due to these changes, the necessary modifications must be made in MacLow::ReceiveOk() accordingly along with the callbacks and then in MacRxMiddle::Receive() accordingly.
In MacLow::ReceiveOk(), the rxpacket segment of the code should be modified so that m_rxCallback (packet, &hdr) includes the Radiotap Header. The signature as well as the invocations of the callback must also be modified.
void MacLow::SetRxCallback (Callback<void,Ptr<Packet>,const WifiMacHeader *,const RadiotapHeader *> callback) { m_rxCallback = callback; }
The callback uses RadiotapHeader of type const RadiotapHeader * to save the expense of a copy.
PCAP Traces
Ptr<Packet> p = packet->Copy (); p->AddHeader (radiotaphdr);
The Radiotap Header can be added to the copy of the packet and then the following could be used:
NotifyPromiscSniffRx (p, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
Modifications for sending up the stack
While the Radiotap Header is created in MacLow, it must be sent up the stack till MacHigh where it can be added to the packet for Click use.
RegularWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr, const RadiotapHeader *radiotaphdr)
Accordingly, the callbacks and arguments have been modified to permit the same.
MonitorWifiMac
MonitorWifiMac can inherit directly from WifiMac and we could copy only the non-QoS part from RegularMacWifi. Thus, the MonitorWifiMac implementation doesn't need to know the type of station being implemented in the Click graph.
To test the reception of a Radiotap Header at Receive (), I attempted to remove the radiotap header. However, this resulted in premature termination while running the test programs (nsclick-simple-lan and nsclick-raw-wlan). The problem appears to be with RadiotapHeader::Deserialize () where an error occurs due the m_length and bytesRead being inconsistent. The LLC header at WifiNetDevice::Receive () needs to be preserved. For this purpose, I created a copy of the packet at Receive () and then removed the header with the LLC header from the copy. The LLC parameters necessary for the rest of Receive () can be used from this copy.
For Monitor Mode testing, a flag was created at WifiNetDevice::ForwardUp (), which when set (through WifiNetDevice::SetMonitorMode ()) would remove the LLC header from the packet. If not, the packet would simply travel up as it is. The packet reception was tested at MonitorWifiMac where at Receive (), the radiotap header being sent up the stack would be added to the packet. This packet would then be sent up the stack through ForwardUp ().
There is no need for a Monitor Mode flag in MacLow, unlike our initial assumptions. In MacLow::ReceiveOk, there's no need to do any bypassing for Monitor Mode. In MonitorWifiMac, the Monitor Mode functionality can be enabled using m_low->SetPromisc ().
Test script
A test script was developed for testing Monitor Mode. The grid would consist of several AdhocWifiMac nodes capable of talking to each other and a lone MonitorWifiMac node, which receives all these packets. The example is Click-based and prints the information about the received packets from within Click.
Transmission side
As far as TX part is concerned, there’s a need to use a tx-vector that allows per-packet tx parameters so as to allow for the transmission parameters obtained from the radiotap headers to be used for transmission. The implementation introduces per-packet tx parameters through WifiStationRemoteManager by adding the appropriate menthods for the different parameters and for Data, Rts, Cts, Ack.
There would be changes required in IPv4L3ClickRouting would be stripping off headers (the radiotap headers must be stripped as high in the stack as possible) to extract required information and pushing them using SendDown () where we can pass the required click information through netdev->Send (). I might need to strip off a WifiMacHeader at Ipv4L3ClickProtocol::SendDown () to extract Mac address information before sending out the packet through the NetDevice.
RadiotapHeader radiotaphdr; r->RemoveHeader(radiotaphdr); ... netdev->Send(p, radiotaphdr.GetInfo(), protocol);
As part of future work, following the click-mac integration, there’s the possible implementation of tx-queue feedback.
Deliverables
Considering the time period for the program, the following would be the list of deliverables:
- Implementation of full-radiotap header support
- Implementation a MonitorWifiMac abstraction
- Modification of tx-vector to support radiotap information
Plan
- May 23 - June 11 : Creation of radiotap headers in YansWifiPhy and testing the same
- June 12 - June 26 : Implementing MonitorWifiMac abstraction
- June 27 - July 1 : Testing
- July 1 - July 10 : Refactoring PCAP output: moving wifi PCAP sniff trace sources to MacLow,
- July 11 - July 15 : Mid-term code review + feedback
- July 16 - July 21 : Rest of the refactoring of the PCAP output
- July 22 - July 24 : Testing
- July 25 - August 7 : Adding Radiotap Information to the implementation of tx-vector
- August 8 - August 11 : Integration and testing
- August 12 - August 14 : Documentation
- August 15 - August 19 : End-term code review + feedback
Progress
- May 15 - May 22 : Revisions to original proposal before beginning of the Coding Phase
- May 23 - June 3 : Created Radiotap headers in YansWifiPhy and tested output using examples
- June 3 - June 10 : Creation of MonitorWifiMac (copy of non-QoS RegularWifiMac)
- June 10 - July 3 : MonitorWifiMac abstraction ready for rx
- July 4 - July 10 : Test script for Monitor Mode and further testing
- July 10 - Present : Mid-term review + feedback
Currently working on the Tx-vector aspect