如何过滤数据包 [英] how can I filter packets

查看:173
本文介绍了如何过滤数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RawCapture pack;

if (pack is TcpPacket)
  {
this.AllPackets.Rows.Add(packetCount.ToString(),len.ToString(), timestr,"tcp");
   }
else
 {
this.AllPackets.Rows.Add(packetCount.ToString(), len.ToString(), timestr,"other");
 }



我拥有它的结果,它总是其他".

警告1:从未提供给定的表达式类型("PacketDotNet.TcpPacket")



The result that I have it, it''s always "other".

Warning 1: The given expression is never provided the type (''PacketDotNet.TcpPacket'')

推荐答案

您的代码? "pack"从未设置为任何东西,因此将始终放入else块.如果是这样,为什么不输出pack.GetType()而不是"tcp"或"other",那么您就可以看到您正在得到什么.

(不知道该警告意味着什么).
Is there a bit missing from your code? ''pack'' is never set to anything so will always drop into the else block. If so, instead of "tcp" or "other", why don''t you output pack.GetType(), then you can see what you''re getting.

(no idea what that warning means btw).


关键字is在继承树中起作用.
我们知道packRawCapture类型.如果RawCapture是从基类TcpPacket派生的,或者将实现接口TcpPacket,则表达式pack is TcpPacket将返回true.我对接口的可能性表示怀疑,因为以大写字母I开头的接口是常见的.

从命名来看,我猜想TcpPacket可以从RawCapture派生,而不是相反.但是,只有PacketDotNet文档才能带来确定性.阅读并告诉我们RawCaptureTcpPacket之间的关系.
The keyword is works within inheritance trees.
We know that pack is of type RawCapture. The expression pack is TcpPacket would return true, if RawCapture was derived from a base class TcpPacket or would implement an interface TcpPacket. I doubt the interface possibility because it''s common to name interfaces starting with a capital I.

From the naming, I would guess that TcpPacket could be derived from RawCapture instead of the other way round. But only the PacketDotNet documentation can bring certainty. Read it and tell us the relationship between RawCapture and TcpPacket.


这篇关于如何过滤数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆