メインコンテンツまでスキップ

TCP の実装 (第 1 部)

4.1 はじめに​

概念的には、TCP は複数のプロセスから構成される。そのうちのいくつかはユーザ/TCP コマンドを扱い、他のものはネットワークから到着するパケットを扱う。TCP はまた、遠隔から起動できる内部の測定機能を持つ。

個々の TCP は、さまざまな見方ができる。多数のユーザ・プロセスにサービスを提供する独立したプロセスとして実装することもできる。ローカル PSN への共通のインタフェースと共通のバッファ記憶域を共有する、再入可能なライブラリ・ルーチンの集合とみなすこともできる。さらには、ユーザを扱うもの、ネットワークからのパケット入力を扱うもの、ネットワークへのパケット出力を扱うものといった、プロセスの集合とみなすことさえできる。

4.2 TCP のデータ構造​

4.2.1 インターネットワーク・パケット形式​

以下に、インターネットワーク・パケットの各フィールドを先頭から順に示す。制御情報の各ビット (SYN、ACK、FIN、DSN、EOS、EOL、INT など)、制御データ・オクテットの特殊機能コード、宛先および送信元のネットワーク・アドレスとポート・アドレス、チェックサムが規定されている。

8 bits: Internet information

   2 bits: Reserved for local PSN use

   2 bits: Header format (11 in binary)

   4 bits: Protocol version number

8 bits: Header length in octets (32 is the current value)

16 bits: Length of text in octets

32 bits: Packet sequence number

32 bits: Acknowledgment number (i.e. sequence number of next octet
expected).

16 bits: Window size (in octets)

16 bits: Control Information

   Listed from high to low order:

   SYN: Request to synchronize sending sequence numbers

   ACK: There is a valid acknowledgment in the 32 bit ACK field

   FIN: Sender will stop SENDing and RECEIVEing on this connection

   DSN: The sender has stopped using sequence numbers and wants to
   initiate a new sequence number for sending.

   EOS: This packet is the end of a segment and therefore has a
   checksum in the 16 bit checksum field. If this bit is not set, the
   16 bit checksum field is to be ignored. The bit is usually set,
   but if fragmentation at a GATEWAY occurs, the packets preceding
   the last one will not have checksums, and the last packet will
   have the checksum for the entire original fragment (segment) as it
   was calculated by the sending TCP.

   EOL: This packet contains the last fragment of a letter. The EOS
   bit will always be set in this case.

   INT: The sender wants to INTERRUPT on this connection.

   XXX: six (6) unused control bits

   OD: three (3) bits of control dispatch:

      000: Null (the control octet contents should be ignored}

      001: Event Code is present in the control octet. These were
      defined in section 2.4.3.

      010: Special Functions

      011: Reject (codes as yet undefined)

      1XX: Unused

8 bits: Control Data Octet

   If CD is 000 then this octet is to be ignored.

   If CD is 001, this octet contains event codes defined in section
   2.4.3

   If CD is 010, this octet contains a special function code as
   defined below:

      0: RESET all connections between Source and Destination TCPs

      l: RESET the specific connection referenced in this packet

      2: ECHO return packet to sender with the special function code
      ECHOR (Echo Reply).

      3: QUERY Query status of connection referenced in this packet

      4: STATUS Reply to QUERY with requested status.

      5: ECHOR Echo Reply

      6: TRASH Discard packet without acknowledgment

      >6: Unused

      Note: Special function packets not pertaining to a particular
      connection [RESET all, ECHO, ECHOR, and TRASH] are normally
      sent using socket zero as described in section 3.2.

   If CD is 01l, this octet contains an as yet undefined REJECT code.

   If CD is 1XX, this octet is undefined.

4 bits: Length of destination network address in 4 bit units (current
value is 1)

4 bits: Destination network address

   1010-1111 are addresses of ARPANET, UCL, CYCLADES, NPL, CADC, and
   EPSS respectively.

16 bits: Destination TCP address

8 bits: Padding

4 bits: length of source network address in 4 bit units (current
value is 1)

4 bits: source network address (as for destination address)

16 bits: Source TCP address

24 bits: Destination port address

24 bits: Source port address

16 bits: Checksum (if EOS bit is set)