tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

conflux_st.h (5014B)


      1 /* Copyright (c) 2019-2021, The Tor Project, Inc. */
      2 /* See LICENSE for licensing information */
      3 
      4 /**
      5 * \file conflux_st.h
      6 * \brief Structure definitions for conflux multipath
      7 **/
      8 
      9 #ifndef CONFLUX_ST_H
     10 #define CONFLUX_ST_H
     11 
     12 #include "core/or/circuit_st.h"
     13 #include "core/or/cell_st.h"
     14 #include "lib/defs/digest_sizes.h"
     15 
     16 /**
     17 * Specifies which conflux alg is in use.
     18 */
     19 typedef enum {
     20 CONFLUX_ALG_MINRTT = 0,
     21 CONFLUX_ALG_LOWRTT = 1,
     22 CONFLUX_ALG_CWNDRTT = 2,
     23 } conflux_alg_t;
     24 
     25 /** XXX: Cached consensus params+scheduling alg */
     26 struct conflux_params_t {
     27  conflux_alg_t alg;
     28 };
     29 
     30 struct conflux_leg_t {
     31  /**
     32   * For computing ooo_q insertion sequence numbers: Highest absolute
     33   * sequence number received on each leg, before delivery.
     34   *
     35   * As a receiver, this allows us to compute the absolute sequence number
     36   * of a cell for delivery or insertion into the ooo_q. When a SWITCH cell
     37   * is received on a leg, the absolute sequence number of that cell is
     38   * the relative sequence number in that cell, plus the absolute sequence
     39   * number of that leg from this array. The leg's sequence number
     40   * is then updated to this value immediately.
     41   *
     42   * In this way, we are able to assign absolute sequence numbers to cells
     43   * immediately, regardless of how many legs or leg switches have occurred,
     44   * and regardless of the delivery status of each cell versus if it must be
     45   * queued.
     46   */
     47  uint64_t last_seq_recv;
     48 
     49  /**
     50   * For relative sequencing: Highest absolute sequence number sent on each
     51   * circuit. The overall absolute current sent sequence number is the highest
     52   * of these values.
     53   *
     54   * As a sender, this allows us to compute a relative sequence number when
     55   * switching legs. When switching legs, the sender looks up its current
     56   * absolute sequence number as the maximum of all legs. The sender then
     57   * compares that to the current sequence number on the leg it is about to
     58   * send on, and then computes the relative sequence number as the difference
     59   * between the overall absolute sequence number and the sequence number
     60   * from the sending leg.
     61   *
     62   * In this way, we can use much smaller relative sequence numbers on the
     63   * wire, as opposed to larger absolute values, at the expense of this
     64   * bookkeeping overhead on each end.
     65   */
     66  uint64_t last_seq_sent;
     67 
     68  /**
     69   * Current round-trip of the circuit, in usec.
     70   *
     71   * XXX: In theory, we could use the congestion control RTTs directly off the
     72   * circs, but congestion control code has assumptions about the RTT being 0
     73   * at the start of the circuit, which will *not* be the case here, because we
     74   * get an RTT off the link circuit. */
     75  uint64_t circ_rtts_usec;
     76 
     77  /** Exit side only: When was the LINKED cell sent? Used for RTT measurement
     78   * that sets circ_rtts_usec when the LINKED_ACK is received. */
     79  uint64_t linked_sent_usec;
     80 
     81  /** Circuit of this leg. */
     82  circuit_t *circ;
     83 };
     84 
     85 /** Fields for conflux multipath support */
     86 struct conflux_t {
     87  /** Cached parameters for this circuit */
     88  struct conflux_params_t params;
     89 
     90  /**
     91   * List of all linked conflux_leg_t for this set. Once a leg is in that list,
     92   * it can be used to transmit data. */
     93  smartlist_t *legs;
     94 
     95  /**
     96   * Out-of-order priority queue of conflux_cell_t *, heapified
     97   * on conflux_cell_t.seq number (lowest at top of heap).
     98   *
     99   * XXX: We are most likely to insert cells at either the head or the tail.
    100   * Verify that is fast-path wrt smartlist priority queues, and not a memmove
    101   * nightmare. If so, we may need a real linked list, or a packed_cell_t list.
    102   */
    103  smartlist_t *ooo_q;
    104 
    105  /**
    106   * Approximate allocation cost of the bytes stored in ooo_q
    107   * and the messages that it contains.
    108   */
    109  size_t ooo_q_alloc_cost;
    110 
    111  /**
    112   * Absolute sequence number of cells delivered to streams since start.
    113   * (ie: this is updated *after* dequeue from the ooo_q priority queue). */
    114  uint64_t last_seq_delivered;
    115 
    116  /**
    117   * The estimated remaining number of cells we can send on this circuit
    118   * before we are allowed to switch legs. */
    119  uint64_t cells_until_switch;
    120 
    121  /** Current circuit leg. Only use this with conflux_get_circ_for_leg() for
    122   * bounds checking. */
    123  struct conflux_leg_t *curr_leg;
    124 
    125  /** Previous circuit leg. Only use this with conflux_get_circ_for_leg() for
    126   * bounds checking. */
    127  struct conflux_leg_t *prev_leg;
    128 
    129  /** The nonce that joins these */
    130  uint8_t nonce[DIGEST256_LEN];
    131 
    132  /** Indicate if this conflux set is in full teardown. We mark it at the first
    133   * close in case of a total teardown so we avoid recursive calls of circuit
    134   * mark for close. */
    135  bool in_full_teardown;
    136 
    137  /** Number of leg launch that we've done for this set. We keep this value
    138   * because there is a maximum allowed in order to avoid side channel(s). */
    139  unsigned int num_leg_launch;
    140 
    141  /**
    142   * PolicyHint: Predicted ports/protocol shorthand..
    143   *
    144   * XXX: This might be redundant to the circuit's exitpolicy.
    145   */
    146 };
    147 
    148 #endif /* !defined(CONFLUX_ST_H) */