本文整理汇总了C#中SharpPcap.LibPcap.CaptureFileReaderDevice类的典型用法代码示例。如果您正苦于以下问题:C# CaptureFileReaderDevice类的具体用法?C# CaptureFileReaderDevice怎么用?C# CaptureFileReaderDevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CaptureFileReaderDevice类属于SharpPcap.LibPcap命名空间,在下文中一共展示了CaptureFileReaderDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Constuctor_FromBeaconFrame
public void Test_Constuctor_FromBeaconFrame ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_beacon_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
BeaconFrame beaconFrame = (BeaconFrame)p.PayloadPacket;
List<InformationElement> infoElements = beaconFrame.InformationElements;
Assert.AreEqual (InformationElement.ElementId.ServiceSetIdentity, infoElements [0].Id);
Assert.AreEqual (InformationElement.ElementId.SupportedRates, infoElements [1].Id);
Assert.AreEqual (InformationElement.ElementId.DsParameterSet, infoElements [2].Id);
Assert.AreEqual (InformationElement.ElementId.TrafficIndicationMap, infoElements [3].Id);
Assert.AreEqual (InformationElement.ElementId.ErpInformation, infoElements [4].Id);
Assert.AreEqual (InformationElement.ElementId.ErpInformation2, infoElements [5].Id);
Assert.AreEqual (InformationElement.ElementId.RobustSecurityNetwork, infoElements [6].Id);
Assert.AreEqual (InformationElement.ElementId.ExtendedSupportedRates, infoElements [7].Id);
Assert.AreEqual (InformationElement.ElementId.HighThroughputCapabilities, infoElements [8].Id);
Assert.AreEqual (InformationElement.ElementId.HighThroughputInformation, infoElements [9].Id);
Assert.AreEqual (InformationElement.ElementId.VendorSpecific, infoElements [10].Id);
Assert.AreEqual (InformationElement.ElementId.VendorSpecific, infoElements [11].Id);
Assert.AreEqual (InformationElement.ElementId.VendorSpecific, infoElements [12].Id);
Assert.AreEqual (InformationElement.ElementId.VendorSpecific, infoElements [13].Id);
Assert.AreEqual (InformationElement.ElementId.VendorSpecific, infoElements [14].Id);
}
示例2: IPv6PacketTestParsing
public void IPv6PacketTestParsing()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/ipv6_icmpv6_packet.pcap");
dev.Open();
RawCapture rawCapture;
int packetIndex = 0;
while((rawCapture = dev.GetNextPacket()) != null)
{
var p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
Console.WriteLine("got packet");
switch(packetIndex)
{
case 0:
VerifyPacket0(p, rawCapture);
break;
default:
Assert.Fail("didn't expect to get to packetIndex " + packetIndex);
break;
}
packetIndex++;
}
dev.Close();
}
示例3: CookedCaptureTest
public void CookedCaptureTest()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/LinuxCookedCapture.pcap");
dev.Open();
RawCapture rawCapture;
int packetIndex = 0;
while((rawCapture = dev.GetNextPacket()) != null)
{
Packet p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
switch(packetIndex)
{
case 0:
VerifyPacket0(p);
break;
case 1:
VerifyPacket1(p);
break;
case 2:
VerifyPacket2(p);
break;
default:
Assert.Fail("didn't expect to get to packetIndex " + packetIndex);
break;
}
packetIndex++;
}
dev.Close();
}
示例4: UDPData
public void UDPData()
{
RawCapture rawCapture;
UdpPacket u;
Packet p;
var dev = new CaptureFileReaderDevice("../../CaptureFiles/udp_dns_request_response.pcap");
dev.Open();
// check the first packet
rawCapture = dev.GetNextPacket();
p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
Assert.IsNotNull(p);
u = (UdpPacket)p.Extract(typeof(UdpPacket));
Assert.IsNotNull(u, "Expected a non-null UdpPacket");
Assert.AreEqual(41 - u.Header.Length,
u.PayloadData.Length, "UDPData.Length mismatch");
// check the second packet
rawCapture = dev.GetNextPacket();
p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
Assert.IsNotNull(p);
u = (UdpPacket)p.Extract(typeof(UdpPacket));
Assert.IsNotNull(u, "Expected u to be a UdpPacket");
Assert.AreEqual(356 - u.Header.Length,
u.PayloadData.Length, "UDPData.Length mismatch");
Console.WriteLine("u is {0}", u.ToString());
dev.Close();
}
示例5: Test_Constructor
public void Test_Constructor()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/80211_qos_null_data_frame.pcap");
dev.Open();
var rawCapture = dev.GetNextPacket();
dev.Close();
Packet p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
QosNullDataFrame frame = (QosNullDataFrame)p.PayloadPacket;
Assert.AreEqual(0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual(FrameControlField.FrameSubTypes.QosNullData, frame.FrameControl.SubType);
Assert.IsFalse(frame.FrameControl.ToDS);
Assert.IsTrue(frame.FrameControl.FromDS);
Assert.IsFalse(frame.FrameControl.MoreFragments);
Assert.IsFalse(frame.FrameControl.Retry);
Assert.IsFalse(frame.FrameControl.PowerManagement);
Assert.IsFalse(frame.FrameControl.MoreData);
Assert.IsFalse(frame.FrameControl.Wep);
Assert.IsFalse(frame.FrameControl.Order);
Assert.AreEqual(314, frame.Duration.Field);
Assert.AreEqual("78ACC00A5E0E", frame.DestinationAddress.ToString().ToUpper());
Assert.AreEqual("00223FC1F378", frame.BssId.ToString().ToUpper());
Assert.AreEqual("00223FC1F378", frame.SourceAddress.ToString().ToUpper());
Assert.AreEqual(0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual(2292, frame.SequenceControl.SequenceNumber);
Assert.AreEqual(0x00, frame.QosControl);
Assert.AreEqual(0xDBF2B119, frame.FrameCheckSequence);
Assert.AreEqual(26, frame.FrameSize);
}
示例6: Test_Constructor
public void Test_Constructor()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/80211_authentication_frame.pcap");
dev.Open();
var rawCapture = dev.GetNextPacket();
dev.Close();
Packet p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
AuthenticationFrame frame = (AuthenticationFrame)p.PayloadPacket;
Assert.AreEqual(0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual(FrameControlField.FrameSubTypes.ManagementAuthentication, frame.FrameControl.SubType);
Assert.IsFalse(frame.FrameControl.ToDS);
Assert.IsFalse(frame.FrameControl.FromDS);
Assert.IsFalse(frame.FrameControl.MoreFragments);
Assert.IsFalse(frame.FrameControl.Retry);
Assert.IsFalse(frame.FrameControl.PowerManagement);
Assert.IsFalse(frame.FrameControl.MoreData);
Assert.IsFalse(frame.FrameControl.Wep);
Assert.IsFalse(frame.FrameControl.Order);
Assert.AreEqual(248, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual("0024B2F8D706", frame.DestinationAddress.ToString().ToUpper());
Assert.AreEqual("00173FB72C29", frame.SourceAddress.ToString().ToUpper());
Assert.AreEqual("0024B2F8D706", frame.BssId.ToString().ToUpper());
Assert.AreEqual(0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual(1327, frame.SequenceControl.SequenceNumber);
Assert.AreEqual(0, frame.AuthenticationAlgorithmNumber);
Assert.AreEqual(1, frame.AuthenticationAlgorithmTransactionSequenceNumber);
Assert.AreEqual(AuthenticationStatusCode.Success, frame.StatusCode);
Assert.AreEqual(0x4AE3E90F, frame.FrameCheckSequence);
Assert.AreEqual(30, frame.FrameSize);
}
示例7: Test_Constructor_AddBlockAckResponseReport
public void Test_Constructor_AddBlockAckResponseReport ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_block_ack_response_action_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
ActionFrame frame = (ActionFrame)p.PayloadPacket;
Assert.AreEqual (0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual (FrameControlField.FrameSubTypes.ManagementAction, frame.FrameControl.SubType);
Assert.IsFalse (frame.FrameControl.ToDS);
Assert.IsFalse (frame.FrameControl.FromDS);
Assert.IsFalse (frame.FrameControl.MoreFragments);
Assert.IsFalse (frame.FrameControl.Retry);
Assert.IsFalse (frame.FrameControl.PowerManagement);
Assert.IsFalse (frame.FrameControl.MoreData);
Assert.IsFalse (frame.FrameControl.Wep);
Assert.IsFalse (frame.FrameControl.Order);
Assert.AreEqual (314, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual ("0024B2F8D706", frame.DestinationAddress.ToString ().ToUpper ());
Assert.AreEqual ("7CC5376D16E7", frame.SourceAddress.ToString ().ToUpper ());
Assert.AreEqual ("0024B2F8D706", frame.BssId.ToString ().ToUpper ());
Assert.AreEqual (0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual (3826, frame.SequenceControl.SequenceNumber);
Assert.AreEqual (0x6D3FCFA3, frame.FrameCheckSequence);
Assert.AreEqual (24, frame.FrameSize);
Assert.AreEqual (9, frame.PayloadData.Length);
}
示例8: Test_Constructor
public void Test_Constructor ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_disassociation_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
DisassociationFrame frame = (DisassociationFrame)p.PayloadPacket;
Assert.AreEqual (0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual (FrameControlField.FrameSubTypes.ManagementDisassociation, frame.FrameControl.SubType);
Assert.IsFalse (frame.FrameControl.ToDS);
Assert.IsFalse (frame.FrameControl.FromDS);
Assert.IsFalse (frame.FrameControl.MoreFragments);
Assert.IsFalse (frame.FrameControl.Retry);
Assert.IsFalse (frame.FrameControl.PowerManagement);
Assert.IsFalse (frame.FrameControl.MoreData);
Assert.IsFalse (frame.FrameControl.Wep);
Assert.IsFalse (frame.FrameControl.Order);
Assert.AreEqual (248, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual ("0024B2F8D706", frame.DestinationAddress.ToString ().ToUpper ());
Assert.AreEqual ("00173FB72C29", frame.SourceAddress.ToString ().ToUpper ());
Assert.AreEqual ("0024B2F8D706", frame.BssId.ToString ().ToUpper ());
Assert.AreEqual (0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual (1311, frame.SequenceControl.SequenceNumber);
Assert.AreEqual (ReasonCode.LeavingToRoam, frame.Reason);
Assert.AreEqual (0xB17572A4, frame.FrameCheckSequence);
Assert.AreEqual (26, frame.FrameSize);
}
示例9: Test_Constructor
public void Test_Constructor ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_null_data_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
NullDataFrame frame = (NullDataFrame)p.PayloadPacket;
Assert.AreEqual (0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual (FrameControlField.FrameSubTypes.DataNullFunctionNoData, frame.FrameControl.SubType);
Assert.IsTrue (frame.FrameControl.ToDS);
Assert.IsFalse (frame.FrameControl.FromDS);
Assert.IsFalse (frame.FrameControl.MoreFragments);
Assert.IsFalse (frame.FrameControl.Retry);
Assert.IsFalse (frame.FrameControl.PowerManagement);
Assert.IsFalse (frame.FrameControl.MoreData);
Assert.IsFalse (frame.FrameControl.Wep);
Assert.IsFalse (frame.FrameControl.Order);
Assert.AreEqual (314, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual ("001B2F02DC6C", frame.DestinationAddress.ToString ().ToUpper ());
Assert.AreEqual ("2477030C721C", frame.SourceAddress.ToString ().ToUpper ());
Assert.AreEqual ("001B2F02DC6C", frame.BssId.ToString ().ToUpper ());
Assert.AreEqual (0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual (1245, frame.SequenceControl.SequenceNumber);
Assert.AreEqual (0x8DAD458C, frame.FrameCheckSequence);
Assert.AreEqual (24, frame.FrameSize);
}
示例10: Test_Constructor
public void Test_Constructor ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_probe_request_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
ProbeRequestFrame frame = (ProbeRequestFrame)p.PayloadPacket;
Assert.AreEqual (0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual (FrameControlField.FrameSubTypes.ManagementProbeRequest, frame.FrameControl.SubType);
Assert.IsFalse (frame.FrameControl.ToDS);
Assert.IsFalse (frame.FrameControl.FromDS);
Assert.IsFalse (frame.FrameControl.MoreFragments);
Assert.IsFalse (frame.FrameControl.Retry);
Assert.IsFalse (frame.FrameControl.PowerManagement);
Assert.IsFalse (frame.FrameControl.MoreData);
Assert.IsFalse (frame.FrameControl.Wep);
Assert.IsFalse (frame.FrameControl.Order);
Assert.AreEqual (0, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual ("FFFFFFFFFFFF", frame.DestinationAddress.ToString ().ToUpper ());
Assert.AreEqual ("0020008AB749", frame.SourceAddress.ToString ().ToUpper ());
Assert.AreEqual ("FFFFFFFFFFFF", frame.BssId.ToString ().ToUpper ());
Assert.AreEqual (0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual (234, frame.SequenceControl.SequenceNumber);
Assert.AreEqual (0xD83CB03D, frame.FrameCheckSequence);
Assert.AreEqual (45, frame.FrameSize);
}
示例11: ParsingArpPacketRequestResponse
public void ParsingArpPacketRequestResponse()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/arp_request_response.pcap");
dev.Open();
RawCapture rawCapture;
int packetIndex = 0;
while((rawCapture = dev.GetNextPacket()) != null)
{
var p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
Console.WriteLine("got packet");
Console.WriteLine("{0}", p.ToString());
switch(packetIndex)
{
case 0:
VerifyPacket0(p);
break;
case 1:
VerifyPacket1(p);
break;
default:
Assert.Fail("didn't expect to get to packetIndex " + packetIndex);
break;
}
packetIndex++;
}
dev.Close();
}
示例12: Test_Constructor
public void Test_Constructor ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_block_acknowledgment_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
BlockAcknowledgmentFrame frame = (BlockAcknowledgmentFrame)p.PayloadPacket;
Assert.AreEqual (0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual (FrameControlField.FrameSubTypes.ControlBlockAcknowledgment, frame.FrameControl.SubType);
Assert.IsFalse (frame.FrameControl.ToDS);
Assert.IsFalse (frame.FrameControl.FromDS);
Assert.IsFalse (frame.FrameControl.MoreFragments);
Assert.IsFalse (frame.FrameControl.Retry);
Assert.IsFalse (frame.FrameControl.PowerManagement);
Assert.IsFalse (frame.FrameControl.MoreData);
Assert.IsFalse (frame.FrameControl.Wep);
Assert.IsFalse (frame.FrameControl.Order);
Assert.AreEqual (0, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual ("0024B2F8D706", frame.ReceiverAddress.ToString ().ToUpper ());
Assert.AreEqual ("7CC5376D16E7", frame.TransmitterAddress.ToString ().ToUpper ());
Assert.AreEqual (BlockAcknowledgmentControlField.AcknowledgementPolicy.Delayed, frame.BlockAcknowledgmentControl.Policy);
Assert.IsFalse (frame.BlockAcknowledgmentControl.MultiTid);
Assert.IsTrue (frame.BlockAcknowledgmentControl.CompressedBitmap);
Assert.AreEqual (0, frame.BlockAcknowledgmentControl.Tid);
Assert.AreEqual (0, frame.BlockAckStartingSequenceControl);
Assert.AreEqual (8, frame.BlockAckBitmap.Length);
Assert.AreEqual (0x9BB909C2, frame.FrameCheckSequence);
Assert.AreEqual (28, frame.FrameSize);
}
示例13: Test_Constructor_EncryptedDataFrame
public void Test_Constructor_EncryptedDataFrame()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/80211_encrypted_data_frame.pcap");
dev.Open();
var rawCapture = dev.GetNextPacket();
dev.Close();
Packet p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
DataDataFrame frame = (DataDataFrame)p.PayloadPacket;
Assert.AreEqual(0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual(FrameControlField.FrameSubTypes.Data, frame.FrameControl.SubType);
Assert.IsFalse(frame.FrameControl.ToDS);
Assert.IsTrue(frame.FrameControl.FromDS);
Assert.IsFalse(frame.FrameControl.MoreFragments);
Assert.IsFalse(frame.FrameControl.Retry);
Assert.IsFalse(frame.FrameControl.PowerManagement);
Assert.IsFalse(frame.FrameControl.MoreData);
Assert.IsTrue(frame.FrameControl.Wep);
Assert.IsFalse(frame.FrameControl.Order);
Assert.AreEqual(0, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual("33330000000C", frame.DestinationAddress.ToString().ToUpper());
Assert.AreEqual("00173FB72C29", frame.SourceAddress.ToString().ToUpper());
Assert.AreEqual("0024B2F8D706", frame.BssId.ToString().ToUpper());
Assert.AreEqual(0, frame.SequenceControl.FragmentNumber);
Assert.AreEqual(1561, frame.SequenceControl.SequenceNumber);
Assert.AreEqual(0xC77B6323, frame.FrameCheckSequence);
Assert.AreEqual(24, frame.FrameSize);
Assert.AreEqual(218, frame.PayloadData.Length);
}
示例14: ICMPv4Parsing
public void ICMPv4Parsing ()
{
var dev = new CaptureFileReaderDevice("../../CaptureFiles/ICMPv4.pcap");
dev.Open();
var rawCapture = dev.GetNextPacket();
dev.Close();
// Parse an icmp request
Packet p = Packet.ParsePacket(rawCapture.LinkLayerType, rawCapture.Data);
Assert.IsNotNull(p);
var icmp = ICMPv4Packet.GetEncapsulated(p);
Console.WriteLine(icmp.GetType());
Assert.AreEqual(ICMPv4TypeCodes.EchoRequest, icmp.TypeCode);
Assert.AreEqual(0xe05b, icmp.Checksum);
Assert.AreEqual(0x0200, icmp.ID);
Assert.AreEqual(0x6b00, icmp.Sequence);
// check that the message matches
string expectedString = "abcdefghijklmnopqrstuvwabcdefghi";
byte[] expectedData = System.Text.ASCIIEncoding.ASCII.GetBytes(expectedString);
Assert.AreEqual(expectedData, icmp.Data);
}
示例15: Test_Constructor
public void Test_Constructor ()
{
var dev = new CaptureFileReaderDevice ("../../CaptureFiles/80211_ack_frame.pcap");
dev.Open ();
var rawCapture = dev.GetNextPacket ();
dev.Close ();
Packet p = Packet.ParsePacket (rawCapture.LinkLayerType, rawCapture.Data);
AckFrame frame = (AckFrame)p.PayloadPacket;
Assert.AreEqual (0, frame.FrameControl.ProtocolVersion);
Assert.AreEqual (FrameControlField.FrameSubTypes.ControlACK, frame.FrameControl.SubType);
Assert.IsFalse (frame.FrameControl.ToDS);
Assert.IsFalse (frame.FrameControl.FromDS);
Assert.IsFalse (frame.FrameControl.MoreFragments);
Assert.IsFalse (frame.FrameControl.Retry);
Assert.IsFalse (frame.FrameControl.PowerManagement);
Assert.IsFalse (frame.FrameControl.MoreData);
Assert.IsFalse (frame.FrameControl.Wep);
Assert.IsFalse (frame.FrameControl.Order);
Assert.AreEqual (0, frame.Duration.Field); //this need expanding on in the future
Assert.AreEqual ("F8DB7F491342", frame.ReceiverAddress.ToString ().ToUpper ());
Assert.AreEqual (0xD2F5BE07, frame.FrameCheckSequence);
Assert.AreEqual (10, frame.FrameSize);
}