diff options
Diffstat (limited to 'infra')
| -rw-r--r-- | infra/include/ldbc.h | 4 | ||||
| -rw-r--r-- | infra/src/ldbc.c | 31 | ||||
| -rw-r--r-- | infra/test/10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap | bin | 0 -> 8974 bytes | |||
| -rw-r--r-- | infra/test/TestDistributer.cc | 346 | ||||
| -rw-r--r-- | infra/test/TestPacketParser.cc | 104 |
5 files changed, 424 insertions, 61 deletions
diff --git a/infra/include/ldbc.h b/infra/include/ldbc.h index 83f361e..3965a33 100644 --- a/infra/include/ldbc.h +++ b/infra/include/ldbc.h @@ -67,7 +67,7 @@ enum complex_layer LAYER_TYPE_GTPV1_U = 1 << 10 }; -#define MR_PKT_PARSE_RESULT_MAX 4 +#define MR_PKT_PARSE_RESULT_MAX 8 enum { @@ -142,4 +142,4 @@ static inline int pkt_parser_push(struct pkt_parser * pkt_parser, } const char * ldbc_str_dist_mode(struct distributer * dist_object); -const char * ldbc_str_hash_mode(struct distributer * dist_object);
\ No newline at end of file +const char * ldbc_str_hash_mode(struct distributer * dist_object); diff --git a/infra/src/ldbc.c b/infra/src/ldbc.c index e5604b1..29d7b9e 100644 --- a/infra/src/ldbc.c +++ b/infra/src/ldbc.c @@ -558,23 +558,10 @@ static inline uint32_t hash_sym_rss(struct distributer * dist, const void * data switch (layer_type) { + /* RSS is not support TCP/UDP for the short length */ case LAYER_TYPE_TCP: - { - const struct rte_tcp_hdr * tcp_hdr = (const struct rte_tcp_hdr *)data; - s_data = (const char *)&tcp_hdr->src_port; - d_data = (const char *)&tcp_hdr->dst_port; - data_len = sizeof(uint16_t); - break; - } - case LAYER_TYPE_UDP: - { - const struct rte_udp_hdr * udp_hdr = (const struct rte_udp_hdr *)data; - s_data = (const char *)&udp_hdr->src_port; - d_data = (const char *)&udp_hdr->dst_port; - data_len = sizeof(uint16_t); - break; - } + return orin_hash; case LAYER_TYPE_IPV4: { @@ -604,6 +591,16 @@ static inline uint32_t hash_sym_rss(struct distributer * dist, const void * data return src_hash ^ dst_hash; } +uint32_t EXPORT_FOR_UNITTEST_hash_sym_crc(struct distributer * dist, const void * data, int layer_type, uint32_t orin_hash) +{ + return hash_sym_crc(dist, data, layer_type, orin_hash); +} + +uint32_t EXPORT_FOR_UNITTEST_hash_sym_rss(struct distributer * dist, const void * data, int layer_type, uint32_t orin_hash) +{ + return hash_sym_rss(dist, data, layer_type, orin_hash); +} + static inline uint32_t __distributer_inner_tuple2(struct distributer * dist_object, struct rte_mbuf * mbuf) { @@ -611,7 +608,7 @@ static inline uint32_t __distributer_inner_tuple2(struct distributer * dist_obje int inner_layer_type; struct pkt_parser pkt_parser; - pkt_parser_init(&pkt_parser, LAYER_TYPE_L3, 2); + pkt_parser_init(&pkt_parser, LAYER_TYPE_L3, 4); /* 根据硬件的解析能力,找到最外层的IP */ #if ENABLE_LDBC_BASED_NIC_PTYPE @@ -647,7 +644,7 @@ static inline uint32_t __distributer_inner_tuple4(struct distributer * dist_obje struct rte_mbuf * mbuf) { struct pkt_parser pkt_parser; - pkt_parser_init(&pkt_parser, LAYER_TYPE_L3 | LAYER_TYPE_L4, 4); + pkt_parser_init(&pkt_parser, LAYER_TYPE_L3 | LAYER_TYPE_L4, 8); /* 根据硬件的解析能力,找到最外层的IP */ #if ENABLE_LDBC_BASED_NIC_PTYPE diff --git a/infra/test/10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap b/infra/test/10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap Binary files differnew file mode 100644 index 0000000..a031787 --- /dev/null +++ b/infra/test/10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap diff --git a/infra/test/TestDistributer.cc b/infra/test/TestDistributer.cc index c3d9a37..414054f 100644 --- a/infra/test/TestDistributer.cc +++ b/infra/test/TestDistributer.cc @@ -19,6 +19,14 @@ extern "C" #define TEST_PCAP_FILE_PREFIX "" #endif +using test_table_t = std::tuple<const char *, enum e_dist_mode, enum e_hash_mode, const char *, const char *, uint16_t, uint16_t>; + +extern "C" +{ +extern uint32_t EXPORT_FOR_UNITTEST_hash_sym_crc(struct distributer * dist, const void * data, int layer_type, uint32_t orin_hash); +extern uint32_t EXPORT_FOR_UNITTEST_hash_sym_rss(struct distributer * dist, const void * data, int layer_type, uint32_t orin_hash); +} + class PacketLoader { private: @@ -68,15 +76,12 @@ public: } }; -class TestFixtureDistributer : public ::testing::TestWithParam< - std::tuple<const char *, enum e_dist_mode, enum e_hash_mode>> +class TestFixtureDistributer : public ::testing::TestWithParam<test_table_t> { void SetUp() override { /* Load Test Param */ - auto * pcap_file = std::get<0>(GetParam()); - dist_mode_ = std::get<1>(GetParam()); - hash_mode_ = std::get<2>(GetParam()); + auto *pcap_file = std::get<0>(GetParam()); /* Perpare PCAP reader */ pkt_loader_ = new PacketLoader(); @@ -85,7 +90,48 @@ class TestFixtureDistributer : public ::testing::TestWithParam< pkt_loader_->LoadFromPcapFile(testfile); /* Prepare Distributer Handle */ + dist_mode_ = std::get<1>(GetParam()); + hash_mode_ = std::get<2>(GetParam()); dist_object_ = distributer_create(dist_mode_, hash_mode_, 0); + + /* Retrive the expected SIP, DIP, SPORT, DPORT */ + uint32_t sip = 0; + uint32_t dip = 0; + + const char *str_sip = std::get<3>(GetParam()); + const char *str_dip = std::get<4>(GetParam()); + uint16_t sport = htons(std::get<5>(GetParam())); + uint16_t dport = htons(std::get<6>(GetParam())); + + ASSERT_EQ(inet_pton(AF_INET, str_sip, &sip), 1); + ASSERT_EQ(inet_pton(AF_INET, str_dip, &dip), 1); + + /* Perpare fake headers to caculate the hash values */ + struct rte_ipv4_hdr ipv4_hdr_expected {}; + ipv4_hdr_expected.src_addr = sip; + ipv4_hdr_expected.dst_addr = dip; + + struct __fake_tcp_or_udp_hdr { + uint16_t sport; + uint16_t dport; + } fake_tcp_or_udp_hdr{sport, dport}; + + expected_hash_value_ = 0; + if (dist_object_->fn_hash_0 != nullptr) + { + expected_hash_value_ = dist_object_->fn_hash_0( + dist_object_, (const void *) &ipv4_hdr_expected, LAYER_TYPE_IPV4, dist_object_->orin_hash); + } + + if (dist_mode_ == LDBC_DIST_OUTER_TUPLE4 || dist_mode_ == LDBC_DIST_INNER_TUPLE4) + { + if (dist_object_->fn_hash_1 != nullptr) + { + expected_hash_value_ = dist_object_->fn_hash_1( + dist_object_, (const void *) &fake_tcp_or_udp_hdr, + LAYER_TYPE_TCP, expected_hash_value_); + } + } } void TearDown() override @@ -98,98 +144,314 @@ protected: enum e_dist_mode dist_mode_; enum e_hash_mode hash_mode_; struct distributer * dist_object_; + uint32_t expected_hash_value_; }; TEST_P(TestFixtureDistributer, TestDistHashResult) { - uint32_t hash_result{0}; - bool hash_result_set{false}; - for (auto m = pkt_loader_->FetchPacket(); m != nullptr; m = pkt_loader_->FetchPacket()) { struct rte_mbuf * __mbuf = m.get(); distributer_caculate(dist_object_, &__mbuf, 1); - - if (hash_result_set) - { - EXPECT_EQ(m->hash.usr, hash_result); - } - else - { - hash_result_set = true; - hash_result = m->hash.usr; - } + EXPECT_EQ(m->hash.usr, expected_hash_value_); } - - EXPECT_NE(hash_result, 0); } -std::tuple<const char *, enum e_dist_mode, enum e_hash_mode> testTable[] +test_table_t testTable[] { + /* Frame 1: 195 bytes on wire (1560 bits), 195 bytes captured (1560 bits) + Ethernet II, Src: HuaweiTe_2f:a8:08 (34:0a:98:2f:a8:08), Dst: 5a:78:88:20:66:db (5a:78:88:20:66:db) + Internet Protocol Version 4, Src: 10.4.127.4, Dst: 10.4.36.1 + User Datagram Protocol, Src Port: 10000, Dst Port: 4789 + Virtual eXtensible Local Area Network + Ethernet II, Src: JuniperN_46:5f:c7 (00:24:dc:46:5f:c7), Dst: JuniperN_a5:bb:f5 (3c:61:04:a5:bb:f5) + MultiProtocol Label Switching Header, Label: 444673, Exp: 1, S: 1, TTL: 125 + Internet Protocol Version 4, Src: 178.89.4.219, Dst: 117.122.217.89 + Transmission Control Protocol, Src Port: 58062, Dst Port: 443, Seq: 1, Ack: 1, Len: 87 + Transport Layer Security + */ std::make_tuple("178_89_4_219_to_117_122_217_89_mpls_vxlan_inner.pcap", LDBC_DIST_INNER_TUPLE2, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.219", + "117.122.217.89", + 58062, + 443), std::make_tuple("178_89_4_219_to_117_122_217_89_mpls_vxlan_inner.pcap", LDBC_DIST_INNER_TUPLE2, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.219", + "117.122.217.89", + 58062, + 443), std::make_tuple("178_89_4_219_to_117_122_217_89_mpls_vxlan_inner.pcap", LDBC_DIST_INNER_TUPLE4, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.219", + "117.122.217.89", + 58062, + 443), std::make_tuple("178_89_4_219_to_117_122_217_89_mpls_vxlan_inner.pcap", LDBC_DIST_INNER_TUPLE4, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.219", + "117.122.217.89", + 58062, + 443), + + /* Frame 1: 1498 bytes on wire (11984 bits), 1498 bytes captured (11984 bits) + Ethernet II, Src: 00:00:00_00:04:34 (00:00:00:00:04:34), Dst: 18:10:04:00:01:26 (18:10:04:00:01:26) + MultiProtocol Label Switching Header, Label: 594864, Exp: 0, S: 0, TTL: 60 + MultiProtocol Label Switching Header, Label: 18, Exp: 0, S: 1, TTL: 60 + Internet Protocol Version 4, Src: 172.16.51.180, Dst: 10.224.139.116 + User Datagram Protocol, Src Port: 2152, Dst Port: 2152 + GPRS Tunneling Protocol + Internet Protocol Version 4, Src: 149.3.200.32, Dst: 100.95.37.122 + Transmission Control Protocol, Src Port: 443, Dst Port: 44672, Seq: 1, Ack: 1, Len: 1388 + Transport Layer Security + */ + + std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", + LDBC_DIST_OUTER_TUPLE2, + LDBC_HASH_SYM_CRC, + "172.16.51.180", + "10.224.139.116", + 2152, + 2152), + std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", + LDBC_DIST_OUTER_TUPLE2, + LDBC_HASH_SYM_RSS, + "172.16.51.180", + "10.224.139.116", + 2152, + 2152), + std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", + LDBC_DIST_OUTER_TUPLE4, + LDBC_HASH_SYM_CRC, + "172.16.51.180", + "10.224.139.116", + 2152, + 2152), + std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", + LDBC_DIST_OUTER_TUPLE4, + LDBC_HASH_SYM_RSS, + "172.16.51.180", + "10.224.139.116", + 2152, + 2152), std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", LDBC_DIST_INNER_TUPLE2, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "149.3.200.32", + "100.95.37.122", + 443, + 44672), std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", LDBC_DIST_INNER_TUPLE2, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "149.3.200.32", + "100.95.37.122", + 443, + 44672), std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", LDBC_DIST_INNER_TUPLE4, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "149.3.200.32", + "100.95.37.122", + 443, + 44672), std::make_tuple("100_95_37_122_to_149_3_200_32_gtpv1_u.pcap", LDBC_DIST_INNER_TUPLE4, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "149.3.200.32", + "100.95.37.122", + 443, + 44672), + + /*Frame 1: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) + Ethernet II, Src: 5f:c2:88:47:7f:7f (5f:c2:88:47:7f:7f), Dst: 0d:6a:00:24:dc:46 (0d:6a:00:24:dc:46) + Internet Protocol Version 4, Src: 178.89.4.219, Dst: 213.180.204.183 + Transmission Control Protocol, Src Port: 55189, Dst Port: 443, Seq: 0, Len: 0 */ + std::make_tuple("178_89_4_219_to_117_122_217_89_ipv4.pcap", LDBC_DIST_OUTER_TUPLE2, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.219", + "213.180.204.183", + 55189, + 443), std::make_tuple("178_89_4_219_to_117_122_217_89_ipv4.pcap", LDBC_DIST_OUTER_TUPLE2, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.219", + "213.180.204.183", + 55189, + 443), std::make_tuple("178_89_4_219_to_117_122_217_89_ipv4.pcap", LDBC_DIST_OUTER_TUPLE4, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.219", + "213.180.204.183", + 55189, + 443), std::make_tuple("178_89_4_219_to_117_122_217_89_ipv4.pcap", LDBC_DIST_OUTER_TUPLE4, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.219", + "213.180.204.183", + 55189, + 443), + + /* + Frame 1: 214 bytes on wire (1712 bits), 214 bytes captured (1712 bits) + Ethernet II, Src: 00:00:00_00:04:10 (00:00:00:00:04:10), Dst: 18:10:04:00:00:26 (18:10:04:00:00:26) + MultiProtocol Label Switching Header, Label: 506305, Exp: 1, S: 1, TTL: 61 + Internet Protocol Version 4, Src: 178.89.4.221, Dst: 31.13.70.49 + Transmission Control Protocol, Src Port: 58100, Dst Port: 443, Seq: 1, Ack: 1, Len: 144 + Transport Layer Security + */ + std::make_tuple("178.89.4.221_to_31.13.70.49_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE2, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.221", + "31.13.70.49", + 58100, + 443), std::make_tuple("178.89.4.221_to_31.13.70.49_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE2, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.221", + "31.13.70.49", + 58100, + 443), std::make_tuple("178.89.4.221_to_31.13.70.49_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE4, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.221", + "31.13.70.49", + 58100, + 443), std::make_tuple("178.89.4.221_to_31.13.70.49_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE4, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.221", + "31.13.70.49", + 58100, + 443), + + /* Frame 1: 82 bytes on wire (656 bits), 82 bytes captured (656 bits) + Ethernet II, Src: 00:00:00_00:04:10 (00:00:00:00:04:10), Dst: 18:10:04:00:00:26 (18:10:04:00:00:26) + MultiProtocol Label Switching Header, Label: 506305, Exp: 1, S: 1, TTL: 61 + Internet Protocol Version 4, Src: 178.89.4.221, Dst: 31.13.70.49 + Transmission Control Protocol, Src Port: 54282, Dst Port: 443, Seq: 0, Len: 0 + */ + std::make_tuple("178.89.4.221_to_31.13.70.49_asym_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE2, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.221", + "31.13.70.49", + 54282, + 443), std::make_tuple("178.89.4.221_to_31.13.70.49_asym_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE2, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.221", + "31.13.70.49", + 54282, + 443), std::make_tuple("178.89.4.221_to_31.13.70.49_asym_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE4, - LDBC_HASH_SYM_CRC), + LDBC_HASH_SYM_CRC, + "178.89.4.221", + "31.13.70.49", + 54282, + 443), std::make_tuple("178.89.4.221_to_31.13.70.49_asym_mpls_ipv4.pcap", LDBC_DIST_OUTER_TUPLE4, - LDBC_HASH_SYM_RSS), + LDBC_HASH_SYM_RSS, + "178.89.4.221", + "31.13.70.49", + 54282, + 443), + + /* + Frame 1: 168 bytes on wire (1344 bits), 168 bytes captured (1344 bits) + Ethernet II, Src: 0a:0a:0a:0a:00:10 (0a:0a:0a:0a:00:10), Dst: 90:00:00:91:40:46 (90:00:00:91:40:46) + Internet Protocol Version 4, Src: 10.10.0.16, Dst: 10.252.22.1 + User Datagram Protocol, Src Port: 61163, Dst Port: 4789 + Virtual eXtensible Local Area Network + Ethernet II, Src: HuaweiTe_2a:dc:03 (10:51:72:2a:dc:03), Dst: Broadcast (ff:ff:ff:ff:ff:ff) + 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 600 + Internet Protocol Version 4, Src: 10.254.142.4, Dst: 197.156.73.235 + User Datagram Protocol, Src Port: 65535, Dst Port: 2152 + GPRS Tunneling Protocol + Internet Protocol Version 4, Src: 10.23.160.163, Dst: 129.226.103.217 + Transmission Control Protocol, Src Port: 8235, Dst Port: 80, Seq: 0, Len: 0 + */ + + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_OUTER_TUPLE2, + LDBC_HASH_SYM_CRC, + "10.10.0.16", + "10.252.22.1", + 61163, + 4789), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_OUTER_TUPLE2, + LDBC_HASH_SYM_RSS, + "10.10.0.16", + "10.252.22.1", + 61163, + 4789), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_OUTER_TUPLE4, + LDBC_HASH_SYM_CRC, + "10.10.0.16", + "10.252.22.1", + 61163, + 4789), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_OUTER_TUPLE4, + LDBC_HASH_SYM_RSS, + "10.10.0.16", + "10.252.22.1", + 61163, + 4789), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_INNER_TUPLE2, + LDBC_HASH_SYM_CRC, + "10.23.160.163", + "129.226.103.217", + 8235, + 80), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_INNER_TUPLE2, + LDBC_HASH_SYM_RSS, + "10.23.160.163", + "129.226.103.217", + 8235, + 80), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_INNER_TUPLE4, + LDBC_HASH_SYM_CRC, + "10.23.160.163", + "129.226.103.217", + 8235, + 80), + std::make_tuple("10.23.160.163_to_129.226.103.217_gtp_u_in_vxlan.pcap", + LDBC_DIST_INNER_TUPLE4, + LDBC_HASH_SYM_RSS, + "10.23.160.163", + "129.226.103.217", + 8235, + 80) }; INSTANTIATE_TEST_CASE_P(TestOuterTuple2, TestFixtureDistributer, ::testing::ValuesIn(testTable)); + /* 分流算法测试 */ /* 测试用例1: Ether/IPv4,按外层IP地址分流 */ static const unsigned char stream_ipv4_pkt_0[78] = { @@ -677,4 +939,4 @@ TEST(DistributerInner2, EtherIPv4OffloadVxLANIPv4) { EXPECT_NE(__mbufs[__nr_mbufs - 1].hash.usr, __mbufs[i].hash.usr); } -}
\ No newline at end of file +} diff --git a/infra/test/TestPacketParser.cc b/infra/test/TestPacketParser.cc index 062829c..3671087 100644 --- a/infra/test/TestPacketParser.cc +++ b/infra/test/TestPacketParser.cc @@ -736,6 +736,110 @@ TEST(PacketParseInnerL3, EtherIPv6UDPGTPv1EXTIPv6) TestCheckIPv6Addr(result, "2409:8034:2000::4", "2409:8934:4484:1236:60a5:d6ff:fefc:9c59"); } +/* + Frame 33857: 318 bytes on wire (2544 bits), 318 bytes captured (2544 bits) + Ethernet II, Src: 0a:0a:0a:0a:00:10 (0a:0a:0a:0a:00:10), Dst: 90:00:00:91:40:46 (90:00:00:91:40:46) + Internet Protocol Version 4, Src: 10.10.0.16, Dst: 10.252.22.1 + User Datagram Protocol, Src Port: 60055, Dst Port: 4789 + Virtual eXtensible Local Area Network + Ethernet II, Src: HuaweiTe_2a:dc:03 (10:51:72:2a:dc:03), Dst: Broadcast (ff:ff:ff:ff:ff:ff) + 802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 600 + Internet Protocol Version 4, Src: 10.202.0.74, Dst: 10.254.142.4 + User Datagram Protocol, Src Port: 2152, Dst Port: 2152 + GPRS Tunneling Protocol + Internet Protocol Version 4, Src: 216.58.209.132, Dst: 10.59.238.65 + Transmission Control Protocol, Src Port: 443, Dst Port: 37714, Seq: 1, Ack: 1, Len: 162 + Transport Layer Security +*/ +static const unsigned char _pkt_gtp_u_over_vxlan_tls_1[318] = { +0x90, 0x00, 0x00, 0x91, 0x40, 0x46, 0x0a, 0x0a, /* ....@F.. */ +0x0a, 0x0a, 0x00, 0x10, 0x08, 0x00, 0x45, 0x00, /* ......E. */ +0x01, 0x30, 0x00, 0x00, 0x40, 0x00, 0x40, 0x11, /* .0..@.@. */ +0x0e, 0xa7, 0x0a, 0x0a, 0x00, 0x10, 0x0a, 0xfc, /* ........ */ +0x16, 0x01, 0xea, 0x97, 0x12, 0xb5, 0x01, 0x1c, /* ........ */ +0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */ +0x39, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 9....... */ +0x10, 0x51, 0x72, 0x2a, 0xdc, 0x03, 0x81, 0x00, /* .Qr*.... */ +0x02, 0x58, 0x08, 0x00, 0x45, 0x00, 0x00, 0xfa, /* .X..E... */ +0xde, 0x40, 0x00, 0x00, 0x3d, 0x11, 0xfa, 0x9c, /* .@..=... */ +0x0a, 0xca, 0x00, 0x4a, 0x0a, 0xfe, 0x8e, 0x04, /* ...J.... */ +0x08, 0x68, 0x08, 0x68, 0x00, 0xe6, 0x00, 0x00, /* .h.h.... */ +0x30, 0xff, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x8d, /* 0....... */ +0x45, 0x00, 0x00, 0xd6, 0x8d, 0x70, 0x00, 0x00, /* E....p.. */ +0x39, 0x06, 0x51, 0x76, 0xd8, 0x3a, 0xd1, 0x84, /* 9.Qv.:.. */ +0x0a, 0x3b, 0xee, 0x41, 0x01, 0xbb, 0x93, 0x52, /* .;.A...R */ +0xed, 0xc0, 0xfd, 0x50, 0x97, 0x79, 0xf8, 0x1f, /* ...P.y.. */ +0x80, 0x19, 0x01, 0x05, 0xf7, 0x13, 0x00, 0x00, /* ........ */ +0x01, 0x01, 0x08, 0x0a, 0x77, 0xe8, 0x07, 0x3f, /* ....w..? */ +0x00, 0x22, 0xac, 0xc2, 0x16, 0x03, 0x03, 0x00, /* ."...... */ +0x6a, 0x02, 0x00, 0x00, 0x66, 0x03, 0x03, 0x61, /* j...f..a */ +0x92, 0x5a, 0x25, 0x9c, 0xf5, 0x72, 0xba, 0x26, /* .Z%..r.& */ +0x90, 0xdd, 0xb7, 0xdb, 0x28, 0xad, 0xb3, 0xc7, /* ....(... */ +0x84, 0xd1, 0xac, 0x58, 0x44, 0x46, 0x51, 0x44, /* ...XDFQD */ +0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x01, 0x20, /* OWNGRD. */ +0xca, 0xcb, 0x30, 0xe4, 0x4a, 0x36, 0x14, 0x93, /* ..0.J6.. */ +0x1e, 0x53, 0x67, 0xa6, 0xa2, 0xc7, 0x94, 0xca, /* .Sg..... */ +0x41, 0xd7, 0x05, 0xf9, 0xed, 0x97, 0xcc, 0x8b, /* A....... */ +0xb5, 0x66, 0xbe, 0x9f, 0x54, 0x7f, 0xdd, 0x5e, /* .f..T..^ */ +0xc0, 0x2b, 0x00, 0x00, 0x1e, 0x00, 0x17, 0x00, /* .+...... */ +0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b, /* ........ */ +0x00, 0x02, 0x01, 0x00, 0x00, 0x10, 0x00, 0x0b, /* ........ */ +0x00, 0x09, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, /* ...http/ */ +0x31, 0x2e, 0x31, 0x14, 0x03, 0x03, 0x00, 0x01, /* 1.1..... */ +0x01, 0x16, 0x03, 0x03, 0x00, 0x28, 0x00, 0x00, /* .....(.. */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x3d, /* ......>= */ +0x1c, 0x7f, 0xe0, 0xdd, 0x4e, 0x13, 0x81, 0xd5, /* ....N... */ +0x78, 0xc8, 0x3c, 0xe6, 0x6d, 0xa6, 0xfe, 0xbf, /* x.<.m... */ +0x00, 0x02, 0xb0, 0x6c, 0xd7, 0x76, 0xa4, 0x30, /* ...l.v.0 */ +0x16, 0xf7, 0xb1, 0x51, 0x3d, 0x54 /* ...Q=T */ +}; + +TEST(PacketParseOuterL3, EtherVxlanGTPIPv4TCP) +{ + struct pkt_parser _pkt_gtp_u_over_vxlan_tls_1_handler; + _pkt_gtp_u_over_vxlan_tls_1_handler.expect_layer_type = LAYER_TYPE_L3; + _pkt_gtp_u_over_vxlan_tls_1_handler.nr_expect_results = 1; + _pkt_gtp_u_over_vxlan_tls_1_handler.nr_results = 0; + + complex_parser_ether(&_pkt_gtp_u_over_vxlan_tls_1_handler, _pkt_gtp_u_over_vxlan_tls_1); + EXPECT_EQ(_pkt_gtp_u_over_vxlan_tls_1_handler.nr_results, 1); + + struct pkt_parser_result * result = &_pkt_gtp_u_over_vxlan_tls_1_handler.results[0]; + EXPECT_EQ(result->this_layer_type, LAYER_TYPE_IPV4); + EXPECT_TRUE(result->data != NULL); + + TestCheckIPv4Addr(result, "10.10.0.16", "10.252.22.1"); +} + +TEST(PacketParseInnerL3, EtherVxlanGTPIPv4TCP) +{ + struct pkt_parser _pkt_gtp_u_over_vxlan_tls_1_handler; + _pkt_gtp_u_over_vxlan_tls_1_handler.expect_layer_type = LAYER_TYPE_L3; + _pkt_gtp_u_over_vxlan_tls_1_handler.nr_expect_results = 4; + _pkt_gtp_u_over_vxlan_tls_1_handler.nr_results = 0; + + complex_parser_ether(&_pkt_gtp_u_over_vxlan_tls_1_handler, _pkt_gtp_u_over_vxlan_tls_1); + EXPECT_EQ(_pkt_gtp_u_over_vxlan_tls_1_handler.nr_results, 3); + + struct pkt_parser_result * result = &_pkt_gtp_u_over_vxlan_tls_1_handler.results[0]; + EXPECT_EQ(result->this_layer_type, LAYER_TYPE_IPV4); + EXPECT_TRUE(result->data != NULL); + + TestCheckIPv4Addr(result, "10.10.0.16", "10.252.22.1"); + + result = &_pkt_gtp_u_over_vxlan_tls_1_handler.results[1]; + EXPECT_EQ(result->this_layer_type, LAYER_TYPE_IPV4); + EXPECT_TRUE(result->data != NULL); + + TestCheckIPv4Addr(result, "10.202.0.74", "10.254.142.4"); + + result = &_pkt_gtp_u_over_vxlan_tls_1_handler.results[2]; + EXPECT_EQ(result->this_layer_type, LAYER_TYPE_IPV4); + EXPECT_TRUE(result->data != NULL); + + TestCheckIPv4Addr(result, "216.58.209.132", "10.59.238.65"); +} + #if 0 TEST(DistributerInner4, EtherIPv4VxLANIPv4TCP) { |
