NSOC2011ClickMac: Difference between revisions
m (Remove manual links and replace them with wiki links) |
|||
Line 5: | Line 5: | ||
* 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. | * 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: [ | Mid-term report: [[NSOC2011ClickMac/MidTermReport]] | ||
== RadiotapHeader support == | == RadiotapHeader support == |
Latest revision as of 17:00, 10 February 2013
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: NSOC2011ClickMac/MidTermReport
RadiotapHeader support
A major step in the project would be the implementation of full radiotap headers support.
For the RX side, 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) <--
For the TX side, the radiotap information can be extracted from the packet and fed to the per-packet tx-vector parameters.
Creation of Radiotap Header
The Radiotap Header can be created in YansWifiPhy::EndReceive().
uint32_t rate = 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; Ptr<Packet> p = packet->Copy (); RadiotapHeader header; header.SetTsft (Simulator::Now ().GetMicroSeconds ()); frameFlags |= RadiotapHeader::FRAME_FLAG_FCS_INCLUDED; if (isShortPreamble) { frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE; } header.SetFrameFlags (frameFlags); header.SetRate (rate); uint16_t channelFlags = 0; switch (rate) { case 2: // 1Mbps case 4: // 2Mbps case 10: // 5Mbps case 22: // 11Mbps channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK; break; default: channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM; break; } if (GetChannelFrequencyMhz () < 2500) { channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ; } else { channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ; } header.SetChannelFrequencyAndFlags (GetChannelFrequencyMhz (), channelFlags); header.SetAntennaSignalPower (signalDbm); header.SetAntennaNoisePower (noiseDbm);
The necessary modifications must be made in MacLow and MacRxMiddle to send the RadiotapHeaders up the stack.
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType (), header);
The radiotap header can be added as arguments as shown above for MacLow::ReceiveOk(). 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);
YansWifiPhyHelper::PcapSniffRxEvent () has been modified to remove the redundancies in setting the radiotap parameters because of the above modifications in YansWifiPhy::EndReceive ().
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.
RX Side
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.
Changes were made in the existing radiotap header implementation to accommodate the TX parameters in the header. For monitor mode support, the changes required would be using a dummy address and protocol in the NetDevice->Send () arguments in Ipv4L3ClickRoutingProtocol::SendDown () and then modifications in MonitorWifiMac::Enqueue () that include the removal of the wifi-mac and radiotap headers. The radiotap information stripped would then be used to set the per-packet tx-vector parameters. The packet with the stripped headers is sent to the dca_queue.
MonitorWifiMac::SetTxParametersFromRadiotapHeader() sets the tx-vector relevant parameters in WifiRemoteStationManager before the packet is sent to the dca_queue. The per-packet nature of the tx-vector parameters is preserved owing to the implementation of the HighLatencyTxVectorTag in WifiRemoteStationManager.
Test Script
A click-based script was created for the purpose of testing the TX side of monitor mode support. For this, two nodes were used, one of AdhocWifiMac type and the other of MonitorWifiMac type. The latter has a single host Click configuration for wifi. The node broadcasts ARP requests if it wants to find a destination address and it responds to ARP requests made to it. A click script is used to set radiotap tx parameters (tx power, RTS and data retries).
Rate control was made possible by means of SetTXRate() and different transmission powers were assigned to alternative packets using the RoundRobinSwitch element and assigning two different tx power levels to alternative ARP packets.
- Note:
Since the test script above can be used for both RX and TX, this script would alone be sufficient to test the monitor mode support for ns-3's Wifi model.
Future Work
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
- Implementation 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
- June 10 - July 3 : MonitorWifiMac abstraction ready for rx
- July 4 - July 10 : Test script for RX Monitor Mode support
- July 10 - July 17 : Mid-term review + feedback
- July 18 - July 27 : Tx-vector implementation for radiotap header support
- July 27 - Aug 5 : Test script for TX Monitor Mode support
- Aug 6 - Aug 8 : Addition of comments
- Aug 9 - Aug 12 : Testing and fixing holes
- Aug 13 - Aug 14 : Cleaning up
- Aug 15 : Submitted code for review