Skip to main content
. 2022 Dec 4;22(23):9481. doi: 10.3390/s22239481
OODA loop algorithm as P4 source code.

state_input = state_read();

// Management frame
if (headers.frameCtrl.frameType == 0x0)
{
    if (headers.frameCtrl.subType == 0xB) state_output = state_update(AUTH);
    if (headers.frameCtrl.subType == 0x0) state_output = state_update(ASSOC);

    // De-authentication Frame
    if (headers.frameCtrl.subType == 0xC)
    {
      lookup_tbl.apply();
      // Deauthentication frame from a known device.
      if (ID_ok == 1) state_output = state_update(DEAUTH + VALID_ID);

      // Deauthentication frame from an unknown device.
      if (ID_ok == 0)
      {
        state_output = state_update(DEAUTH);
        Drop_action();
      }
    }

    // Disassociation Frame
    if (headers.frameCtrl.subType == 0xA)
    {
      lookup_tbl.apply();
      // Disassociation frame from a known device.
      if (ID_ok == 1) state_output = state_update(DISASSOC + VALID_ID);

      // Disassociation frame from an unknown device.
      if (ID_ok == 0)
      {
        state_output = state_update(DISASSOC);
        Drop_action();
      }
    }

    // Beacon Frame
    if (headers.frameCtrl.subType == 0x8)
    {
      ssid = ssid_check(headers);
      // Beacon frame with the same SSID but different BSSID, Evil Twin!!
      if (ssid == 1) state_output = state_update(BEACON);
      // Beacon frame with different SSID, another WAP in range - ignore.
      Pass_action();
    }
}

if (headers.frameCtrl.frameType == 0x1) // Control frame.
{
   Pass_action(); // Pass the frame.
}

if (headers.frameCtrl.frameType == 0x2 && state_input == 0x0) // Data frame.
{
   CPU_action();
   state_output = state_update(DATA);
}