Exemplo n.º 1
0
        public static void Test_AnalyzeTcpStreamTest_ReadPcap_01(string file)
        {
            Trace.WriteLine("Test_AnalyzeTcpStreamTest_ReadPcap_01");
            Trace.WriteLine("pcap file \"{0}\"", file);
            Pib.Pcap.Test.AnalyzeTcpStreamTest tcpAnalyze = new Pib.Pcap.Test.AnalyzeTcpStreamTest();
            using (PcapFileReader pcapFileReader = new PcapFileReader(GetPath(file)))
            {
                PPacketManager ppacketManager = new PPacketManager();
                foreach (PcapPacket packet in pcapFileReader)
                {
                    Packet packet2 = new Packet(packet.Data, packet.Timestamp, DataLinkKind.Ethernet);
                    tcpAnalyze.Add(ppacketManager.CreatePPacket(packet2));
                }
            }

            Trace.WriteLine("{0} packet captured", tcpAnalyze.Packets.Count);
            //var q = from p in gPacketList where p.TCPHeader != null orderby p.gGroupNumber, p.PacketNumber select p;
            var q = from p in tcpAnalyze.Packets where p.PPacket.Tcp != null orderby p.StreamNumber, p.PPacket.PacketNumber select p;

            Trace.WriteLine("{0} packet selectionned", q.Count());
            foreach (Pib.Pcap.Test.TcpStreamPacket p in q)
            {
                PrintStreamPacket(p);
            }
        }
Exemplo n.º 2
0
 public static void Test_ReadPcap_02(string file, bool detail = false)
 {
     Trace.WriteLine("read file \"{0}\"", file);
     using (PcapFileReader pcapFileReader = new PcapFileReader(GetPath(file)))
     {
         PPacketManager ppacketManager = new PPacketManager();
         foreach (PcapPacket packet in pcapFileReader)
         {
             Packet packet2 = new Packet(packet.Data, packet.Timestamp, DataLinkKind.Ethernet);
             //Trace.WriteLine("packet no {0}", packet.Index);
             //PrintPacketHandler2(ppacketManager.CreatePPacket(packet2), detail);
             PrintPacket.PrintPacket1(ppacketManager.CreatePPacket(packet2), detail);
         }
     }
 }
Exemplo n.º 3
0
 public static void Test_ReadPcap_PrintPacketsDetail_01(string file)
 {
     Trace.WriteLine("read file \"{0}\"", file);
     using (PcapFileReader pcapFileReader = new PcapFileReader(GetPath(file)))
     {
         PPacketManager ppacketManager = new PPacketManager();
         int            i = 0;
         foreach (PcapPacket packet in pcapFileReader)
         {
             Packet       packet2 = new Packet(packet.Data, packet.Timestamp, DataLinkKind.Ethernet);
             IpV4Datagram ip      = packet2.Ethernet.IpV4;
             if (ip.Tcp == null || ip.Tcp.Http.Version == null)
             {
                 continue;
             }
             if (++i > 5)
             {
                 break;
             }
             PrintPacketDetail.PrintPacketDetailHandler(ppacketManager.CreatePPacket(packet2));
         }
     }
 }