Professional Documents
Culture Documents
Download kcp_dissector.lua
---@ KCP Protocol dissector plugin
do
--[[
0 4 5 6 8 (BYTE)
+---------------+---+---+-------+
| conv |cmd|frg| wnd |
+---------------+---+---+-------+ 8
| ts | sn |
+---------------+---------------+ 16
| una | len |
+---------------+---------------+ 24
| |
| DATA (optional) |
| |
+-------------------------------+
--]]
KCP.fields = {
conv, cmd, frg, wnd,
ts, sn,
una, len,
data
}
local segment = 0
-- KCP dissect packet
function KCP.dissector (Buffer, Menu, T)
local TS = Buffer(offset, 4)
Tree:add_le(ts, TS)
Tree:append_text(", ts: " .. TS:le_uint())
offset = offset + 4
local SN = Buffer(offset, 4)
Tree:add_le(sn, SN)
Tree:append_text(", sn: " .. SN:le_uint())
offset = offset + 4
if CMD:le_uint() == 81 then
local info = "CMD_PUSH, SN(" .. SN:le_uint() .. ")"
if UNA:le_uint() > 0 then
info = info .. "WAIT_SN(" .. UNA:le_uint() .. ")"
end
Menu.cols.info = info
elseif CMD:le_uint() == 82 then
Menu.cols.info = "CMD_ACK, SN(" .. SN:le_uint() .. "), NEXT_SN(" .. UNA:le_uint() .. ")"
elseif CMD:le_uint() == 83 then
-- TODO
elseif CMD:le_uint() == 84 then
-- TODO
end
end
DissectorTable.get("udp.port"):add(PORT, KCP)
end