wriesharek同时监听多个端口

之前的文章《wireshark解析自定义的protobuf协议》 ,当时只监听了一个端口,而如果游戏同时有二个 socket 连接,比如一个是网关另外一个是其它的,怎么办呢?

for i,port in ipairs(tcp_port) do
        tcp_port_table:add(port, m_MeteoricProto)
 end

参考链接:https://wiki.wireshark.org/Lua/Examples#Using_Lua_to_register_protocols_to_more_ports

 

 

 

wiresharek 的过滤条件可以这样写:

(ip.dst == 192.168.xx.xx or ip.src == 192.168.xx.xx) && tcp.len > 0

这样显示的基本上就是自定义解析的 socket 消息了,关于过滤条件,更多详情可参考官网:

https://wiki.wireshark.org/DisplayFilters

 

第一个问题,监听多个端口,查官方文档没找到答案。

image

 

https://wiki.wireshark.org/LuaAPI/Dissector#dissectortable:add.28pattern.2C_dissector.29

追踪到源码也不是太理解

image

https://github.com/wireshark/wireshark/blob/master/epan/wslua/wslua_dissector.c

 

之后测试发现,下面二种方式也是可以的,一种表示范围,另一种表示多个端口,与用for循环的效果一样。

tcp_port_table:add("8002-8004", m_MeteoricProto)

tcp_port_table:add("8002,8003,8004", m_MeteoricProto)

posted @ 2017-11-07 21:00  meteoric_cry  阅读(635)  评论(0编辑  收藏  举报