wiki:OFDM/MIMO/Docs/AutoResponse

OFDM PHY Auto Response System

The OFDM core includes a subsystem which can automatically transmit a packet in response to a received packet. Automatically triggerd transmissions occur with very short and deterministic turnaround times.

This behavior is ideal for implementing MAC protocols which require responses at fast time scales (like RTS-CTS or DATA-ACK exchanges). Both the conditions for responding and contents of the response packet are programmable from software. While this system is implemented in FPGA fabric, its behavior is programmed entirely by C code. Think of it as a MAC "accelerator"- MAC behaviors are specified in code but executed by dedicated hardware resources in the PHY.

The auto response hardware consists of three parts- match units, actors and the header translator.

Match Units

The auto response match units search for user-specified patterns in received headers. Each unit operates independently. There are six match units in the current PHY.

Each match unit searches for a sequence of 1, 2 or 3 bytes starting at some offset in each received header. Multiple match units can be used together to search for longer sequences.

Actors

The actors are configured to trigger a transmission when a received packet meets programmed conditions. These conditions include any combination of match unit outputs, plus the Rx PHY status bits indicating the CRC status of received the received packet header and payload.

Important: user code must guarantee that the conditions applied to each actor are mutually exclusive. No more than one actor should be triggered by a single packet reception. This requirement is not enforced in hardware. Results will be unpredictable if multiple actors are triggered at once. Unused actors should be disabled.

Header Translator

The header translator is used to construct the header of an automatically transmitted packet using data from the header of the received packet which triggered the transmission. This allows auto-transmitted packets to use values from received headers without having to read them into the user code. A simple example is populatng the destination address of an auto-transmitted ACK with the source address of the received DATA packet.


Configuring the Auto Response System

C macros are provided in warphphy.h to help configure the match units, actors and header translator.

Match unit configuration:
Each match unit is configured with a single register write; each unit is acceseds with the macro mimo_ofdmTxRx_setMatchN(config), where N is in [0,5] and config is the value returned by the match unit config macro:

  • PHY_AUTORESPONSE_MATCH_CONFIG(addr, len, val): Configure the match unit to check whether len header bytes starting at addr match value val. There is an endian-swap between C-code and the PHY hardware. For 2 and 3 byte matches, the byte order must be swapped (with htons() for 2-byte and htonl() for 3-byte search values).

Actor configuration:
Each actor is configured with a single register write; each actor is accessed with the macro mimo_ofdmTxRx_setActionN(config), where N is in [0,5] and config is the value returned by one of these actor configuration macros:

  • PHY_AUTORESPONSE_TXACTION_CONFIG(pktBuf, options, delay, conditions): Configure the actor to automatically transmit:
    • pktBuf: index (in [1,31]) of the packet buffer from which to automatically transmit the packet
    • options: enable the header translator when this actor triggers a transmission (PHY_AUTORESPONSE_ACT_TRANS_HDR: use the translator; 0: disable the translator)
    • delay: number of 100ns increments to delay the automatic transmission. The time starts when the final byte of the incoming packet is decoded, even if the actor doesn't depend on the payload error status
    • conditions: bitwise OR'd combination of actor condition flags; every condition must be met by a given reception to trigger the actor.
  • PHY_AUTORESPONSE_ACTION_SETFLAGA_CONFIG(conditions): Configure the actor to set Flag A; conditions is a bitwise OR'd combination of actor condition requirements
  • PHY_AUTORESPONSE_ACTION_SETFLAGB_CONFIG(conditions): Configure the actor to set Flag B; conditions is a bitwise OR'd combination of actor condition requirements

Actor condition requirements:
The following values are used to specify the conditions for each actor. These values should be bitwise OR'd together to form the conditions field in the PHY_AUTORESPONSE_TXACTION_CONFIG macro.

  • PHY_AUTORESPONSE_REQ_GOODHDR: Packet currently being received is decoded without header errors
  • PHY_AUTORESPONSE_REQ_BADPKT: Packet currently being received has errors in payload but not header
  • PHY_AUTORESPONSE_REQ_GOODPKT: Packet currently being received is decoded without errors in header and payload
  • PHY_AUTORESPONSE_REQ_FLAGA: Flag A is set (set during previous reception)
  • PHY_AUTORESPONSE_REQ_FLAGB: Flag B is set (set during previous reception)
  • PHY_AUTORESPONSE_REQ_MATCH0: Match unit 0 conditions are met by the current packet header
  • PHY_AUTORESPONSE_REQ_MATCH1: Match unit 1 conditions are met by the current packet header
  • PHY_AUTORESPONSE_REQ_MATCH2: Match unit 2 conditions are met by the current packet header
  • PHY_AUTORESPONSE_REQ_MATCH3: Match unit 3 conditions are met by the current packet header
  • PHY_AUTORESPONSE_REQ_MATCH4: Match unit 4 conditions are met by the current packet header
  • PHY_AUTORESPONSE_REQ_MATCH5: Match unit 5 conditions are met by the current packet header

Actor options:
The following values are used to specify the options for each actor. These values should be bitwise OR'd together to form the options field in the {{PHY_AUTORESPONSE_TXACTION_CONFIG}} macro.

  • PHY_AUTORESPONSE_ACT_TRANS_HDR: Use the header translator for the auto-triggered transmission

Header translator:

  • PHY_HEADERTRANSLATE_SET(actionBuf, txByteNum, srcBuf, srcByteNum): Configure the translator to send the byte at index srcByteNum from the packet buffer srcBuf as byte number txByteNum for packets automatically transmitted from packet buffer actionBuf

Sample Code

The examples below illustrate how to use the OFDM PHY's auto response subsystem. These examples include only the auto responder configuration code. Please refer to the latest OFDM Reference Design for a full hardware-ready MAC/PHY example which uses this code.

The examples below assume each packet has a 24-byte header, using the format of phyHeader from warpphy.h. Specifically, the examples assume the header has fields:

unsigned short int srcAddr; //Source MAC address
unsigned short int destAddr;    //Destination MAC address
unsigned short int relAddr; //Relay MAC address
unsigned char pktType;      //Packet type

The examples assume some values are defined elsewhere in user code. These variables are used for convenience, and are borrowed from our full MAC implementations in the OFDM Reference Design.

  • PKTHEADER_INDX_TYPE: the byte index of the pktType field in the header
  • PKTHEADER_INDX_RELADDR: the byte index of the relAddr field in the header
  • PKTHEADER_INDX_SRCADDR: the byte index of the srcAddr field in the header
  • PKTHEADER_INDX_DSTADDR: the byte index of the dstAddr field in the header
  • ACKPACKET and DATAPACKET: (unsigned char) values specifying packet types
  • MY_ADDR: the (unsigned short int) value of the local node's MAC address
  • pktBuf_tx_ACK: the index (in [1,30]) of a PHY packet buffer used for transmitting ACKs
  • pktBuf_rx: the index (in [1,30]) of the PHY packet buffer where received packets are written
  • templatePkt: a struct of type Macframe (see PlatformSupport/WARPMAC/warpmac.h)

Automatic ACKs

This example configures the PHY to automatically transmit an ACK packet whenever a DATA packet is received whose destination address matches the local node's address. This is the usual behavior of protocols like Aloha and CSMA. Notice that all other MAC behaviors, like random backoffs and re-transmissions, are handled by the MAC implementation in C (not included here).

This example uses a temlate ACK packet (templatePkt), stored in a PHY packet buffer (pktBuf_tx_ACK). This template specifies header fields which are not read from the received packet header (i.e. header fields not overwritten by the header translator).

//Configure match unit 0 to search for packets addressed to me
// Looks for 2 bytes starting at index PKTHEADER_INDX_DSTADDR with value MY_ADDR
mimo_ofdmTxRx_setMatch0( PHY_AUTORESPONSE_MATCH_CONFIG(PKTHEADER_INDX_DSTADDR, 2, htons(MY_ADDR)) );

//Configure match unit 1 to search for DATA packets
// Looks for 1 byte starting at index PKTHEADER_INDX_TYPE with value DATAPACKET
mimo_ofdmTxRx_setMatch1( PHY_AUTORESPONSE_MATCH_CONFIG(PKTHEADER_INDX_TYPE, 1, DATAPACKET) );

//Configure the header translator to replace the outgoing destination address with the received source address
PHY_HEADERTRANSLATE_SET(pktBuf_tx_ACK, (PKTHEADER_INDX_DSTADDR+0), pktBuf_rx, (PKTHEADER_INDX_SRCADDR+0));
PHY_HEADERTRANSLATE_SET(pktBuf_tx_ACK, (PKTHEADER_INDX_DSTADDR+1), pktBuf_rx, (PKTHEADER_INDX_SRCADDR+1));

//Create a template ACK packet
templatePkt.header.fullRate = HDR_FULLRATE_QPSK;
templatePkt.header.length = 0;
templatePkt.header.srcAddr = MY_ADDR;
templatePkt.header.pktType = ACKPACKET;

//Copy the template ACK to the PHY packet buffer
warpmac_prepPhyForXmit(&templatePkt, pktBuf_tx_ACK);

//Configure actor 0 to send ACKs using the header translator after 5µs when the PHY receives a good data packet destined to this node
mimo_ofdmTxRx_setAction0(
    PHY_AUTORESPONSE_TXACTION_CONFIG(pktBuf_tx_ACK, PHY_AUTORESPONSE_ACT_TRANS_HDR, 20, 
        (PHY_AUTORESPONSE_REQ_MATCH0 | PHY_AUTORESPONSE_REQ_MATCH1 | PHY_AUTORESPONSE_REQ_GOODHDR | PHY_AUTORESPONSE_REQ_GOODPKT)));

//Disable the unused actors
mimo_ofdmTxRx_setAction1(0);
mimo_ofdmTxRx_setAction2(0);
mimo_ofdmTxRx_setAction3(0);
mimo_ofdmTxRx_setAction4(0);
mimo_ofdmTxRx_setAction5(0);



Simple Multi-hop

This example configures the PHY to automatically re-transmit received DATA packets, overwriting the source MAC address with the node's own address.

Note that the actor is configured to transmit from the same packet buffer where the PHY wrote the received packet. This eliminates the need for a template packet header, as the transmitted header will match the received header except where the header translator overwrites values.

//Configure match unit 0 to search for packets whose relay address matches this node's address
// Looks for 2 bytes starting at index PKTHEADER_INDX_RELADDR with value MY_ADDR
mimo_ofdmTxRx_setMatch0( PHY_AUTORESPONSE_MATCH_CONFIG(PKTHEADER_INDX_RELADDR, 2, htons(MY_ADDR)) );

//Configure match unit 1 to search for DATA packets
// Looks for 1 byte starting at index PKTHEADER_INDX_TYPE with value DATAPACKET
mimo_ofdmTxRx_setMatch1( PHY_AUTORESPONSE_MATCH_CONFIG(PKTHEADER_INDX_TYPE, 1, DATAPACKET) );

//Configure the header translator to replace the outgoing source address with the received relay address
PHY_HEADERTRANSLATE_SET(pktBuf_rx, (PKTHEADER_INDX_SRCADDR+0), pktBuf_rx, (PKTHEADER_INDX_RELADDR+0));
PHY_HEADERTRANSLATE_SET(pktBuf_rx, (PKTHEADER_INDX_SRCADDR+1), pktBuf_rx, (PKTHEADER_INDX_RELADDR+1));

//Configure actor 0 to transit the received packet using the header translator after 5µs when the PHY receives a good data packet using this node as a relay
mimo_ofdmTxRx_setAction0(
    PHY_AUTORESPONSE_TXACTION_CONFIG(pktBuf_rx, PHY_AUTORESPONSE_ACT_TRANS_HDR, 20, 
        (PHY_AUTORESPONSE_REQ_MATCH0 | PHY_AUTORESPONSE_REQ_MATCH1 | PHY_AUTORESPONSE_REQ_GOODHDR | PHY_AUTORESPONSE_REQ_GOODPKT)));

//Disable the unused actors
mimo_ofdmTxRx_setAction1(0);
mimo_ofdmTxRx_setAction2(0);
mimo_ofdmTxRx_setAction3(0);
mimo_ofdmTxRx_setAction4(0);
mimo_ofdmTxRx_setAction5(0);
Last modified 8 years ago Last modified on Dec 9, 2015, 10:15:37 PM