three-way handshake,中文翻譯為『三向交握』或『三段式交握』。一個用戶端向另一個伺服端建立 TCP 連線時,所使用的程序。

SYN (client→server)

  1. soure port: 3262
  2. target port: 80
  3. sequence: 0x5ced5d04
  4. acknowledge: 0
  5. data offset: 0x70
  6. flags: 0x02(SYN)
  7. window: 65535
  8. checksum: 0x7ef2
  9. urgent point: 0
  10. options: 0x02(Maximum Segment Size, MSS)
  11. length: 4
  12. mss: 1460
  13. padding: 0x0101
  14. SACK: 0x0402
0c,be,00,50,5c,ed,5d,04,00,00,00,00,70,02,ff,ff,7e,f2,00,00,02,04,05,b4,01,01,04,02

SYN,ACK (server→client)

  1. soure port: 80
  2. target port: 3262
  3. sequence: 0xf28774e5
  4. acknowledge: 0x5ced5d05
  5. data offset: 0x70
  6. flags: 0x12(SYN, ACK)
  7. window: 16384
  8. checksum: 0xd773
  9. urgent point: 0
  10. options: 0x02(Maximum Segment Size, MSS)
  11. length: 4
  12. mss: 1460
  13. padding: 0x0101
  14. SACK: 0x0402
00,50,0c,be,f2,87,74,e5,5c,ed,5d,05,70,12,40,00,d7,73,00,00,02,04,05,b4,01,01,04,02

ACK (client→server)

  1. soure port: 3262
  2. target port: 80
  3. sequence: 0x5ced5d05
  4. acknowledge: 0xf28774e6
  5. data offset: 0x50
  6. flags: 0x10(ACK)
  7. window: 65535
  8. checksum: 0x1e08
  9. urgent point: 0
0c,be,1f,90,5c,ed,5d,05,f2,87,74,e6,50,10,ff,ff,1e,08,00,00

以上三個通訊就完成三向交握,下面就開始 http 的資料傳送。

PSH, ACK (client→server)

向 server 要求讀取某一個 html 檔。

  1. soure port: 3262
  2. target port: 80
  3. sequence: 0x5ced5d05
  4. acknowledge: 0xf28774e6
  5. data offset: 0x50
  6. flags: 0x18(ACK, PSH)
  7. window: 65535
  8. checksum: 0x1f1d
  9. urgent point: 0
  10. http: GET http://xxxxxxx HTTP/1.1\r\n.........
0c,be,00,50,5c,ed,5d,05,f2,87,74,e6,50,18,ff,ff,1f,1d,00,00,........

ACK (server→client)

  1. soure port: 80
  2. target port: 3262
  3. sequence: 0xf28774e6
  4. acknowledge: 0x5ced5e1a
  5. data offset: 0x50
  6. flags: 0x10(ACK)
  7. window: 65258
  8. checksum: 0x2b77
  9. urgent point: 0
  10. http: .........
00,50,0c,be,f2,87,74,e6,5c,ed,5e,1a,50,10,fe,ea,2b,77,00,00,.......

ACK (server→client)

  1. soure port: 80
  2. target port: 3262
  3. sequence: 0xf2877a9a
  4. acknowledge: 0x5ced5e1a
  5. data offset: 0x50
  6. flags: 0x10(ACK)
  7. window: 65258
  8. checksum: 0x2919
  9. urgent point: 0
  10. http: .........
00,50,0c,be,f2,87,7a,9a,5c,ed,5e,1a,50,10,fe,ea,29,19,00,00,.......

ACK (client→server)

  1. soure port: 3262
  2. target port: 80
  3. sequence: 0x5ced5e1a
  4. acknowledge: 0xf287804e
  5. data offset: 0x50
  6. flags: 0x10(ACK)
  7. window: 65535
  8. checksum: 0x1e08
  9. urgent point: 0
0c,be,00,50,5c,ed,5e,1a,f2,87,80,4e,50,10,ff,ff,1e,08,00,00

ACK (server→client)

  1. soure port: 80
  2. target port: 3262
  3. sequence: 0xf287804e
  4. acknowledge: 0x5ced5e1a
  5. data offset: 0x50
  6. flags: 0x10(ACK)
  7. window: 65258
  8. checksum: 0x865a
  9. urgent point: 0
  10. http: .........
00,50,0c,be,f2,87,80,4e,5c,ed,5e,1a,50,10,fe,ea,86,5a,00,00,.......

ACK (client→server)

  1. soure port: 3262
  2. target port: 80
  3. sequence: 0x5ced5e1a
  4. acknowledge: 0xf2878602
  5. data offset: 0x50
  6. flags: 0x10(ACK)
  7. window: 65535
  8. checksum: 0x1e08
  9. urgent point: 0
0c,be,00,50,5c,ed,5e,1a,f2,87,86,02,50,10,ff,ff,1e,08,00,00

PSH, ACK (server→client)

  1. soure port: 80
  2. target port: 3262
  3. sequence: 0xf2878602
  4. acknowledge: 0x5ced5e1a
  5. data offset: 0x50
  6. flags: 0x18(PSH, ACK)
  7. window: 65258
  8. checksum: 0xfc49
  9. urgent point: 0
  10. http: .........
00,50,0c,be,f2,87,86,02,5c,ed,5e,1a,50,18,fe,ea,fc,49,00,00,.......

以上通訊才算完成一個檔案傳輸喔。

創作者介紹

邱小新の工作筆記

台南小新 發表在 痞客邦 PIXNET 留言(0) 人氣()