{"action":"created","issue":{"url":"https://api.github.com/repos/IGRSoft/KisMac2/issues/56","labels_url":"https://api.github.com/repos/IGRSoft/KisMac2/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/IGRSoft/KisMac2/issues/56/comments","events_url":"https://api.github.com/repos/IGRSoft/KisMac2/issues/56/events","html_url":"https://github.com/IGRSoft/KisMac2/issues/56","id":99325438,"number":56,"title":"Frame Check Sequence is ignored","user":{"login":"orinem","id":11839044,"avatar_url":"https://avatars.githubusercontent.com/u/11839044?v=3","gravatar_id":"","url":"https://api.github.com/users/orinem","html_url":"https://github.com/orinem","followers_url":"https://api.github.com/users/orinem/followers","following_url":"https://api.github.com/users/orinem/following{/other_user}","gists_url":"https://api.github.com/users/orinem/gists{/gist_id}","starred_url":"https://api.github.com/users/orinem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orinem/subscriptions","organizations_url":"https://api.github.com/users/orinem/orgs","repos_url":"https://api.github.com/users/orinem/repos","events_url":"https://api.github.com/users/orinem/events{/privacy}","received_events_url":"https://api.github.com/users/orinem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-06T00:07:42Z","updated_at":"2015-08-08T00:29:33Z","closed_at":null,"body":"I get an awful lot of corrupt packets - about 100 per second here.  I verified this by capturing with Wireshark independently.\r\n\r\nUnfortunately, the Frame Check Sequence is currently ignored and bad packets get parsed.  This results in random messages from the packet parsing, many \"Packet with illegal 802.11 version captured\" messages for example.\r\n\r\nDepending on what is corrupted in any given packet, you can see bad SSIDs in the networks list, non-existent clients in the details list and so on.\r\n\r\nThe ability to check the FCS partially exists in FCS.h and FCS.m, though the parameter types and table should be changed to uint32_t (sizeof(long) may well be 8 these days).\r\n\r\nIn addition, WaveDriverAirportExtreme at least is not including the FCS bytes in frames returned from nextFrame.  I have not looked at any of the other drivers.\r\n\r\nHere is very basic code to do the FCS check.  It will need fixing to handle any drivers that do not supply the FCS bytes, possibly by adding an FCS present flag to KCtrlFrame.  It would also be possible for the drivers themselves to do the check.\r\n\r\nWavePacket.mm\r\nNote the 80211 version check is moved after the FCS check.\r\n```\r\n// At global scope\r\nstatic uint32_t checksumErrors = 0;\r\n//...\r\n    // Set frame pointer and length\r\n    _length = f->ctrl.len;\r\n    _frame = (UInt8*)(f->data);\r\n    \r\n    uint32_t crcReceived;\r\n    memcpy(&crcReceived, &_frame[_length-4], 4);\r\n    uint32_t crc = 0xFFFFFFFF;\r\n    // This loop is _very_ inefficient; move it into a function and put UDPC32 implementation inline.\r\n    for ( int i = 0; i < _length-4; ++i )\r\n    {\r\n        crc = UPDC32(_frame[i], crc);\r\n    }\r\n    crc ^= 0xFFFFFFFF;\r\n    \r\n    if ( crc != crcReceived ) {\r\n        if ( ++checksumErrors % 1000 == 0 )\r\n            DBNSLog(@\"%u packets with bad checksum (this packet: 0x%08X received, 0x%08X calculated).\\n\", checksumErrors, crcReceived, crc);\r\n            \r\n        return NO;\r\n    }\r\n    \r\n    // Check IEEE80211 Version\r\n    if ((hdr1->frame_ctl & IEEE80211_VERSION_MASK) != IEEE80211_VERSION_0) {\r\n        DBNSLog(@\"Packet with illegal 802.11 version captured (frame_ctl=0x%04X).\\n\", hdr1->frame_ctl);\r\n        return NO;\r\n    }\r\n    \r\n```\r\nWaveDriverAirportExtreme.m:\r\n```\r\n            case DLT_IEEE802_11_RADIO_AVS:\r\n                dataLen = header.caplen - sizeof(avs_80211_1_header);\r\n                //dataLen -= 4;       // Skip fcs?\r\n```"},"comment":{"url":"https://api.github.com/repos/IGRSoft/KisMac2/issues/comments/128868767","html_url":"https://github.com/IGRSoft/KisMac2/issues/56#issuecomment-128868767","issue_url":"https://api.github.com/repos/IGRSoft/KisMac2/issues/56","id":128868767,"user":{"login":"orinem","id":11839044,"avatar_url":"https://avatars.githubusercontent.com/u/11839044?v=3","gravatar_id":"","url":"https://api.github.com/users/orinem","html_url":"https://github.com/orinem","followers_url":"https://api.github.com/users/orinem/followers","following_url":"https://api.github.com/users/orinem/following{/other_user}","gists_url":"https://api.github.com/users/orinem/gists{/gist_id}","starred_url":"https://api.github.com/users/orinem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orinem/subscriptions","organizations_url":"https://api.github.com/users/orinem/orgs","repos_url":"https://api.github.com/users/orinem/repos","events_url":"https://api.github.com/users/orinem/events{/privacy}","received_events_url":"https://api.github.com/users/orinem/received_events","type":"User","site_admin":false},"created_at":"2015-08-08T00:29:33Z","updated_at":"2015-08-08T00:29:33Z","body":"I don't have skype at the moment... I'll drop you an email - rather not post the address, though it's not really a secret. "}}