【发布时间】:2013-01-09 13:05:21
【问题描述】:
我正在使用 pcap.net 库在 C#.net 中开发通话录音应用程序。对于数据包捕获,我使用的是 Wireshark 的Dumpcap.exe。数据包文件在 5 秒内创建。要读取每个数据包文件,我所做的是
OfflinePacketDevice selectedDevice = new OfflinePacketDevice(filename);
using (PacketCommunicator communicator =
selectedDevice.Open(65536, // portion of the packet to capture
// 65536 guarantees that the whole packet will be captured on all the link layers
PacketDeviceOpenAttributes.Promiscuous, // promiscuous mode
0)) // read timeout
{
communicator.ReceivePackets(0, DispatcherHandler);
在 DispatcherHandler 方法中,我正在处理每个数据包。 DispatcherHandler 调用每个文件需要 0 秒。
我在以 same 方法处理 RTP 数据包数据包时出现延迟..
为了识别 rtp 数据包,我使用了 有序字典,键为 ipadrress+portnumber。所以我需要在每个rtp数据包到来时检查这个键是否存在于字典中。此任务在处理每个转储文件时变慢。
if (objPortIPDict.Contains(ip.Source.ToString().Replace(".", "") + port))
{
// here i write the rtp payload to a file
}
【问题讨论】: