Exemplo n.º 1
0
        private static void device_PcapOnPacketArrival(Packet packet)
        {
            //if (!(packet is TCPPacket)) return;
            //if (packet.IpV4 == null || packet.IpV4.Tcp == null)
            if (packet.Ethernet == null || packet.Ethernet.IpV4 == null || packet.Ethernet.IpV4.Tcp == null)
            {
                return;
            }

            //TCPPacket tcpPacket = (TCPPacket)packet;
            //TcpDatagram tcp = packet.Ethernet.IpV4.Tcp;
            // Creates a key for the dictionary
            //Connection c = new Connection(tcpPacket);
            Connection c = new Connection(packet);

            // create a new entry if the key does not exists
            if (!sharpPcapDict.ContainsKey(c))
            {
                string   fileName = c.getFileName(_path);
                TcpRecon tcpRecon = new TcpRecon(fileName);
                sharpPcapDict.Add(c, tcpRecon);
            }

            // Use the TcpRecon class to reconstruct the session
            //sharpPcapDict[c].ReassemblePacket(tcpPacket);
            sharpPcapDict[c].ReassemblePacket(packet);
        }
Exemplo n.º 2
0
        private static void device_PcapOnPacketArrival(Packet packet)
        {
            //if (!(packet is TCPPacket)) return;
            //if (packet.IpV4 == null || packet.IpV4.Tcp == null)
            if (packet.Ethernet == null || packet.Ethernet.IpV4 == null || packet.Ethernet.IpV4.Tcp == null)
                return;

            //TCPPacket tcpPacket = (TCPPacket)packet;
            //TcpDatagram tcp = packet.Ethernet.IpV4.Tcp;
            // Creates a key for the dictionary
            //Connection c = new Connection(tcpPacket);
            Connection c = new Connection(packet);

            // create a new entry if the key does not exists
            if (!sharpPcapDict.ContainsKey(c))
            {
                string fileName = c.getFileName(_path);
                TcpRecon tcpRecon = new TcpRecon(fileName);
                sharpPcapDict.Add(c, tcpRecon);
            }

            // Use the TcpRecon class to reconstruct the session
            //sharpPcapDict[c].ReassemblePacket(tcpPacket);
            sharpPcapDict[c].ReassemblePacket(packet);
        }