.NET网络工具包 Packet.Net

fmms 13年前
     <p>Packet.Net 是一个.NET程序包,提供了剖析和构建网络数据包的功能。可以通过类的属性来调整各种数据包的参数。</p>    <p>示例代码:</p>    <pre class="brush:c#; toolbar: true; auto-links: false;">using PacketDotNet;  // open the capture file SharpPcap.LivePcapDevice dev = new SharpPcap.LivePcapDevice("SomeCapturedPackets.pcap");  // read a raw packet rawPacket = dev.GetNextRawPacket();  // parse the packet Packet p = Packet.ParsePacket((LinkLayers)rawPacket.LinkLayerType,                               new PosixTimeval(rawPacket.Timeval.Seconds,                                                rawPacket.Timeval.MicroSeconds),                               rawPacket.Data);  // print out the packet contents Console.WriteLine(p);</pre>    <p></p>    <p>输出信息:</p>    <pre>[EthernetPacket: 00234D5BF88B -> 00183F7775D1 proto=IpV4 (0x800)  l=14][IPv4Packet: 192.168.1.76 -> 72.14.204.83 HeaderLength=5  Protocol=TCP TimeToLive=64][TCPPacket:  SourcePort: 59038 ->   DestinationPort: 443 ack[218134930 (0xd007992)]]</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1325818283265" target="_blank">http://www.open-open.com/lib/view/home/1325818283265</a></p>