SWRU368C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
As an illustration of how a RAW packet is built at the application level. The following demonstrates to build a PING packet encapsulated w/ ICMP, IP and MAC protocols.
FRAME CONTROL is set to 0x88, 0x02 because of below configuration:
RawPingPacket[] = {
/*---- 802.11 MAC Header -----*/
0x88,
0x02,
0x2C, 0x00,
0x00, 0x23, 0x75, 0x55,0x55, 0x55,
0x00, 0x22, 0x75, 0x55,0x55, 0x55,
0x00, 0x22, 0x75, 0x55,0x55, 0x55,
0x80, 0x42, 0x00, 0x00,
/*---- LLC & SNAP Header -----*/
0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
/*---- IP Header -----*/
0x45, 0x00, 0x00, 0x54, 0x96, 0xA1, 0x00, 0x00, 0x40, 0x01,
0x57, 0xFA,
0xc0, 0xa8, 0x01, 0x64,
0xc0, 0xa8, 0x01, 0x65,
/*---- ICMP Header -----*/
0x08, 0x00, 0xA5, 0x51,
0x5E, 0x18, 0x00, 0x00,
/*---- Payload -----*/
0x41, 0x08, 0xBB, 0x8D, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
typedef struct {
UINT8 rate;
UINT8 channel;
INT8 rssi;
UINT8 padding;
UINT32 timestamp;
}
TransceiverRxOverHead_t;
void TransceiverModeRx (INT8 <channel_number>, INT32 <pkts_to_receive>) {
TransceiverRxOverHead_t *frameRadioHeader = NULL;
UINT8 buffer[BUFFER_SIZE] = {'\0'};
INT32 <socket_hanlde> = -1;
INT32 recievedBytes = 0;
<socket_hanlde>= sl_Socket(SL_AF_RF, SL_SOCK_RAW, <channel_number>);
while(<pkts_to_receive>--)
{
memset(&buffer[0], 0, sizeof(buffer));
recievedBytes = sl_Recv(<socket_hanlde>, buffer, BUFFER_SIZE, 0);
frameRadioHeader = (TransceiverRxOverHead_t *)buffer;
PRINT(" ===>>> Timestamp: %iuS, Signal Strength: %idB\n\r", frameRadioHeader->timestamp, frameRadioHeader->rssi);
PRINT(" ===>>> Destination MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n\r", buffer[12], buffer[13], buffer[14], buffer[15], buffer[16], buffer[17]);
PRINT(" ===>>> Source MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n\r", buffer[24], buffer[25], buffer[26], buffer[27], buffer[28], buffer[29]);
PRINT(" ===>>> Source IP Address: %d.%d.%d.%d\n\r", buffer[54], buffer[55], buffer[56], buffer[57]);
PRINT(" ===>>> Destination IP Address: %d.%d.%d.%d\n\r", buffer[58], buffer[59], buffer[60], buffer[61]);
}
sl_Close(<socket_handle>);