如何过滤数据包 [英] how can I filter packets
本文介绍了如何过滤数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
在继承树中起作用.
我们知道pack
是RawCapture
类型.如果RawCapture
是从基类TcpPacket
派生的,或者将实现接口TcpPacket
,则表达式pack is TcpPacket
将返回true.我对接口的可能性表示怀疑,因为以大写字母I开头的接口是常见的.
从命名来看,我猜想TcpPacket
可以从RawCapture
派生,而不是相反.但是,只有PacketDotNet文档才能带来确定性.阅读并告诉我们RawCapture
和TcpPacket
之间的关系.
The keywordis
works within inheritance trees.
We know thatpack
is of typeRawCapture
. The expressionpack is TcpPacket
would return true, ifRawCapture
was derived from a base classTcpPacket
or would implement an interfaceTcpPacket
. I doubt the interface possibility because it''s common to name interfaces starting with a capital I.
From the naming, I would guess thatTcpPacket
could be derived fromRawCapture
instead of the other way round. But only the PacketDotNet documentation can bring certainty. Read it and tell us the relationship betweenRawCapture
andTcpPacket
.
这篇关于如何过滤数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文