UlsoTest.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. /*
  2. * Copyright (c) 2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above
  10. * copyright notice, this list of conditions and the following
  11. * disclaimer in the documentation and/or other materials provided
  12. * with the distribution.
  13. * * Neither the name of The Linux Foundation nor the names of its
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  21. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  24. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  26. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  27. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * Changes from Qualcomm Innovation Center are provided under the following license:
  30. *
  31. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  32. *
  33. * Redistribution and use in source and binary forms, with or without
  34. * modification, are permitted (subject to the limitations in the
  35. * disclaimer below) provided that the following conditions are met:
  36. *
  37. * * Redistributions of source code must retain the above copyright
  38. * notice, this list of conditions and the following disclaimer.
  39. *
  40. * * Redistributions in binary form must reproduce the above
  41. * copyright notice, this list of conditions and the following
  42. * disclaimer in the documentation and/or other materials provided
  43. * with the distribution.
  44. *
  45. * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
  46. * contributors may be used to endorse or promote products derived
  47. * from this software without specific prior written permission.
  48. *
  49. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
  50. * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
  51. * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  52. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  53. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  54. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  55. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  56. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  57. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  58. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  59. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  60. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  61. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  62. */
  63. #include <stdio.h>
  64. #include <stdlib.h>
  65. #include <unistd.h>
  66. #include <string.h>
  67. #include <stdint.h>
  68. #include <cstring> // for memcpy
  69. #include "hton.h" // for htonl
  70. #include "InterfaceAbstraction.h"
  71. #include "Constants.h"
  72. #include "Logger.h"
  73. #include "TestsUtils.h"
  74. #include "UlsoTestFixture.h"
  75. #include "HeaderInsertion.h"
  76. #define ARRAY_SIZE(A) (sizeof(ArraySizeHelper(A)))
  77. template <typename T, size_t N>
  78. char (&ArraySizeHelper(T (&a)[N]))[N];
  79. using std::cout;
  80. using std::endl;
  81. using std::string;
  82. using I4 = IPv4Header;
  83. using I6 = IPv6Header;
  84. using UDPH = UdpHeader;
  85. using TCPH = TcpHeader;
  86. /* Packet modification function objects */
  87. template<typename PacketType> class PacketModifier {public:virtual void operator()(PacketType& p) const = 0; virtual ~PacketModifier(){}};
  88. template<typename PacketType> class NullPacketModifier: public PacketModifier<PacketType> {public:void operator()(PacketType& p) const override {}};
  89. template<typename PacketType> class ZeroChecksumPacketModifier: public PacketModifier<PacketType>
  90. {public:void operator()(PacketType& p) const override {p.mQmapHeader.setmZeroChecksum(1);}};
  91. template<typename PacketType> class OutOfBoundsPacketModifier: public PacketModifier<PacketType>
  92. {public:void operator()(PacketType& p) const override {p.mQmapHeader.setmIpIdCfg(0);p.setIpId(65530);}};
  93. template<typename Transport, typename Internet, const size_t* SegmentSizesArr, size_t SegmentSizesArrSize, const float* SegmentsNumsArr,
  94. size_t SegmentsNumsArrSize, typename Modifier = NullPacketModifier<UlsoPacket<Transport, Internet>>>
  95. class PacketsGeneratorClass {
  96. protected:
  97. using PacketType = UlsoPacket<Transport, Internet>;
  98. public:
  99. vector<PacketType> operator()(){
  100. vector<PacketType> outVec;
  101. Modifier m;
  102. for(size_t i=0; i<SegmentSizesArrSize; i++){
  103. for(size_t j=0; j<SegmentsNumsArrSize; j++){
  104. PacketType p(SegmentSizesArr[i], static_cast<size_t>(SegmentSizesArr[i] * SegmentsNumsArr[j]), true);
  105. m(p);
  106. outVec.emplace_back(p);
  107. }
  108. }
  109. return outVec;
  110. }
  111. };
  112. template<typename Transport, typename Internet, typename PacketsGenerator>
  113. class UlsoTest: public UlsoTestFixture {
  114. private:
  115. using PacketType = UlsoPacket<Transport, Internet>;
  116. bool singlePacketRun(PacketType& p){
  117. memset(m_sendBuf, 0, sizeof(m_sendBuf));
  118. size_t packetSize = p.asArray(m_sendBuf);
  119. size_t numSent = m_producer.SendData(m_sendBuf, packetSize);
  120. if(numSent == 0){
  121. return false;
  122. }
  123. vector<PacketType> segmentedPacketsVec = p.segment();
  124. for(auto& segmentedPacket: segmentedPacketsVec){
  125. memset(m_receiveBuf, 0, sizeof(m_receiveBuf));
  126. memset(m_segmentBuf, 0, sizeof(m_segmentBuf));
  127. packetSize = segmentedPacket.asArray(m_segmentBuf);
  128. size_t recievedBytes = m_consumer.ReceiveSingleDataChunk(m_receiveBuf, packetSize);
  129. if(packetSize != recievedBytes || memcmp(m_segmentBuf, m_receiveBuf, packetSize)){
  130. return fail(numSent, packetSize, recievedBytes);
  131. }
  132. }
  133. return clearPipe() == 0;
  134. }
  135. public:
  136. UlsoTest(const char* name){
  137. m_name = name;
  138. string title = string("ULSO Test");
  139. string packetStructure = string("Structure: ") + string ("QMAP + Ethernet 2 + ")
  140. + string(Internet().name()) + string(" ") + string(Transport().name());
  141. string testProcess = string(
  142. "1. Config IPA->APPS test pipe\n"
  143. "2. Generate a vector of ULSO packets\n"
  144. "3. For each packet in the packets vector\n"
  145. " a. Send the packet over the APPS->IPA pipe using ipa_tx_dp\n"
  146. " b. Segment the packet using the software simulation and store it in a segments vector\n"
  147. " c. For each segment in the segments vector in order\n"
  148. " # Receive a segment over IPA->APPS test pipe\n"
  149. " # Compare the received segment to the software simulated segment\n"
  150. "4. Clear the IPA->USB pipe and verify there were no bytes left in the pipe");
  151. m_description = string(title + "\n" + packetStructure + "\n" + testProcess + "\n").c_str();
  152. m_minIPAHwType = IPA_HW_v5_0;
  153. Register(*this);
  154. }
  155. virtual bool Run() override {
  156. vector<PacketType> packetsVec = PacketsGenerator()();
  157. for(auto& p: packetsVec){
  158. if(!singlePacketRun(p)){
  159. cout << "Failed With the following packet:" << endl;
  160. cout << p << endl;
  161. return false;
  162. }
  163. }
  164. return true;
  165. }
  166. };
  167. template<typename Transport, typename Internet, typename PacketsGenerator>
  168. class UlsoHPCTest: public UlsoTestFixture {
  169. private:
  170. using PacketType = UlsoPacket<Transport, Internet>;
  171. static constexpr size_t rndisHdrLen {44};
  172. HeaderInsertion m_HeaderInsertion;
  173. uint8_t mRndisHeader[rndisHdrLen] = {0};
  174. bool fail(size_t sendSize=0, size_t totalSegmentsSize=0, size_t recievedBytes=0){
  175. printBuf(m_sendBuf, sendSize, "Sent:");
  176. printBuf(m_receiveBuf, recievedBytes, string("Rceived ")
  177. + std::to_string(recievedBytes) + string(" Bytes:"));
  178. printBuf(m_segmentBuf, totalSegmentsSize, string("Expected to receive ")
  179. + std::to_string(totalSegmentsSize) + string(" Bytes:"));
  180. clearPipe();
  181. return false;
  182. }
  183. bool singlePacketRun(PacketType& p){
  184. cout << p << endl;
  185. memset(m_sendBuf, 0, sizeof(m_sendBuf));
  186. size_t sendSize = p.asArray(m_sendBuf);
  187. if(!m_producer.SendData(m_sendBuf, sendSize)){
  188. return fail(sendSize);
  189. }
  190. vector<PacketType> segmentedPacketsVec = p.segment();
  191. memset(m_segmentBuf, 0, sizeof(m_segmentBuf));
  192. uint8_t *segmentBufPtr = m_segmentBuf;
  193. size_t totalSegmentsSize = 0;
  194. vector<size_t> comparisionIntervalsSizesVec;
  195. for(auto& segmentedPacket: segmentedPacketsVec){
  196. memcpy(segmentBufPtr, mRndisHeader, sizeof(mRndisHeader));
  197. segmentBufPtr += sizeof(mRndisHeader);
  198. comparisionIntervalsSizesVec.emplace_back(sizeof(mRndisHeader));
  199. totalSegmentsSize += sizeof(mRndisHeader);
  200. size_t n = segmentedPacket.asArray(segmentBufPtr);
  201. segmentBufPtr += n;
  202. totalSegmentsSize += n;
  203. comparisionIntervalsSizesVec.emplace_back(n);
  204. }
  205. memset(m_receiveBuf, 0, sizeof(m_receiveBuf));
  206. size_t recievedBytes = m_consumer.ReceiveSingleDataChunk(m_receiveBuf, totalSegmentsSize);
  207. if(totalSegmentsSize != recievedBytes){
  208. return fail(sendSize, totalSegmentsSize, recievedBytes);
  209. }
  210. segmentBufPtr = m_segmentBuf;
  211. uint8_t *recieveBufPtr = m_receiveBuf;
  212. while(!comparisionIntervalsSizesVec.empty()){
  213. size_t skipSize = comparisionIntervalsSizesVec.front();
  214. recieveBufPtr += skipSize;
  215. segmentBufPtr += skipSize;
  216. comparisionIntervalsSizesVec.erase(comparisionIntervalsSizesVec.begin());
  217. if(comparisionIntervalsSizesVec.empty()){
  218. return fail(sendSize, totalSegmentsSize, recievedBytes);
  219. }
  220. size_t compareSize = comparisionIntervalsSizesVec.front();
  221. if(memcmp(segmentBufPtr, recieveBufPtr, compareSize)){
  222. return fail(sendSize, totalSegmentsSize, recievedBytes);
  223. }
  224. segmentBufPtr += compareSize;
  225. recieveBufPtr += compareSize;
  226. comparisionIntervalsSizesVec.erase(comparisionIntervalsSizesVec.begin());
  227. }
  228. if(clearPipe()){
  229. return fail(sendSize, totalSegmentsSize, recievedBytes);
  230. }
  231. return true;
  232. }
  233. protected:
  234. virtual void configFromEp(struct test_ipa_ep_cfg *ep_cfg){
  235. ep_cfg->hdr.hdr_len = ETH_HLEN + rndisHdrLen;
  236. ep_cfg->hdr.hdr_additional_const_len = ETH_HLEN;
  237. ep_cfg->hdr.hdr_ofst_pkt_size_valid = true;
  238. ep_cfg->hdr.hdr_ofst_pkt_size = 3 * sizeof(uint32_t);
  239. ep_cfg->hdr_ext.hdr_total_len_or_pad_offset = sizeof(uint32_t);
  240. ep_cfg->hdr_ext.hdr_total_len_or_pad = IPA_HDR_TOTAL_LEN;
  241. ep_cfg->hdr_ext.hdr_total_len_or_pad_valid = true;
  242. ep_cfg->hdr_ext.hdr_little_endian = true;
  243. ep_cfg->aggr.aggr_en = IPA_ENABLE_AGGR;
  244. ep_cfg->aggr.aggr = IPA_GENERIC;
  245. ep_cfg->aggr.aggr_byte_limit = 4;
  246. ep_cfg->aggr.aggr_time_limit = 1000;
  247. }
  248. public:
  249. UlsoHPCTest(const char* name, const char* description){
  250. m_name = name;
  251. m_description = description;
  252. m_minIPAHwType = IPA_HW_v5_0;
  253. for(size_t i=0; i<rndisHdrLen; i++){
  254. mRndisHeader[i] = i;
  255. }
  256. Register(*this);
  257. }
  258. virtual bool Run() override {
  259. string headerName("rndis");
  260. if(!m_HeaderInsertion.addHeaderHpc(headerName, mRndisHeader, rndisHdrLen, false, IPA_CLIENT_TEST_CONS)){
  261. LOG_MSG_ERROR("!m_HeaderInsertion.addHeaderHpc(headerName, mRndisHeader, 44, false, true) Failed.");
  262. return false;
  263. }
  264. vector<PacketType> packetsVec = PacketsGenerator()();
  265. for(auto& p: packetsVec){
  266. if(!singlePacketRun(p)){
  267. return false;
  268. }
  269. }
  270. if(!m_HeaderInsertion.DeleteHeader(headerName)){
  271. LOG_MSG_ERROR("Delete rndis header failed");
  272. return false;
  273. }
  274. return true;
  275. }
  276. };
  277. /* Tests Macros */
  278. #define PACKETS_GEN_MODIFY(T, I, a, b, m) PacketsGeneratorClass<T, I, a, ARRAY_SIZE(a), b, ARRAY_SIZE(b), m<UlsoPacket<T, I>>>
  279. #define PACKETS_GEN(T, I, a, b) PACKETS_GEN_MODIFY(T, I, a, b, NullPacketModifier)//todo: change macro parameters to meaningfull names
  280. ////////////////////////////////////////////////////////////////////////////////
  281. /////////// Simple Single Packet Tests //////////////
  282. ////////////////////////////////////////////////////////////////////////////////
  283. /*
  284. * Send a single packet and compare the received segments to the software simulation
  285. */
  286. constexpr size_t segmentSizes1[] = {20};
  287. constexpr float segmentsNum1[] = {5};
  288. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes1, segmentsNum1)> ulsoTest0 {"Single Packet: IPV4 UDP"};
  289. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes1, segmentsNum1)> ulsoTest1 {"Single Packet: IPV4 TCP"};
  290. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes1, segmentsNum1)> ulsoTest2 {"Single Packet: IPV6 UDP"};
  291. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes1, segmentsNum1)> ulsoTest3 {"Single Packet: IPV6 TCP"};
  292. ////////////////////////////////////////////////////////////////////////////////
  293. /////////// Segmentation & Non-Segmentation mix //////////////
  294. ////////////////////////////////////////////////////////////////////////////////
  295. /*
  296. * Send a sequence of [large, small, large, small, ...] packets and compare the received segments to the software simulation
  297. */
  298. constexpr size_t segmentSizes2[] = {10, 50, 100, 500, 1460};
  299. constexpr float segmentsNum2[] = {1, 4};
  300. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes2, segmentsNum2)> ulsoTest10 {"Segmentation No Segmentation IPV4 UDP"};
  301. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes2, segmentsNum2)> ulsoTest11 {"Segmentation No Segmentation IPV4 TCP"};
  302. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes2, segmentsNum2)> ulsoTest12 {"Segmentation No Segmentation IPV6 UDP"};
  303. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes2, segmentsNum2)> ulsoTest13 {"Segmentation No Segmentation IPV6 TCP"};
  304. ////////////////////////////////////////////////////////////////////////////////
  305. //////////////////// Zero Checksum ////////////////////
  306. ////////////////////////////////////////////////////////////////////////////////
  307. /*
  308. * Send a sequence of large packets with zero checksum=1 and compare the received segments to the software simulation
  309. */
  310. constexpr size_t segmentSizes3[] = {10, 50, 100, 500, 1460};
  311. constexpr float numSegments3[] = {4};
  312. static UlsoTest<UDPH, I4, PACKETS_GEN_MODIFY(UDPH, I4, segmentSizes3, numSegments3, ZeroChecksumPacketModifier)>
  313. ulsoTest20 {"Zero Checksum IPV4 UDP"};
  314. static UlsoTest<TCPH, I4, PACKETS_GEN_MODIFY(TCPH, I4, segmentSizes3, numSegments3, ZeroChecksumPacketModifier)>
  315. ulsoTest21 {"Zero Checksum IPV4 TCP"};
  316. static UlsoTest<UDPH, I6, PACKETS_GEN_MODIFY(UDPH, I6, segmentSizes3, numSegments3, ZeroChecksumPacketModifier)>
  317. ulsoTest22 {"Zero Checksum IPV6 UDP"};
  318. static UlsoTest<TCPH, I6, PACKETS_GEN_MODIFY(TCPH, I6, segmentSizes3, numSegments3, ZeroChecksumPacketModifier)>
  319. ulsoTest23 {"Zero Checksum IPV6 TCP"};
  320. ////////////////////////////////////////////////////////////////////////////////
  321. ///////// Segment Size Greater Than Payload Size /////////////////
  322. ////////////////////////////////////////////////////////////////////////////////
  323. /*
  324. * Send a single packet with payload size and MSS matching an edge case and edge case and compare the received segments to the software simulation.
  325. * Edge cases:
  326. * 1. payload size < MSS ==> No segmentation
  327. * 2. payload size == MSS - epsilon ==> No segmentation
  328. * 3. payload size == MSS ==> Segmentation
  329. */
  330. /* Segment Size = 100 Payload Size = 50 */
  331. constexpr size_t segmentSizes4[] = {100};
  332. constexpr float numSegments4[] = {0.5};
  333. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes4, numSegments4)> ulsoTest30 {"Payload Smaller Than MSS IPV4 UDP"};
  334. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes4, numSegments4)> ulsoTest31 {"Payload Smaller Than MSS IPV4 TCP"};
  335. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes4, numSegments4)> ulsoTest32 {"Payload Smaller Than MSS IPV6 UDP"};
  336. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes4, numSegments4)> ulsoTest33 {"Payload Smaller Than MSS IPV6 TCP"};
  337. /* Segment Size = 100 Payload Size = 99 */
  338. constexpr size_t segmentSizes5[] = {100};
  339. constexpr float numSegments5[] = {0.99};
  340. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes5, numSegments5)> ulsoTest40 {"Payload slightly Smaller Than MSS IPV4 UDP"};
  341. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes5, numSegments5)> ulsoTest41 {"Payload slightly Smaller Than MSS IPV4 TCP"};
  342. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes5, numSegments5)> ulsoTest42 {"Payload slightly Smaller Than MSS IPV6 UDP"};
  343. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes5, numSegments5)> ulsoTest43 {"Payload slightly Smaller Than MSS IPV6 TCP"};
  344. /* Segment Size = 20 Payload Size = 20 */
  345. constexpr size_t segmentSizes6[] = {100};
  346. constexpr float numSegments6[] = {1};
  347. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes6, numSegments6)> ulsoTest50 {"Payload Equals MSS IPV4 UDP"};
  348. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes6, numSegments6)> ulsoTest51 {"Payload Equals MSS IPV4 TCP"};
  349. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes6, numSegments6)> ulsoTest52 {"Payload Equals MSS IPV6 UDP"};
  350. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes6, numSegments6)> ulsoTest53 {"Payload Equals MSS IPV6 TCP"};
  351. ////////////////////////////////////////////////////////////////////////////////
  352. ////////////// Valid Segment Sizes /////////////////////
  353. ////////////////////////////////////////////////////////////////////////////////
  354. /*
  355. * Send a sequence of packets with different valid sizes and compare the received segments to the software simulation
  356. */
  357. constexpr size_t segmentSizes7[] = {1460, 1220, 512, 1};
  358. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes7, segmentsNum1)> ulsoTest60 {"Valid Segment Sizes IPV4 UDP"};
  359. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes7, segmentsNum1)> ulsoTest61 {"Valid Segment Sizes IPV4 TCP"};
  360. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes7, segmentsNum1)> ulsoTest62 {"Valid Segment Sizes IPV6 UDP"};
  361. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes7, segmentsNum1)> ulsoTest63 {"Valid Segment Sizes IPV6 TCP"};
  362. ////////////////////////////////////////////////////////////////////////////////
  363. //////////////// Big Segment Sizes /////////////////////
  364. ////////////////////////////////////////////////////////////////////////////////
  365. /*
  366. * Send a sequence of very large packets and compare the received segments to the software simulation
  367. */
  368. constexpr size_t segmentSizes8[] = {2000, 3000, 4000, 5000, 6000, 10000};
  369. static UlsoTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes8, segmentsNum1)> ulsoTest70 {"Big Segment Sizes IPV4 UDP"};
  370. static UlsoTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes8, segmentsNum1)> ulsoTest71 {"Big Segment Sizes IPV4 TCP"};
  371. static UlsoTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes8, segmentsNum1)> ulsoTest72 {"Big Segment Sizes IPV6 UDP"};
  372. static UlsoTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes8, segmentsNum1)> ulsoTest73 {"Big Segment Sizes IPV6 TCP"};
  373. ////////////////////////////////////////////////////////////////////////////////
  374. //////////////// IP ID wrapp around min/max bounds ///////////////
  375. ////////////////////////////////////////////////////////////////////////////////
  376. /*
  377. * Send a single packet such that:
  378. * IPID + #segments < MAX IPID
  379. * and compare the received segments to the software simulation
  380. */
  381. constexpr size_t segmentSizes9[] = {2000};
  382. constexpr float numSegments9[] = {10};
  383. static UlsoTest<UDPH, I4, PACKETS_GEN_MODIFY(UDPH, I4, segmentSizes9, numSegments9, OutOfBoundsPacketModifier)> ulsoTest80 {"IPID CFG IPV4 UDP"};
  384. static UlsoTest<TCPH, I4, PACKETS_GEN_MODIFY(TCPH, I4, segmentSizes9, numSegments9, OutOfBoundsPacketModifier)> ulsoTest81 {"IPID CFG IPV4 UDP"};
  385. ////////////////////////////////////////////////////////////////////////////////
  386. //////////////// HPC RNDIS Header Insertion //////////////////////
  387. ////////////////////////////////////////////////////////////////////////////////
  388. static UlsoHPCTest<UDPH, I4, PACKETS_GEN(UDPH, I4, segmentSizes1, segmentsNum1)> Ipv4UdpHpcRndisTest {"Ipv4UdpHpcRndisTest", "IPv4 + UDP"};
  389. static UlsoHPCTest<TCPH, I4, PACKETS_GEN(TCPH, I4, segmentSizes1, segmentsNum1)> Ipv4TcpHpcRndisTest {"Ipv4TcpHpcRndisTest", "IPv4 + TCP"};
  390. static UlsoHPCTest<UDPH, I6, PACKETS_GEN(UDPH, I6, segmentSizes1, segmentsNum1)> Ipv6UdpHpcRndisTest {"Ipv6UdpHpcRndisTest", "IPv6 + UDP"};
  391. static UlsoHPCTest<TCPH, I6, PACKETS_GEN(TCPH, I6, segmentSizes1, segmentsNum1)> Ipv6TcpHpcRndisTest {"Ipv6TcpHpcRndisTest", "IPv6 + TCP"};