예제 #1
0
        public void TestDecode()
        {
            HexData samplePacket = new HexData("cfff00001712a2702fa91b97cb3db9d7736d32f2231932941156221f7eed93c8ea78b87c0c80a55c60c60044a30fe946ba0cec818cdf237ddb78c816ab1bdff71c509c797d8a93c8c2449bc10b3667f3a0bee0e9ea2990152054d336006fbddb38e1dc580004a819febadf22f21eb14c15687de9230b6b8bc4da592479215fe3e44eb3baece38c0c02e7294783ed01429aa40624b4d9cda7eef2d4520fb285ea1cbb3433324b10f8711a1277edbf34e82919a082f6a332d2a2d52ff956914d1dac7b482d40bc2854401df5309db5a8cc5b642ab9474885492ea99482cfd5483feaa1897cb5a33f1268bc8ca40fc5155d92a3f3868614faecff089691cf1965bcc6e0977ff8431327ab18bdb0013f4a9180bc90bc8fe3afb65782e2f21d67005be0c6d04a0a63f2738064d0fc538477a824e056cecf4b01a55e7ce86c8078a688198716c050aa7af2facca178f911e63d3bffd28339040f54c1b3b40f9794578f27d4c64aab38b4a23ee5bc1239711dcacad5a623506cd504394cc1673b83590877603d308a5c6b7febfd6af582a507477c64c16553056c23830ec391c198fb64190bc40cd33b05749b0e3abd0e75c60de0d3c6a8dd6280ca62fe10eb1900015f038e9911c64efb87e1c4a3d66700fd7b1247cc4f7f74beec3937d92c03a6489ecfb27e3974ecc50c2c79661291ba5dc3d10e4b8eb2f42bc28ebcc8578823e55d288c7efbf1ae434eed2c444d865953c1bf805cd793f528930096b6a473964e6706393ae9b934d4761b18741fcd6940e71a9c99e5b90eb8af0d62c6c39081b6aeb01083819741c7a09bb3bdf235f0622b286eb509f203370fe44da1386ea81ed51527d7d5f1368eb206113e5f2ca167c645506b3b6a7b59276fa49eedbfa3d81721ad68726492f50588b311c895478d89b48c336d0a87ccb84e3c7cf782450784124d720209df89241f589b5ca92c5d06aa9e313d6cd4d68d87b839ff9e0eebcc4f29399a98783aba5d540b549bd39aa3c541593af7f4c171bced1e1c72ddc6ad9985bf671ae1b1de1c178592b32f5a7fb60fadacaf8978b07360db0a0cd1f69138e8d883000f2a99d50ce64339d599076c2fdbd81d58642dc945594fd9e8eb38d341c8c3260c2c82c43065058fcd38fe028db6aefe16798afc8984748484da7ad4eff1302a5e939565e572ec2facb544cadf84a046a236359e2891e370c1bf8b16e28ed3e215527475db571b52e660ab711bc7e4e9e786c1d94ef5dd3ebe91f44abb0c167a86e959be54196e3f01a593ba34b37b5cc36fe8357c1d9b0bf0b817c6d7905efdbbf9f78e7ba196cffca2444a1cec3750b71b1fc866b2d15302e9c1a8285946e536a51a83d34fc695f11f4244fb925ab996913b8437f745140649840f26f6023e5dc29338d73ec6208bf3f8784a698f2f0867efb5d70041da4cf6a627f14fe3ac7bbaf90eeece28ac676e592a3d51921359bcc8905cdfc1610694144607fe43b1ea8a1ff03adacab409e66b8a4b795d87a6419c15bb92fc5c1ffd1ae7735e5d4612c42d35c009abe0e0d4d21676733cd1440656f291e21c10ed2db649e0ffbccb3fe8b021125a16c79f8f02734deb049a180855c0f21013a0921ef13b016e76c57599feb67a517bcb8bcb895f56d634ea5308f9c68ddeff22d57c9f9ec09c2fdd8f1ab273f1d9964bb2f211f408d67f252ddd665a3fb3a44ca98e9512a3d3d2c0453c244db31f79be0549c8");

            byte[] bytes = samplePacket.bytes;
            Packet p     = Packet.Unpack(samplePacket.bytes);

            Assert.AreEqual(p.GetType(), typeof(InitialPacket));
            InitialPacket recP = p as InitialPacket;

            Assert.AreEqual(0xff000017, recP.Version);
            Assert.AreEqual((UInt32)18, recP.DCIDLength);
            CollectionAssert.AreEqual((new HexData("a2702fa91b97cb3db9d7736d32f223193294")).bytes, recP.DCID);
            Assert.AreEqual((UInt32)17, recP.SCIDLength);
            CollectionAssert.AreEqual((new HexData("56221f7eed93c8ea78b87c0c80a55c60c6")).bytes, recP.SCID);

            // Wireshark translates the initial 0xCF to 0b11000000 while our code translates it to 0b11001111
            // Likely because of header protection, which we cannot have without QUIC-TLS
            // PacketNumberLength and PacketNumber thus cannot be computed correctly
            // Assert.AreEqual((UInt32)1, recP.PacketNumberLength);
            // Assert.AreEqual((UInt32)0, recP.PacketNumber);
            Assert.AreEqual((UInt64)0, recP.TokenLength.Value);
            CollectionAssert.AreEqual(new byte[] { }, recP.Token);
            Assert.AreEqual((UInt64)1187, recP.Length.Value);
            // TODO: assert payload content
        }
예제 #2
0
        public void TestDecode()
        {
            HexData samplePacket = new HexData("d4ff0000171116b9c8c2eb9a0c815d415be8bda522edfa145e1178e63dd8e8da9f9c637dd95b03413c82cd8c408e6f9722022f02eeb44626382118e6c9e0cb7df0099dbe936a71f0dbe85e4dd445d11f7cd46fa0f21d3972574164ed409c03a56f8585891a18652bd7682914647f4ce42c6fef68161e4a3321a870e369edccdfcc130a88f6f4b5e33d820dcc996db5d7cc775b29bf2f34cdd23d906f2d386026c4ce002dfdd227bc0fcee14a8089278e4e59c36ecc549c4f399b8c08");

            byte[] bytes = samplePacket.bytes;
            Packet p     = Packet.Unpack(samplePacket.bytes);

            Assert.AreEqual(p.GetType(), typeof(RTTPacket));
            RTTPacket recP = p as RTTPacket;

            Assert.AreEqual(0xff000017, recP.Version);
            Assert.AreEqual((UInt32)17, recP.DCIDLength);
            CollectionAssert.AreEqual((new HexData("16b9c8c2eb9a0c815d415be8bda522edfa")).bytes, recP.DCID);
            Assert.AreEqual((UInt32)20, recP.SCIDLength);
            CollectionAssert.AreEqual((new HexData("5e1178e63dd8e8da9f9c637dd95b03413c82cd8c")).bytes, recP.SCID);

            // PacketNumberLength and PacketNumber cannot be computed correctly: see TestInitialPacket
            // Assert.AreEqual((UInt32)1, recP.PacketNumberLength);
            // Assert.AreEqual((UInt32)111, recP.PacketNumber);
            Assert.AreEqual((UInt64)142, recP.Length.Value);
            CollectionAssert.AreEqual((new HexData("9722022f02eeb44626382118e6c9e0cb7df0099dbe936a71f0dbe85e4dd445d11f7cd46fa0f21d3972574164ed409c03a56f8585891a18652bd7682914647f4ce42c6fef68161e4a3321a870e369edccdfcc130a88f6f4b5e33d820dcc996db5d7cc775b29bf2f34cdd23d906f2d386026c4ce002dfdd227bc0fcee14a8089278e4e59c36ecc549c4f399b8c08")).bytes, recP.Payload);
        }