コード例 #1
0
 public virtual void  testPshAckPacketHeaderValues()
 {
     assertEquals(Packets.IPProtocols_Fields.TCP, _pshAck.IPProtocol);
     assertEquals(Packets.IPProtocols_Fields.TCP, _pshAck.Protocol);
     assertEquals("IP Checksum mismatch, should be 0x38a2, but is " + System.Convert.ToString(_pshAck.IPChecksum, 16), 0x38a2, _pshAck.IPChecksum);
     assertEquals("(IP) Checksum mismatch, should be 0x38a2, but is " + System.Convert.ToString(_pshAck.Checksum, 16), 0x38a2, _pshAck.Checksum);
     IPPacket.TestProbe probe = new Packets.IPPacket.TestProbe(_pshAck);
     assertTrue("Computed IP checksum mismatch, should be " + System.Convert.ToString(_pshAck.IPChecksum, 16) + ", but is " + System.Convert.ToString(probe.ComputedSenderIPChecksum, 16) + ", (" + System.Convert.ToString(probe.ComputedReceiverIPChecksum, 16) + ")", _pshAck.ValidChecksum);
     assertEquals("Version mismatch, should be " + Packets.IPVersions_Fields.IPV4 + ", but is " + _pshAck.Version, Packets.IPVersions_Fields.IPV4, _pshAck.Version);
     assertEquals("TOS incorrect, should be 0, but is " + _pshAck.TypeOfService, 0, _pshAck.TypeOfService);
     assertEquals("Length incorrect, should be 62, but is " + _pshAck.Length, 62, _pshAck.Length);
     assertEquals("ID incorrect, should be 0x8708, but is " + _pshAck.Id, 0x8708, _pshAck.Id);
     assertEquals("Fragment flags incorrect, should be 0, but are " + _pshAck.FragmentFlags, 2, _pshAck.FragmentFlags);
     assertEquals("Fragment offset incorrect, should be 0, but is " + _pshAck.FragmentOffset, 0, _pshAck.FragmentOffset);
     assertEquals("Time-to-live incorrect, should be 63, but is " + _pshAck.TimeToLive, 63, _pshAck.TimeToLive);
 }
コード例 #2
0
        public static void MyTest1()
        {
            byte[] SYN_ACK_PACKET = new byte[] { (byte)(0x00), (byte)(0x10), (byte)(0x7b), (byte)(0x38), (byte)(0x46), (byte)(0x33), (byte)(0x08), (byte)(0x00), (byte)(0x20), (byte)(0x89), (byte)(0xa5), (byte)(0x9f), (byte)(0x08), (byte)(0x00), (byte)(0x45), (byte)(0x00), (byte)(0x00), (byte)(0x2c), (byte)(0x93), (byte)(0x83), (byte)(0x40), (byte)(0x00), (byte)(0xff), (byte)(0x06), (byte)(0x6c), (byte)(0x38), (byte)(0xac), (byte)(0x10), (byte)(0x70), (byte)(0x32), (byte)(0x87), (byte)(0x0d), (byte)(0xd8), (byte)(0xbf), (byte)(0x00), (byte)(0x19), (byte)(0x50), (byte)(0x49), (byte)(0x78), (byte)(0xbe), (byte)(0xe0), (byte)(0xa7), (byte)(0x9f), (byte)(0x3a), (byte)(0xb4), (byte)(0x03), (byte)(0x60), (byte)(0x12), (byte)(0x22), (byte)(0x38), (byte)(0xfc), (byte)(0xc7), (byte)(0x00), (byte)(0x00), (byte)(0x02), (byte)(0x04), (byte)(0x05), (byte)(0xb4), (byte)(0x70), (byte)(0x6c) };
            byte[] PSH_ACK_PACKET = new byte[] { (byte)(0x08), (byte)(0x00), (byte)(0x20), (byte)(0x89), (byte)(0xa5), (byte)(0x9f), (byte)(0x00), (byte)(0x10), (byte)(0x7b), (byte)(0x38), (byte)(0x46), (byte)(0x33), (byte)(0x08), (byte)(0x00), (byte)(0x45), (byte)(0x00), (byte)(0x00), (byte)(0x3e), (byte)(0x87), (byte)(0x08), (byte)(0x40), (byte)(0x00), (byte)(0x3f), (byte)(0x06), (byte)(0x38), (byte)(0xa2), (byte)(0x87), (byte)(0x0d), (byte)(0xd8), (byte)(0xbf), (byte)(0xac), (byte)(0x10), (byte)(0x70), (byte)(0x32), (byte)(0x50), (byte)(0x49), (byte)(0x00), (byte)(0x19), (byte)(0x9f), (byte)(0x3a), (byte)(0xb4), (byte)(0x03), (byte)(0x78), (byte)(0xbe), (byte)(0xe0), (byte)(0xf8), (byte)(0x50), (byte)(0x18), (byte)(0x7d), (byte)(0x78), (byte)(0x86), (byte)(0xf0), (byte)(0x00), (byte)(0x00), (byte)(0x45), (byte)(0x48), (byte)(0x4c), (byte)(0x4f), (byte)(0x20), (byte)(0x61), (byte)(0x6c), (byte)(0x70), (byte)(0x68), (byte)(0x61), (byte)(0x2e), (byte)(0x61), (byte)(0x70), (byte)(0x70), (byte)(0x6c), (byte)(0x65), (byte)(0x2e), (byte)(0x65), (byte)(0x64), (byte)(0x75), (byte)(0x0d), (byte)(0x0a) };

            // get link layer length
            int linkLayerLen = LinkLayer.getLinkLayerLength(Packets.LinkLayers.EN10MB);
            // create syn-ack packet
            IPPacket _synAck = new IPPacket(linkLayerLen, SYN_ACK_PACKET);
            // create psh-ack packet
            IPPacket _pshAck = new IPPacket(linkLayerLen, PSH_ACK_PACKET);

            // create packet with random garbage
            byte[] badBytes = new byte[SYN_ACK_PACKET.Length];
            (new System.Random()).NextBytes((badBytes));
            IPPacket _baddie = new IPPacket(linkLayerLen, badBytes);

            IPPacket.TestProbe probe = new Packets.IPPacket.TestProbe(_synAck);
            Console.WriteLine("Computed IP checksum mismatch, should be " + System.Convert.ToString(_synAck.IPChecksum, 16) + ", but is " + System.Convert.ToString(probe.ComputedSenderIPChecksum, 16) + ", (" + System.Convert.ToString(probe.ComputedReceiverIPChecksum, 16) + ") ---- {0}", _synAck.ValidChecksum);

            Console.WriteLine("From: {0}, To:{1}", _synAck.SourceAddress, _synAck.DestinationAddress);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: jiangguang5201314/VMukti
		public static void MyTest1()
		{

			byte[] SYN_ACK_PACKET = new byte[]{(byte) (0x00), (byte) (0x10), (byte) (0x7b), (byte) (0x38), (byte) (0x46), (byte) (0x33), (byte) (0x08), (byte) (0x00), (byte) (0x20), (byte) (0x89), (byte) (0xa5), (byte) (0x9f), (byte) (0x08), (byte) (0x00), (byte) (0x45), (byte) (0x00), (byte) (0x00), (byte) (0x2c), (byte) (0x93), (byte) (0x83), (byte) (0x40), (byte) (0x00), (byte) (0xff), (byte) (0x06), (byte) (0x6c), (byte) (0x38), (byte) (0xac), (byte) (0x10), (byte) (0x70), (byte) (0x32), (byte) (0x87), (byte) (0x0d), (byte) (0xd8), (byte) (0xbf), (byte) (0x00), (byte) (0x19), (byte) (0x50), (byte) (0x49), (byte) (0x78), (byte) (0xbe), (byte) (0xe0), (byte) (0xa7), (byte) (0x9f), (byte) (0x3a), (byte) (0xb4), (byte) (0x03), (byte) (0x60), (byte) (0x12), (byte) (0x22), (byte) (0x38), (byte) (0xfc), (byte) (0xc7), (byte) (0x00), (byte) (0x00), (byte) (0x02), (byte) (0x04), (byte) (0x05), (byte) (0xb4), (byte) (0x70), (byte) (0x6c)};
			byte[] PSH_ACK_PACKET = new byte[]{(byte) (0x08), (byte) (0x00), (byte) (0x20), (byte) (0x89), (byte) (0xa5), (byte) (0x9f), (byte) (0x00), (byte) (0x10), (byte) (0x7b), (byte) (0x38), (byte) (0x46), (byte) (0x33), (byte) (0x08), (byte) (0x00), (byte) (0x45), (byte) (0x00), (byte) (0x00), (byte) (0x3e), (byte) (0x87), (byte) (0x08), (byte) (0x40), (byte) (0x00), (byte) (0x3f), (byte) (0x06), (byte) (0x38), (byte) (0xa2), (byte) (0x87), (byte) (0x0d), (byte) (0xd8), (byte) (0xbf), (byte) (0xac), (byte) (0x10), (byte) (0x70), (byte) (0x32), (byte) (0x50), (byte) (0x49), (byte) (0x00), (byte) (0x19), (byte) (0x9f), (byte) (0x3a), (byte) (0xb4), (byte) (0x03), (byte) (0x78), (byte) (0xbe), (byte) (0xe0), (byte) (0xf8), (byte) (0x50), (byte) (0x18), (byte) (0x7d), (byte) (0x78), (byte) (0x86), (byte) (0xf0), (byte) (0x00), (byte) (0x00), (byte) (0x45), (byte) (0x48), (byte) (0x4c), (byte) (0x4f), (byte) (0x20), (byte) (0x61), (byte) (0x6c), (byte) (0x70), (byte) (0x68), (byte) (0x61), (byte) (0x2e), (byte) (0x61), (byte) (0x70), (byte) (0x70), (byte) (0x6c), (byte) (0x65), (byte) (0x2e), (byte) (0x65), (byte) (0x64), (byte) (0x75), (byte) (0x0d), (byte) (0x0a)};

			// get link layer length
			int linkLayerLen = LinkLayer.getLinkLayerLength(Packets.LinkLayers.EN10MB);
			// create syn-ack packet
			IPPacket _synAck = new IPPacket(linkLayerLen, SYN_ACK_PACKET);
			// create psh-ack packet
			IPPacket _pshAck = new IPPacket(linkLayerLen, PSH_ACK_PACKET);
			// create packet with random garbage
			byte[] badBytes = new byte[SYN_ACK_PACKET.Length];
			(new System.Random()).NextBytes((badBytes));
			IPPacket _baddie = new IPPacket(linkLayerLen, badBytes);

			IPPacket.TestProbe probe = new Packets.IPPacket.TestProbe(_synAck);
			Console.WriteLine("Computed IP checksum mismatch, should be " + System.Convert.ToString(_synAck.IPChecksum, 16) + ", but is " + System.Convert.ToString(probe.ComputedSenderIPChecksum, 16) + ", (" + System.Convert.ToString(probe.ComputedReceiverIPChecksum, 16) + ") ---- {0}", _synAck.ValidChecksum);

			Console.WriteLine("From: {0}, To:{1}", _synAck.SourceAddress, _synAck.DestinationAddress);
		}
コード例 #4
0
		public virtual void  testPshAckPacketHeaderValues()
		{
			assertEquals(Packets.IPProtocols_Fields.TCP, _pshAck.IPProtocol);
			assertEquals(Packets.IPProtocols_Fields.TCP, _pshAck.Protocol);
			assertEquals("IP Checksum mismatch, should be 0x38a2, but is " + System.Convert.ToString(_pshAck.IPChecksum, 16), 0x38a2, _pshAck.IPChecksum);
			assertEquals("(IP) Checksum mismatch, should be 0x38a2, but is " + System.Convert.ToString(_pshAck.Checksum, 16), 0x38a2, _pshAck.Checksum);
			IPPacket.TestProbe probe = new Packets.IPPacket.TestProbe(_pshAck);
			assertTrue("Computed IP checksum mismatch, should be " + System.Convert.ToString(_pshAck.IPChecksum, 16) + ", but is " + System.Convert.ToString(probe.ComputedSenderIPChecksum, 16) + ", (" + System.Convert.ToString(probe.ComputedReceiverIPChecksum, 16) + ")", _pshAck.ValidChecksum);
			assertEquals("Version mismatch, should be " + Packets.IPVersions_Fields.IPV4 + ", but is " + _pshAck.Version, Packets.IPVersions_Fields.IPV4, _pshAck.Version);
			assertEquals("TOS incorrect, should be 0, but is " + _pshAck.TypeOfService, 0, _pshAck.TypeOfService);
			assertEquals("Length incorrect, should be 62, but is " + _pshAck.Length, 62, _pshAck.Length);
			assertEquals("ID incorrect, should be 0x8708, but is " + _pshAck.Id, 0x8708, _pshAck.Id);
			assertEquals("Fragment flags incorrect, should be 0, but are " + _pshAck.FragmentFlags, 2, _pshAck.FragmentFlags);
			assertEquals("Fragment offset incorrect, should be 0, but is " + _pshAck.FragmentOffset, 0, _pshAck.FragmentOffset);
			assertEquals("Time-to-live incorrect, should be 63, but is " + _pshAck.TimeToLive, 63, _pshAck.TimeToLive);
		}