Orbit > OTG > Function Specifications > Using LIBMAC

Use LIBMAC in OTR Program

Introduction to LIBMAC

Libmac is a user-space C library that brings the wireless driver application program interface (API) into user space allowing one to get or set values of driver parameters. This library supports operation for a variable number of parameters per call. Currently, the documentation of LIBMAC is created by Doxygen tool and can be found in

List of libmac function used by OTR program:

  • mac_get_ifinfo
  • mac_append_params
  • mac_recv

Some information about Libmac recv interface

  1. mac_append_params is the function to determine which parameters shouls be reported by the driver
  2. mac_recv is the "receive" function
  3. libmac does not use IP address at all

Gate with LIBMAC support

At both ends of the OTG-OTR connection, regular sockets are opened. However, at the receiving end, in addition to regular sockets, we could use mac_recv of Libmac which is also waiting to hear from the interface. Two copies of the incoming frame are made by the kernel for pcap, one of which is given to the application on top of the listening socket and the other to mac_recv. mac_recv, extracts the RSSI value using its regular magic and reports to OML.

To suppport this functionality for various Gate types, I defined LibmacRX class. LibmacRX is an encapsulation of all LIBMAC Related methods to retreiving MAC/PHY parameters. I defined three custom Gate classes which inherits the LibmacRX class.

The major purpose to use LibmacRX class is to call mac_recv function to extract some parameters supported by Libmac-customized driver. In order to do this:


  1. Get interface information by mac_get_ifinfo
  2. finding the wireless dev interface. either by pickInterfacebyName or pickInterfacebyIPAddr
  3. set "dst host" as libpcap filter
  4. determine whihc PHY/MAC parameters are needed and call mac_append_params

When packet is received.

  1. use mac_recv to fetch parameters one by one.

Rate Conversion

This is used only for Intel driver which does not do proper rate mapping from "signal field value" to actual rate value

short LibmacRX::rateMapping(unsigned short signal_bits)
  short val;
  switch (signal_bits){
    case 13:  val = 60; 
    case 15:  val = 90; 
    case 5:   val = 120; 
    case 7:   val = 180; 
    case 9:   val = 240; 
    case 11:  val = 360; 
    case 1:   val = 480; 
    case 3:   val = 540; 
  default:  val = (short)signal_bits; 
  //for 802.11b , no need to map (10,20,55,110)
  return val;

Last modified 14 years ago Last modified on Feb 27, 2006, 8:46:43 PM
Note: See TracWiki for help on using the wiki.