Changeset 0093ab6 in mainline for uspace/srv/net/tl/tcp/seq_no.c


Ignore:
Timestamp:
2011-09-21T19:56:41Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
032bbe7
Parents:
4c55a64
Message:

Parts of data reception. Trimming segment to receive window.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/seq_no.c

    r4c55a64 r0093ab6  
    7171 *
    7272 * ACK is duplicate if it refers to a sequence number that has
    73  * aleady been acked (SEG.ACK < SND.UNA).
     73 * aleady been acked (SEG.ACK <= SND.UNA).
    7474 */
    7575bool seq_no_ack_duplicate(tcp_conn_t *conn, uint32_t seg_ack)
     
    8181         * equivalent of SEG.ACK < SND.UNA. Thus we do it
    8282         * on a best-effort basis, based on the difference.
    83          * [-2^31, 0) means less-than, [0, 2^31) means greater-than.
     83         * [-2^31, 0) means less-than, 0 means equal, [0, 2^31)
     84         * means greater-than. Less-than or equal means duplicate.
    8485         */
    8586        diff = seg_ack - conn->snd_una;
    86         return (diff & (0x1 << 31)) != 0;
     87        return diff == 0 || (diff & (0x1 << 31)) != 0;
    8788}
    8889
     
    176177}
    177178
     179/** Calculate the amount of trim needed to fit segment in receive window. */
     180extern void seq_no_seg_trim_calc(tcp_conn_t *conn, tcp_segment_t *seg,
     181    uint32_t *left, uint32_t *right)
     182{
     183        assert(seq_no_segment_acceptable(conn, seg));
     184
     185        /*
     186         * If RCV.NXT is between SEG.SEQ and RCV.NXT+RCV.WND, then
     187         * left trim amount is positive
     188         */
     189        if (seq_no_lt_le(seg->seq, conn->rcv_nxt,
     190            conn->rcv_nxt + conn->rcv_wnd)) {
     191                *left = conn->rcv_nxt - seg->seq;
     192        } else {
     193                *left = 0;
     194        }
     195
     196        /*
     197         * If SEG.SEQ+SEG.LEN is between SEG.SEQ and RCV.NXT+RCV.WND,
     198         * then right trim is zero.
     199         */
     200        if (seq_no_lt_le(seg->seq - 1, seg->seq + seg->len,
     201            conn->rcv_nxt + conn->rcv_wnd)) {
     202                *right = 0;
     203        } else {
     204                *right = (seg->seq + seg->len) -
     205                    (conn->rcv_nxt + conn->rcv_wnd);
     206        }
     207}
     208
    178209/**
    179210 * @}
Note: See TracChangeset for help on using the changeset viewer.