aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremias Stotter <jeremias@stotter.eu>2024-01-03 23:30:37 +0100
committerJeremias Stotter <jeremias@stotter.eu>2024-01-03 23:30:37 +0100
commit682f4c115b788979ecca895f5cccba95ae0d9e48 (patch)
tree7a09016e77b77d3221bc28d14252b9c6e5d72975
parent79079e88825722096cf69c00fab8af04aca8b8f1 (diff)
downloadnetwork-simulator-682f4c115b788979ecca895f5cccba95ae0d9e48.tar.gz
network-simulator-682f4c115b788979ecca895f5cccba95ae0d9e48.tar.bz2
network-simulator-682f4c115b788979ecca895f5cccba95ae0d9e48.zip
Added flag analyzation to the tcp analyzerHEADmaster
-rw-r--r--templates/tcp/tcp.lua35
1 files changed, 34 insertions, 1 deletions
diff --git a/templates/tcp/tcp.lua b/templates/tcp/tcp.lua
index 350acff..34b080c 100644
--- a/templates/tcp/tcp.lua
+++ b/templates/tcp/tcp.lua
@@ -9,15 +9,48 @@
--
-- You should have received a copy of the GNU General Public License along with network-simulator. If not, see <https://www.gnu.org/licenses/>.
+-- Pass a single byte containing the flags
+function stringify_tcp_flags(flags_byte)
+ local flags_str = ""
+ -- FIN
+ if((flags_byte & 0x1) == 0x1) then
+ flags_str = flags_str.."FIN "
+ end
+ if((flags_byte & 0x2) == 0x2) then
+ flags_str = flags_str.."SYN "
+ end
+ if((flags_byte & 0x4) == 0x4) then
+ flags_str = flags_str.."RST "
+ end
+ if((flags_byte & 0x8) == 0x8) then
+ flags_str = flags_str.."PSH "
+ end
+ if((flags_byte & 0x10) == 0x10) then
+ flags_str = flags_str.."ACK "
+ end
+ if((flags_byte & 0x20) == 0x20) then
+ flags_str = flags_str.."URG "
+ end
+ if((flags_byte & 0x40) == 0x40) then
+ flags_str = flags_str.."ECE "
+ end
+ if((flags_byte & 0x80) == 0x80) then
+ flags_str = flags_str.."CWR"
+ end
+
+ return flags_str
+end
+
function tcp(data, width, frame_length)
s_port, d_port, seq, ack, dorsvflags, window, cksum, urg = string.unpack(">I2>I2>I4>I4>c2>I2>c2>I2", data)
local header_size = string.byte(dorsvflags) >> 4
+ local flags_str = stringify_tcp_flags(string.byte(dorsvflags, 2))
local return_table = {
{["width"] = 2, ["head"] = "Source Port", ["text"] = s_port},
{["width"] = 2, ["head"] = "Destination Port", ["text"] = d_port},
{["width"] = 4, ["head"] = "Sequence number", ["text"] = seq},
{["width"] = 4, ["head"] = "Acknowledgment number", ["text"] = ack},
- {["width"] = 2, ["head"] = "Width and Flags", ["text"] = bin_to_hex(dorsvflags).."\nSize: "..header_size.."("..(header_size*4).." bytes)"},
+ {["width"] = 2, ["head"] = "Width and Flags", ["text"] = "Size: "..header_size.." ("..(header_size*4).." bytes)".."\n"..flags_str},
{["width"] = 2, ["head"] = "Window size", ["text"] = window},
{["width"] = 2, ["head"] = "Checksum", ["text"] = bin_to_hex(cksum)},
{["width"] = 2, ["head"] = "Urgent pointer", ["text"] = urg}
Jeremias Stotters git repositories generated by CGIT