1*b636d99dSDavid van Moolenbroek /* 2*b636d99dSDavid van Moolenbroek * Definitions for tcp compression routines. 3*b636d99dSDavid van Moolenbroek * 4*b636d99dSDavid van Moolenbroek * Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of 5*b636d99dSDavid van Moolenbroek * California. All rights reserved. 6*b636d99dSDavid van Moolenbroek * 7*b636d99dSDavid van Moolenbroek * Redistribution and use in source and binary forms are permitted 8*b636d99dSDavid van Moolenbroek * provided that the above copyright notice and this paragraph are 9*b636d99dSDavid van Moolenbroek * duplicated in all such forms and that any documentation, 10*b636d99dSDavid van Moolenbroek * advertising materials, and other materials related to such 11*b636d99dSDavid van Moolenbroek * distribution and use acknowledge that the software was developed 12*b636d99dSDavid van Moolenbroek * by the University of California, Berkeley. The name of the 13*b636d99dSDavid van Moolenbroek * University may not be used to endorse or promote products derived 14*b636d99dSDavid van Moolenbroek * from this software without specific prior written permission. 15*b636d99dSDavid van Moolenbroek * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 16*b636d99dSDavid van Moolenbroek * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 17*b636d99dSDavid van Moolenbroek * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 18*b636d99dSDavid van Moolenbroek * 19*b636d99dSDavid van Moolenbroek * Van Jacobson (van@ee.lbl.gov), Dec 31, 1989: 20*b636d99dSDavid van Moolenbroek * - Initial distribution. 21*b636d99dSDavid van Moolenbroek */ 22*b636d99dSDavid van Moolenbroek 23*b636d99dSDavid van Moolenbroek /* 24*b636d99dSDavid van Moolenbroek * Compressed packet format: 25*b636d99dSDavid van Moolenbroek * 26*b636d99dSDavid van Moolenbroek * The first octet contains the packet type (top 3 bits), TCP 27*b636d99dSDavid van Moolenbroek * 'push' bit, and flags that indicate which of the 4 TCP sequence 28*b636d99dSDavid van Moolenbroek * numbers have changed (bottom 5 bits). The next octet is a 29*b636d99dSDavid van Moolenbroek * conversation number that associates a saved IP/TCP header with 30*b636d99dSDavid van Moolenbroek * the compressed packet. The next two octets are the TCP checksum 31*b636d99dSDavid van Moolenbroek * from the original datagram. The next 0 to 15 octets are 32*b636d99dSDavid van Moolenbroek * sequence number changes, one change per bit set in the header 33*b636d99dSDavid van Moolenbroek * (there may be no changes and there are two special cases where 34*b636d99dSDavid van Moolenbroek * the receiver implicitly knows what changed -- see below). 35*b636d99dSDavid van Moolenbroek * 36*b636d99dSDavid van Moolenbroek * There are 5 numbers which can change (they are always inserted 37*b636d99dSDavid van Moolenbroek * in the following order): TCP urgent pointer, window, 38*b636d99dSDavid van Moolenbroek * acknowlegement, sequence number and IP ID. (The urgent pointer 39*b636d99dSDavid van Moolenbroek * is different from the others in that its value is sent, not the 40*b636d99dSDavid van Moolenbroek * change in value.) Since typical use of SLIP links is biased 41*b636d99dSDavid van Moolenbroek * toward small packets (see comments on MTU/MSS below), changes 42*b636d99dSDavid van Moolenbroek * use a variable length coding with one octet for numbers in the 43*b636d99dSDavid van Moolenbroek * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the 44*b636d99dSDavid van Moolenbroek * range 256 - 65535 or 0. (If the change in sequence number or 45*b636d99dSDavid van Moolenbroek * ack is more than 65535, an uncompressed packet is sent.) 46*b636d99dSDavid van Moolenbroek */ 47*b636d99dSDavid van Moolenbroek 48*b636d99dSDavid van Moolenbroek /* 49*b636d99dSDavid van Moolenbroek * Packet types (must not conflict with IP protocol version) 50*b636d99dSDavid van Moolenbroek * 51*b636d99dSDavid van Moolenbroek * The top nibble of the first octet is the packet type. There are 52*b636d99dSDavid van Moolenbroek * three possible types: IP (not proto TCP or tcp with one of the 53*b636d99dSDavid van Moolenbroek * control flags set); uncompressed TCP (a normal IP/TCP packet but 54*b636d99dSDavid van Moolenbroek * with the 8-bit protocol field replaced by an 8-bit connection id -- 55*b636d99dSDavid van Moolenbroek * this type of packet syncs the sender & receiver); and compressed 56*b636d99dSDavid van Moolenbroek * TCP (described above). 57*b636d99dSDavid van Moolenbroek * 58*b636d99dSDavid van Moolenbroek * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and 59*b636d99dSDavid van Moolenbroek * is logically part of the 4-bit "changes" field that follows. Top 60*b636d99dSDavid van Moolenbroek * three bits are actual packet type. For backward compatibility 61*b636d99dSDavid van Moolenbroek * and in the interest of conserving bits, numbers are chosen so the 62*b636d99dSDavid van Moolenbroek * IP protocol version number (4) which normally appears in this nibble 63*b636d99dSDavid van Moolenbroek * means "IP packet". 64*b636d99dSDavid van Moolenbroek */ 65*b636d99dSDavid van Moolenbroek 66*b636d99dSDavid van Moolenbroek /* packet types */ 67*b636d99dSDavid van Moolenbroek #define TYPE_IP 0x40 68*b636d99dSDavid van Moolenbroek #define TYPE_UNCOMPRESSED_TCP 0x70 69*b636d99dSDavid van Moolenbroek #define TYPE_COMPRESSED_TCP 0x80 70*b636d99dSDavid van Moolenbroek #define TYPE_ERROR 0x00 71*b636d99dSDavid van Moolenbroek 72*b636d99dSDavid van Moolenbroek /* Bits in first octet of compressed packet */ 73*b636d99dSDavid van Moolenbroek #define NEW_C 0x40 /* flag bits for what changed in a packet */ 74*b636d99dSDavid van Moolenbroek #define NEW_I 0x20 75*b636d99dSDavid van Moolenbroek #define NEW_S 0x08 76*b636d99dSDavid van Moolenbroek #define NEW_A 0x04 77*b636d99dSDavid van Moolenbroek #define NEW_W 0x02 78*b636d99dSDavid van Moolenbroek #define NEW_U 0x01 79*b636d99dSDavid van Moolenbroek 80*b636d99dSDavid van Moolenbroek /* reserved, special-case values of above */ 81*b636d99dSDavid van Moolenbroek #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ 82*b636d99dSDavid van Moolenbroek #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ 83*b636d99dSDavid van Moolenbroek #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) 84*b636d99dSDavid van Moolenbroek 85*b636d99dSDavid van Moolenbroek #define TCP_PUSH_BIT 0x10 86