This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3100 as Sniffer with Filters

Other Parts Discussed in Thread: CC3100

Hello,

I'm using the CC3100 as a sniffer with filters. My main goal is to send to the HOST MCU all the incoming Beacons from a certain SSID. I want to drop all the rest of the received packets.

I started with the example code - "sls_sniffer_with_filters" and saw that Payload filters is not supported yet.

I would like to ask the following questions:

(1) When do you expect that SSID filters will be supported?

(2) Until then, is there any way I can filter incoming packets according to values in certain offsets? (I might implement it manually). If yes, can you please send a code snippet.


Thanks,

Nir

  • Hi Nir,

    You can use the following method: first set the sniffer to pass only beacon frames, and find all the source MAC addresses of the beacon frames that have the desired SSID (there might be more than one). Note that the SSID information element is not located in the same offset inside every beacon. Then you can set the sniffer to pass only beacons that have one of the source MAC addresses from your list.

    Ofer.

  • Hey Ofer,

    Thanks for your fast reply.

    I ended up doing something similar to what you offered:

    (1) Set Sender's MAC address filter for the first 3 bytes (MSBs) with the relevant 3 bytes mask

    => '0' is the father filter

    => Rule.HeaderType.RuleHeaderfield = MAC_SRC_ADDRESS_FIELD

    => Action.ActionType.IntRepresentation = RX_FILTER_ACTION_NULL - to pass only the relevant ones

    (2) Set frame type filter that will drop every packet which is not Beacon (0x80)

    => The previous filter is the father filter

    => Rule.HeaderType.RuleHeaderfield = FRAME_TYPE_FILTER

    => Action.ActionType.IntRepresentation = RX_FILTER_ACTION_DROP

    Doing so, I still receive lots of unwanted packets...

    Do you have an idea how it could happen?

    I saw that filters no. 1-5 are occupied, is there any chance that I get packets that pass other decision trees?

    Thanks for your help,

    Nir

  • Hi Nir,

     You should define the following filters:

    1. Parent filter id is ‘0’
      1. RuleHeaderfield = MAC_SRC_ADDRESS_FIELD
      2. RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO
      3. RuleHeaderArgs = (desired MAC address)
      4. ActionType = RX_FILTER_ACTION_DROP
    2. Parent filter id is ‘0’
      1. RuleHeaderfield = FRAME_TYPE _FIELD
      2. RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO
      3. RuleHeaderArgs = MANAGEMENT frame type (reminder: 0-Management, 1-Control, 2-Data)
      4. ActionType = RX_FILTER_ACTION_DROP
    3. Parent filter id is ‘0’
      1. RuleHeaderfield = FRAME_TYPE_FIELD
      2. RuleCompareFunc = COMPARE_FUNC_EQUAL_TO
      3. RuleHeaderArgs = MANAGEMENT frame type (value: 0)
      4. ActionType = RX_FILTER_ACTION_NULL
    4. Parent filter id is ‘3’
      1. RuleHeaderfield = FRAME_SUBTYPE_FIELD
      2. RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO
      3. RuleHeaderArgs = BEACON frame sub-type (value: 0x80)
      4. ActionType = RX_FILTER_ACTION_DROP

     These filters will drop:

    -          Any frame with a different source MAC address than the desired one

    -          Any non-management frame

    -          Any management frame that is not a beacon

    Leaving only management beacon frames with the desired source MAC address to be passed to the host MCU.

    Ofer.

  • It works

    Thank you very much!

  • This actually solved another problem.  I was trying to filter all non-Beacon frames, exactly how you suggested, but I used Parent Filter ID of 0.  (It was my only filter)

    I changed to 3 per your example, and it works now.

    Why 3?  Why did 0 not work?

  • Hi Alex,

    For creating a filter based on "frame sub type" feild, it is also necessary to define the "frame type" field.

    Example it is not enough to define if (frameSubType== Beacon) you will have to define if ((frameType==Management) && (frameSubType== Beacon))

     

    Regards,

    Ankur

  • I'm still having issues.

    I can get non Management Frames dropped, using the first filter shown below, but when I try to add the next two filters, in order to drop non Beacon packets, I end up dropping ALL packets.  This setup is just how you described, what's going on?

    // this part always the same
    SlrxFilterID_t FilterId = 0;
    SlrxFilterRuleType_t RuleType = HEADER;
    SlrxFilterFlags_t FilterFlags;
    SlrxFilterRule_t Rule;
    SlrxFilterTrigger_t Trigger;
    SlrxFilterAction_t Action;
    SlrxFilterOperationResult_t RetVal;
    const int MANAGEMENT = 0;
    FilterFlags.IntRepresentation = RX_FILTER_BINARY;

    Trigger.ParentFilterID = 0;

    /* When RX_FILTER_COUNTER7 is bigger than 0 */
    Trigger.Trigger = NO_TRIGGER;

    /* connection state and role */
    Trigger.TriggerArgConnectionState.IntRepresentation = 0;
    Trigger.TriggerArgRoleStatus.IntRepresentation = RX_FILTER_ROLE_PROMISCUOUS;
    //end setup


    Rule.HeaderType.RuleHeaderfield = FRAME_TYPE_FIELD;
    Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgs.RxFilterDB1BytesRuleArgs[0][0] = MANAGEMENT;
    Rule.HeaderType.RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO;
    Action.ActionType.IntRepresentation = RX_FILTER_ACTION_DROP;

    RetVal = (SlrxFilterOperationResult_t)sl_WlanRxFilterAdd(
    RuleType,
    FilterFlags,
    &Rule,
    &Trigger,
    &Action,
    &FilterId);

    //Trigger.ParentFilterID = FilterID;
    Rule.HeaderType.RuleHeaderfield = FRAME_TYPE_FIELD;
    Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgs.RxFilterDB1BytesRuleArgs[0][0] = MANAGEMENT;
    Rule.HeaderType.RuleCompareFunc = COMPARE_FUNC_EQUAL;
    Action.ActionType.IntRepresentation = RX_FILTER_ACTION_NULL;

    RetVal = (SlrxFilterOperationResult_t)sl_WlanRxFilterAdd(
    RuleType,
    FilterFlags,
    &Rule,
    &Trigger,
    &Action,
    &FilterId);


    Trigger.ParentFilterID = FilterId;
    Rule.HeaderType.RuleHeaderfield = FRAME_SUBTYPE_FIELD;
    Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgs.RxFilterDB1BytesRuleArgs[0][0] = 0x80;
    Rule.HeaderType.RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO;
    Action.ActionType.IntRepresentation = RX_FILTER_ACTION_DROP;

    RetVal = (SlrxFilterOperationResult_t)sl_WlanRxFilterAdd(
    RuleType,
    FilterFlags,
    &Rule,
    &Trigger,
    &Action,
    &FilterId);

  • Hi,

    you also have to set the RuleHeaderArgsMask field in every one of the filters.

    please try adding:

    UINT8 FrameTypeMask = 0xFF;

    memcpy(Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgsMask,&FrameTypeMask, 1);

    Ofer.

  • That fixed it Ofer, thanks.

    For those of you following at home, I just added this:

        Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgsMask[0] = 0xFF;

    at the top of the function.  No need to set it for every filter, unless you need to change the mask to something longer, for say, a MAC filter.

    Alex