TCP (tcp)
- レイヤ: L4 (トランスポート)
- ヘッダ: 可変長
- 補足: ユーザ定義プロトコル (protocols.d)
下位レイヤからの到達
| 下位レイヤ | 判別フィールド | 値 |
|---|---|---|
ipv4 | protocol | 6 (0x06) |
ipv6 | next_header | 6 (0x06) |
ipv6_hopopts | next_header | 6 (0x06) |
ipv6_route | next_header | 6 (0x06) |
ipv6_srh | next_header | 6 (0x06) |
ipv6_frag | next_header | 6 (0x06) |
ipv6_dstopts | next_header | 6 (0x06) |
フィールド
| フィールド | 型 | 既定値 | Auto | 説明 |
|---|---|---|---|---|
src_port | uint(16) | 49152 | 送信元ポート。 | |
dst_port | uint(16) | 80 | 宛先ポート。次レイヤを選択する (179 = BGP、646 = LDP、3868 = Diameter、5060 = SIP)。 | |
seq | uint(32) | 0 | 先頭データオクテットのシーケンス番号 (SYN では初期シーケンス番号)。 | |
ack | uint(32) | 0 | 確認応答番号。ACK フラグが立っているとき有効。 | |
data_offset | uint(4) | ヘッダの長さ (32 ビットワード単位) | ヘッダ長 (32 ビット語単位、5〜15。Auto、オプションを含む)。 | |
reserved | uint(4) | 0 | 予約ビット。0。 | |
flags | flags(8) | 0x2 | 制御フラグ: CWR、ECE、URG、ACK、PSH、RST、SYN、FIN (既定は SYN)。 | |
window | uint(16) | 65535 | 受信ウィンドウ (バイト。ウィンドウスケールオプションで拡大)。 | |
checksum | uint(16) | ヘッダとそれ以降すべてに対する疑似ヘッダ付きインターネットチェックサム | IPv4 / IPv6 擬似ヘッダを含むインターネットチェックサム (Auto)。 | |
urgent_ptr | uint(16) | 0 | 緊急ポインタ。URG フラグが立っているとき有効。 | |
options | tlv — data_offset * 4 - 20 オクテット | TCP オプション (TLV: EOL、NOP、MSS、ウィンドウスケール、SACK 許可、SACK、タイムスタンプ)。 | ||
padding | padding(4) | オプションを 32 ビット境界に揃えるゼロパディング (Auto)。 |
flags
| ビット | マスク | 名前 |
|---|---|---|
| 7 | 128 (0x80) | cwr |
| 6 | 64 (0x40) | ece |
| 5 | 32 (0x20) | urg |
| 4 | 16 (0x10) | ack |
| 3 | 8 (0x08) | psh |
| 2 | 4 (0x04) | rst |
| 1 | 2 (0x02) | syn |
| 0 | 1 (0x01) | fin |
options
- タイプ 8 ビット、長さ 8 ビット。
- 長さはタイプと長さのフィールドも含みます。
- 未知のタイプは値をオクテット列のまま保持します。
| タイプ値 | 名前 | 値のフィールド | 説明 |
|---|---|---|---|
| 0 (0x00) | eol | (タイプのみ。長さと値なし) | |
| 1 (0x01) | nop | (タイプのみ。長さと値なし) | |
| 2 (0x02) | mss | value | |
| 3 (0x03) | ws | shift | |
| 4 (0x04) | sack_permitted | ||
| 5 (0x05) | sack | blocks | |
| 8 (0x08) | timestamps | tsval, tsecr |
options › mss
| フィールド | 型 | 既定値 | Auto | 説明 |
|---|---|---|---|---|
value | uint(16) |
options › ws
| フィールド | 型 | 既定値 | Auto | 説明 |
|---|---|---|---|---|
shift | uint(8) |
options › sack
| フィールド | 型 | 既定値 | Auto | 説明 |
|---|---|---|---|---|
blocks | list<struct> — PDU の残りすべて |
options › sack › blocks
各要素は以下のフィールドの組です。
| フィールド | 型 | 既定値 | Auto | 説明 |
|---|---|---|---|---|
left | uint(32) | |||
right | uint(32) |
options › timestamps
| フィールド | 型 | 既定値 | Auto | 説明 |
|---|---|---|---|---|
tsval | uint(32) | |||
tsecr | uint(32) |
次レイヤ
次レイヤは dst_port で判別します。このフィールドが Auto のときは、上に積んだプロトコルの値を書き込みます。 デコード時は、最初のフィールドがどの項目にも一致しなければ src_port も参照します。
制約
| レベル | 規則 |
|---|---|
| エラー | data_offset が 5..15 の範囲 |
サンプルテンプレート
- bad-tcp-checksum —
templates/malformed/tcp-bad-checksum.wpg.yaml - tcp-data-psh-ack —
templates/protocols/l4/tcp-data.wpg.yaml - tcp-syn-options —
templates/protocols/l4/tcp-syn.wpg.yaml - diameter-ccr-initial —
templates/protocols/mobile/diameter-ccr-initial.wpg.yaml - diameter-cer —
templates/protocols/mobile/diameter-cer.wpg.yaml - ldp-initialization —
templates/protocols/mpls/ldp-initialization.wpg.yaml - ldp-label-mapping —
templates/protocols/mpls/ldp-label-mapping.wpg.yaml - ldp-label-withdraw —
templates/protocols/mpls/ldp-label-withdraw.wpg.yaml - bgp-open —
templates/protocols/routing/bgp-open.wpg.yaml - sip-register —
templates/protocols/voip/sip-register.wpg.yaml - scenario-tcp-syn-port-scan —
templates/scenarios/tcp-syn-port-scan.wpg.yaml - scenario-vlan-syn-flood —
templates/scenarios/vlan-syn-flood.wpg.yaml