test_packno_len.c revision f07b3eae
106b2a236SDmitri Tikhonov/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov#include <assert.h> 350aadb33SDmitri Tikhonov#include <stdio.h> 450aadb33SDmitri Tikhonov#include <stdlib.h> 550aadb33SDmitri Tikhonov#include <string.h> 650aadb33SDmitri Tikhonov#include <sys/queue.h> 7461e84d8SAmol Deshpande#ifndef WIN32 850aadb33SDmitri Tikhonov#include <sys/time.h> 9461e84d8SAmol Deshpande#endif 1050aadb33SDmitri Tikhonov 1150aadb33SDmitri Tikhonov#include "lsquic.h" 1250aadb33SDmitri Tikhonov#include "lsquic_types.h" 1350aadb33SDmitri Tikhonov#include "lsquic_packet_common.h" 1450aadb33SDmitri Tikhonov#include "lsquic_parse.h" 1550aadb33SDmitri Tikhonov 1650aadb33SDmitri Tikhonov 17f07b3eaeSTyler Young//static const struct parse_funcs *const pf = select_pf_by_ver(LSQVER_043); // will not work on MSVC 18f07b3eaeSTyler Young#define pf ((const struct parse_funcs *const)select_pf_by_ver(LSQVER_043)) 19c7d81ce1SDmitri Tikhonov 20c7d81ce1SDmitri Tikhonov 2150aadb33SDmitri Tikhonovstruct packno_bits_test { 2250aadb33SDmitri Tikhonov int pbt_lineno; 2350aadb33SDmitri Tikhonov /* Inputs: */ 245392f7a3SLiteSpeed Tech lsquic_packno_t pbt_packno, 2550aadb33SDmitri Tikhonov pbt_least_unacked; 2650aadb33SDmitri Tikhonov uint64_t pbt_n_in_flight; 2750aadb33SDmitri Tikhonov /* Output: */ 28c7d81ce1SDmitri Tikhonov enum packno_bits pbt_packno_bits; 2950aadb33SDmitri Tikhonov}; 3050aadb33SDmitri Tikhonov 3150aadb33SDmitri Tikhonov 3250aadb33SDmitri Tikhonovstatic const struct packno_bits_test pb_tests[] = { 3350aadb33SDmitri Tikhonov 3450aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 3550aadb33SDmitri Tikhonov .pbt_packno = 1, 3650aadb33SDmitri Tikhonov .pbt_least_unacked = 0, 3750aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 38c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_1, 3950aadb33SDmitri Tikhonov }, 4050aadb33SDmitri Tikhonov 4150aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 4250aadb33SDmitri Tikhonov .pbt_packno = 101, 4350aadb33SDmitri Tikhonov .pbt_least_unacked = 100, 4450aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 45c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_1, 4650aadb33SDmitri Tikhonov }, 4750aadb33SDmitri Tikhonov 4850aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 4950aadb33SDmitri Tikhonov .pbt_packno = 10001, 5050aadb33SDmitri Tikhonov .pbt_least_unacked = 10000, 5150aadb33SDmitri Tikhonov .pbt_n_in_flight = 1 << 6, 52c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_1, 5350aadb33SDmitri Tikhonov }, 5450aadb33SDmitri Tikhonov 5550aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 5650aadb33SDmitri Tikhonov .pbt_packno = 10001, 5750aadb33SDmitri Tikhonov .pbt_least_unacked = 10000, 5850aadb33SDmitri Tikhonov .pbt_n_in_flight = (1 << 6) + 1, 59c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 6050aadb33SDmitri Tikhonov }, 6150aadb33SDmitri Tikhonov 6250aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 6350aadb33SDmitri Tikhonov .pbt_packno = (1 << 16) + 1, 6450aadb33SDmitri Tikhonov .pbt_least_unacked = 1 << 16, 6550aadb33SDmitri Tikhonov .pbt_n_in_flight = 1 << 14, 66c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 6750aadb33SDmitri Tikhonov }, 6850aadb33SDmitri Tikhonov 6950aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 7050aadb33SDmitri Tikhonov .pbt_packno = (1 << 16) + 1, 7150aadb33SDmitri Tikhonov .pbt_least_unacked = 1 << 16, 7250aadb33SDmitri Tikhonov .pbt_n_in_flight = (1 << 14) + 1, 73c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_4, 7450aadb33SDmitri Tikhonov }, 7550aadb33SDmitri Tikhonov 7650aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 7750aadb33SDmitri Tikhonov .pbt_packno = (1ULL << 33) + 1, 7850aadb33SDmitri Tikhonov .pbt_least_unacked = 1ULL << 33, 7950aadb33SDmitri Tikhonov .pbt_n_in_flight = 1ULL << 30, 80c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_4, 8150aadb33SDmitri Tikhonov }, 8250aadb33SDmitri Tikhonov 8350aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 8450aadb33SDmitri Tikhonov .pbt_packno = (1ULL << 33) + 1, 8550aadb33SDmitri Tikhonov .pbt_least_unacked = 1ULL << 33, 8650aadb33SDmitri Tikhonov .pbt_n_in_flight = (1ULL << 30) + 1, 87c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_6, 8850aadb33SDmitri Tikhonov }, 8950aadb33SDmitri Tikhonov 9050aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 9150aadb33SDmitri Tikhonov .pbt_packno = 100, 9250aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 9350aadb33SDmitri Tikhonov .pbt_n_in_flight = 3, 94c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 9550aadb33SDmitri Tikhonov }, 9650aadb33SDmitri Tikhonov 9750aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 9850aadb33SDmitri Tikhonov .pbt_packno = 100, 9950aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 10050aadb33SDmitri Tikhonov .pbt_n_in_flight = 99, 101c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 10250aadb33SDmitri Tikhonov }, 10350aadb33SDmitri Tikhonov 10450aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 10550aadb33SDmitri Tikhonov .pbt_packno = 1 + (1 << 6), 10650aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 10750aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 108c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_1, 10950aadb33SDmitri Tikhonov }, 11050aadb33SDmitri Tikhonov 11150aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 11250aadb33SDmitri Tikhonov .pbt_packno = 1 + (1 << 6) + 1, 11350aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 11450aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 115c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 11650aadb33SDmitri Tikhonov }, 11750aadb33SDmitri Tikhonov 11850aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 11950aadb33SDmitri Tikhonov .pbt_packno = (1 << 20) + (1 << 14), 12050aadb33SDmitri Tikhonov .pbt_least_unacked = 1 << 20, 12150aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 122c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 12350aadb33SDmitri Tikhonov }, 12450aadb33SDmitri Tikhonov 12550aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 12650aadb33SDmitri Tikhonov .pbt_packno = (1 << 20) + (1 << 14) + 1, 12750aadb33SDmitri Tikhonov .pbt_least_unacked = 1 << 20, 12850aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 129c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_4, 13050aadb33SDmitri Tikhonov }, 13150aadb33SDmitri Tikhonov 13250aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 13350aadb33SDmitri Tikhonov .pbt_packno = (1 << 20) + (1ULL << 30), 13450aadb33SDmitri Tikhonov .pbt_least_unacked = 1 << 20, 13550aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 136c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_4, 13750aadb33SDmitri Tikhonov }, 13850aadb33SDmitri Tikhonov 13950aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 14050aadb33SDmitri Tikhonov .pbt_packno = (1 << 20) + (1ULL << 30) + 1, 14150aadb33SDmitri Tikhonov .pbt_least_unacked = 1 << 20, 14250aadb33SDmitri Tikhonov .pbt_n_in_flight = 0, 143c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_6, 14450aadb33SDmitri Tikhonov }, 14550aadb33SDmitri Tikhonov 14650aadb33SDmitri Tikhonov /* Tests from Chrome: */ 14750aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 14850aadb33SDmitri Tikhonov .pbt_packno = 65, 14950aadb33SDmitri Tikhonov .pbt_least_unacked = 2, 15050aadb33SDmitri Tikhonov .pbt_n_in_flight = 7, 151c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_1, 15250aadb33SDmitri Tikhonov }, 15350aadb33SDmitri Tikhonov 15450aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 15550aadb33SDmitri Tikhonov .pbt_packno = 64 * 256 - 1, 15650aadb33SDmitri Tikhonov .pbt_least_unacked = 2, 15750aadb33SDmitri Tikhonov .pbt_n_in_flight = 7, 158c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 15950aadb33SDmitri Tikhonov }, 16050aadb33SDmitri Tikhonov 16150aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 16250aadb33SDmitri Tikhonov .pbt_packno = 64 * 256 * 256 - 1, 16350aadb33SDmitri Tikhonov .pbt_least_unacked = 2, 16450aadb33SDmitri Tikhonov .pbt_n_in_flight = 7, 165c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_4, 16650aadb33SDmitri Tikhonov }, 16750aadb33SDmitri Tikhonov 16850aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 16950aadb33SDmitri Tikhonov .pbt_packno = 64ULL * 256 * 256 * 256 * 256 - 1, 17050aadb33SDmitri Tikhonov .pbt_least_unacked = 2, 17150aadb33SDmitri Tikhonov .pbt_n_in_flight = 7, 172c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_6, 17350aadb33SDmitri Tikhonov }, 17450aadb33SDmitri Tikhonov 17550aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 17650aadb33SDmitri Tikhonov .pbt_packno = 2, 17750aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 17850aadb33SDmitri Tikhonov .pbt_n_in_flight = 7, 179c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_1, 18050aadb33SDmitri Tikhonov }, 18150aadb33SDmitri Tikhonov 18250aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 18350aadb33SDmitri Tikhonov .pbt_packno = 2, 18450aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 18550aadb33SDmitri Tikhonov .pbt_n_in_flight = 1896, 186c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_2, 18750aadb33SDmitri Tikhonov }, 18850aadb33SDmitri Tikhonov 18950aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 19050aadb33SDmitri Tikhonov .pbt_packno = 2, 19150aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 19250aadb33SDmitri Tikhonov .pbt_n_in_flight = 48545, 193c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_4, 19450aadb33SDmitri Tikhonov }, 19550aadb33SDmitri Tikhonov 19650aadb33SDmitri Tikhonov { .pbt_lineno = __LINE__, 19750aadb33SDmitri Tikhonov .pbt_packno = 2, 19850aadb33SDmitri Tikhonov .pbt_least_unacked = 1, 199e0197994SDmitri Tikhonov .pbt_n_in_flight = 3181457256ULL, 200c7d81ce1SDmitri Tikhonov .pbt_packno_bits = GQUIC_PACKNO_LEN_6, 20150aadb33SDmitri Tikhonov }, 20250aadb33SDmitri Tikhonov 20350aadb33SDmitri Tikhonov}; 20450aadb33SDmitri Tikhonov 20550aadb33SDmitri Tikhonov 20650aadb33SDmitri Tikhonovstatic void 20750aadb33SDmitri Tikhonovrun_pbt (int i) 20850aadb33SDmitri Tikhonov{ 20950aadb33SDmitri Tikhonov const struct packno_bits_test *const pbt = &pb_tests[i]; 210c7d81ce1SDmitri Tikhonov enum packno_bits packno_bits = pf->pf_calc_packno_bits(pbt->pbt_packno, 21150aadb33SDmitri Tikhonov pbt->pbt_least_unacked, pbt->pbt_n_in_flight); 21250aadb33SDmitri Tikhonov assert(packno_bits == pbt->pbt_packno_bits); 213c7d81ce1SDmitri Tikhonov unsigned packet_len = pf->pf_packno_bits2len(packno_bits); 21450aadb33SDmitri Tikhonov /* Now see if we can restore it back: */ 21550aadb33SDmitri Tikhonov lsquic_packno_t cur_packno = pbt->pbt_packno & 216c7d81ce1SDmitri Tikhonov ((1ULL << (packet_len << 3)) - 1); 217a5fa05f9SDmitri Tikhonov lsquic_packno_t orig_packno = lsquic_restore_packno(cur_packno, packet_len, 21850aadb33SDmitri Tikhonov pbt->pbt_least_unacked); 21950aadb33SDmitri Tikhonov assert(orig_packno == pbt->pbt_packno); 22050aadb33SDmitri Tikhonov} 22150aadb33SDmitri Tikhonov 22250aadb33SDmitri Tikhonov 223a5fa05f9SDmitri Tikhonovstruct lsquic_restore_packno_test { 22450aadb33SDmitri Tikhonov int rpt_lineno; 22550aadb33SDmitri Tikhonov /* Input */ 226c7d81ce1SDmitri Tikhonov enum packno_bits rpt_packno_bits; 22750aadb33SDmitri Tikhonov lsquic_packno_t rpt_cur_packno; 22850aadb33SDmitri Tikhonov lsquic_packno_t rpt_max_packno; 22950aadb33SDmitri Tikhonov /* Output */ 23050aadb33SDmitri Tikhonov lsquic_packno_t rpt_orig_packno; 23150aadb33SDmitri Tikhonov}; 23250aadb33SDmitri Tikhonov 233a5fa05f9SDmitri Tikhonovstatic const struct lsquic_restore_packno_test rp_tests[] = 23450aadb33SDmitri Tikhonov{ 23550aadb33SDmitri Tikhonov 23650aadb33SDmitri Tikhonov { .rpt_lineno = __LINE__, 23750aadb33SDmitri Tikhonov .rpt_max_packno = 0, 23850aadb33SDmitri Tikhonov .rpt_cur_packno = 1, 239c7d81ce1SDmitri Tikhonov .rpt_packno_bits = GQUIC_PACKNO_LEN_1, 24050aadb33SDmitri Tikhonov .rpt_orig_packno = 1, 24150aadb33SDmitri Tikhonov }, 24250aadb33SDmitri Tikhonov 24350aadb33SDmitri Tikhonov}; 24450aadb33SDmitri Tikhonov 24550aadb33SDmitri Tikhonov 24650aadb33SDmitri Tikhonovstatic void 24750aadb33SDmitri Tikhonovrun_rpt (int i) 24850aadb33SDmitri Tikhonov{ 249a5fa05f9SDmitri Tikhonov const struct lsquic_restore_packno_test *const rpt = &rp_tests[i]; 250c7d81ce1SDmitri Tikhonov unsigned packet_len = pf->pf_packno_bits2len(rpt->rpt_packno_bits); 251a5fa05f9SDmitri Tikhonov lsquic_packno_t orig_packno = lsquic_restore_packno(rpt->rpt_cur_packno, 252c7d81ce1SDmitri Tikhonov packet_len, rpt->rpt_max_packno); 25350aadb33SDmitri Tikhonov assert(orig_packno == rpt->rpt_orig_packno); 25450aadb33SDmitri Tikhonov} 25550aadb33SDmitri Tikhonov 25650aadb33SDmitri Tikhonov 25750aadb33SDmitri Tikhonovstatic void 258c7d81ce1SDmitri Tikhonovtest_restore (enum packno_bits bits) 25950aadb33SDmitri Tikhonov{ 26050aadb33SDmitri Tikhonov unsigned len, n; 26150aadb33SDmitri Tikhonov enum { OP_PLUS, OP_MINUS, N_OPS } op; 26250aadb33SDmitri Tikhonov uint64_t epoch, epoch_delta; 263b93f59beSBob Perper lsquic_packno_t orig_packno, cur_packno, restored_packno; 26450aadb33SDmitri Tikhonov 265b93f59beSBob Perper#ifdef WIN32 266b93f59beSBob Perper orig_packno = 0; 267b93f59beSBob Perper#endif 268c7d81ce1SDmitri Tikhonov len = pf->pf_packno_bits2len(bits); 26950aadb33SDmitri Tikhonov epoch_delta = 1ULL << (len << 3); 27050aadb33SDmitri Tikhonov epoch = epoch_delta * 11 /* Just some number */; 27150aadb33SDmitri Tikhonov 27250aadb33SDmitri Tikhonov /* Test current epoch: */ 27350aadb33SDmitri Tikhonov for (op = 0; op < N_OPS; ++op) 27450aadb33SDmitri Tikhonov for (n = 0; n < 5; ++n) 27550aadb33SDmitri Tikhonov { 27650aadb33SDmitri Tikhonov /* Test at the ends of the epoch */ 27750aadb33SDmitri Tikhonov if (op == OP_MINUS) 27850aadb33SDmitri Tikhonov orig_packno = epoch - epoch_delta / 2 + n; 27950aadb33SDmitri Tikhonov else if (op == OP_PLUS) 28050aadb33SDmitri Tikhonov orig_packno = epoch + epoch_delta / 2 - n - 1; 28150aadb33SDmitri Tikhonov else 28250aadb33SDmitri Tikhonov assert(0); 28350aadb33SDmitri Tikhonov cur_packno = orig_packno & (epoch_delta - 1); 284a5fa05f9SDmitri Tikhonov restored_packno = lsquic_restore_packno(cur_packno, len, epoch); 28550aadb33SDmitri Tikhonov assert(orig_packno == restored_packno); 28650aadb33SDmitri Tikhonov /* Test in the middle of the epoch */ 28750aadb33SDmitri Tikhonov if (op == OP_MINUS) 28850aadb33SDmitri Tikhonov orig_packno = epoch - n; 28950aadb33SDmitri Tikhonov else 29050aadb33SDmitri Tikhonov orig_packno = epoch + n; 29150aadb33SDmitri Tikhonov cur_packno = orig_packno & (epoch_delta - 1); 292a5fa05f9SDmitri Tikhonov restored_packno = lsquic_restore_packno(cur_packno, len, epoch); 29350aadb33SDmitri Tikhonov assert(orig_packno == restored_packno); 29450aadb33SDmitri Tikhonov } 29550aadb33SDmitri Tikhonov 29650aadb33SDmitri Tikhonov /* Test previous epoch (max is to the left) */ 29750aadb33SDmitri Tikhonov for (n = 0; n < 5; ++n) 29850aadb33SDmitri Tikhonov { 29950aadb33SDmitri Tikhonov /* Test at the end of the epoch */ 30050aadb33SDmitri Tikhonov orig_packno = epoch + epoch_delta / 2 - n - 1; 30150aadb33SDmitri Tikhonov cur_packno = orig_packno & (epoch_delta - 1); 302a5fa05f9SDmitri Tikhonov restored_packno = lsquic_restore_packno(cur_packno, len, epoch - epoch_delta * 3 / 4); 30350aadb33SDmitri Tikhonov assert(orig_packno == restored_packno + epoch_delta); 30450aadb33SDmitri Tikhonov /* Test in the middle of the epoch */ 30550aadb33SDmitri Tikhonov orig_packno = epoch + 2 - n; 30650aadb33SDmitri Tikhonov cur_packno = orig_packno & (epoch_delta - 1); 307a5fa05f9SDmitri Tikhonov restored_packno = lsquic_restore_packno(cur_packno, len, epoch - epoch_delta * 3 / 4); 30850aadb33SDmitri Tikhonov assert(orig_packno == restored_packno + epoch_delta); 30950aadb33SDmitri Tikhonov } 31050aadb33SDmitri Tikhonov 31150aadb33SDmitri Tikhonov /* Test previous epoch (max is to the right) */ 31250aadb33SDmitri Tikhonov for (n = 0; n < 5; ++n) 31350aadb33SDmitri Tikhonov { 31450aadb33SDmitri Tikhonov /* Test at the end of the epoch */ 31550aadb33SDmitri Tikhonov orig_packno = epoch - epoch_delta / 2 + n; 31650aadb33SDmitri Tikhonov cur_packno = orig_packno & (epoch_delta - 1); 317a5fa05f9SDmitri Tikhonov restored_packno = lsquic_restore_packno(cur_packno, len, epoch + epoch_delta * 3 / 4); 31850aadb33SDmitri Tikhonov assert(orig_packno == restored_packno - epoch_delta); 31950aadb33SDmitri Tikhonov /* Test in the middle of the epoch */ 32050aadb33SDmitri Tikhonov orig_packno = epoch + 2 - n; 32150aadb33SDmitri Tikhonov cur_packno = orig_packno & (epoch_delta - 1); 322a5fa05f9SDmitri Tikhonov restored_packno = lsquic_restore_packno(cur_packno, len, epoch + epoch_delta * 3 / 4); 32350aadb33SDmitri Tikhonov assert(orig_packno == restored_packno - epoch_delta); 32450aadb33SDmitri Tikhonov } 32550aadb33SDmitri Tikhonov 32650aadb33SDmitri Tikhonov} 32750aadb33SDmitri Tikhonov 32850aadb33SDmitri Tikhonov 32950aadb33SDmitri Tikhonovint 33050aadb33SDmitri Tikhonovmain (void) 33150aadb33SDmitri Tikhonov{ 33250aadb33SDmitri Tikhonov unsigned i; 33350aadb33SDmitri Tikhonov for (i = 0; i < sizeof(pb_tests) / sizeof(pb_tests[0]); ++i) 33450aadb33SDmitri Tikhonov run_pbt(i); 33550aadb33SDmitri Tikhonov for (i = 0; i < sizeof(rp_tests) / sizeof(rp_tests[0]); ++i) 33650aadb33SDmitri Tikhonov run_rpt(i); 337c7d81ce1SDmitri Tikhonov test_restore(GQUIC_PACKNO_LEN_1); 338c7d81ce1SDmitri Tikhonov test_restore(GQUIC_PACKNO_LEN_2); 339c7d81ce1SDmitri Tikhonov test_restore(GQUIC_PACKNO_LEN_4); 340c7d81ce1SDmitri Tikhonov test_restore(GQUIC_PACKNO_LEN_6); 34150aadb33SDmitri Tikhonov return 0; 34250aadb33SDmitri Tikhonov} 343