- up: ðéä¿¡ãããã³ã«(Communication Protocol)
- refs.
- links
TCPãšã¯
TCP ã¯ä¿¡é Œæ§ã®ããåæ¹åã®ã¹ããªãŒã åéä¿¡ãå®çŸãããããã³ã«.
TCP ã®äž»ãªåœ¹å²ã¯ä»¥äž.
- çµç¹ãèŠã€ãã
- ä¿¡é Œæ§ã確ä¿ãã
å®çŸããããã®æ©èœã¯ä»¥äž.
- ãã€ãã¹ããªãŒã ã³ãã¯ã·ã§ã³
- ãã«ããã¬ã¯ã·ã³ã° (å€éå)
- ä¿¡é Œæ§ã®ç¢ºä¿
- ACK å¿ç
- åéå¶åŸ¡
- é åºå¶åŸ¡ (ã·ãŒã±ã³ã¹çªå·)
- ãŠã£ã³ããŠæ¹åŒ
- ãããŒå¶åŸ¡
- ãŠã£ã³ããŠå¶åŸ¡
Port
åäžã³ã³ãã¥ãŒã¿äžã§åäœããè€æ°ã®ã¢ããªã±ãŒã·ã§ã³ãåºå¥ããããã®çªå·.
TCP ããã
TCP ãªãã·ã§ã³
TCP æ¥ç¶ã®éä¿¡åŽãåä¿¡åŽã«å¯ŸããŠæ瀺ãããã©ã¡ãŒã¿.
TCP ã³ãã¯ã·ã§ã³
3-way ãã³ãã·ã§ã€ã¯
TCP æ¥ç¶ãªãŒãã³æã®æç¶ã.
ACK
確èªå¿ç. Acknowledge.
ãŠã£ã³ããŠå¶åŸ¡
è€æ°ã® TCP ãã±ãããé£ç¶ã㊠(ACK 確èªãªãã§) éä¿¡ãããšããæ¹åŒ.
éä¿¡ã®åŸåŸ©åæ°ãåæžããããšã§, é ãåç·ã«ãããé«éåãå®çŸãã.
ã¹ã©ã€ãã£ã³ã°ãŠã£ã³ããŠæ¹åŒ
åã ã®ããŒã¿ã ACK ãåŸ ããã«è»¢éããä»çµã¿.
éä¿¡ãããããŒã¿ãè€æ°ã® TCP ãã±ããã«åã, ACK ãåŸ ããã«ãŸãšããŠé£ç¶ããŠéä¿¡ãã. ãã㊠ACK ã¯, ãããã®ããŒã¿ã«å¯ŸããŠ, ãŸãšã㊠1 ã€ã ãè¿éãã.
more. Sliding Window Algorithm
ãŠã£ã³ããŠãµã€ãº
ACK ãåŸ ããã«äžåºŠã«éä¿¡ã§ããããŒã¿é.
ãŠã£ã³ããŠãµã€ãº = ã»ã¯ã¡ã³ããµã€ãº * ã¹ã©ã€ãã£ã³ã°ãŠã£ã³ããŠã®åæ°.
äžè¬çã«ã¯ãŠã£ã³ããŠã»ãµã€ãºã®åæå€ã¯æ° Kbytes ããæ°å Kbytes çšåºŠ.
ãŠã£ã³ããŠã»ãµã€ãºã»ãã£ãŒã«ã㯠16bit å¹ ãªã®<ã§, æ倧ã§ã¯ 65,535bytes ãŸã§ã®ãŠã£ã³ããŠã»ãµã€ãºãèšå®ããããšãã§ãã. ãŸã RFC1323 ã§å®çŸ©ãããŠãã TCP ã®æ¡åŒµãããã³ã«ã䜿ããš, ãã倧ããªãŠã£ã³ããŠã»ãµã€ãºãå©çšããããšãã§ãã.
ãŠã£ã³ããŠã»ãµã€ãºã倧ãããããš, ãã®åãããã³ã«ã»ã¹ã¿ãã¯ã§äœ¿çšããã¡ã¢ãªé åãå¢ãã.
- åºç€ããåŠã¶ Windows ãããã¯ãŒã¯:第 14 å ä¿¡é Œæ§ã®ããéä¿¡ãå®çŸãã TCP ãããã³ã« (ãã® 1) (3/3) - ïŒ IT
- åºç€ããåŠã¶ Windows ãããã¯ãŒã¯:第 16 å ä¿¡é Œæ§ã®ããéä¿¡ãå®çŸãã TCP ãããã³ã« (3) (2/4) - ïŒ IT
TCP ããã ããŠã£ã³ããŠã»ãµã€ãºããã£ãŒã«ã:16bit å¹
åä¿¡åŽã®ãŠã£ã³ããŠã»ãµã€ãºãçžæã«äŒããããã«å©çšããã. TCP ã®éä¿¡åŽã§ã¯, çžæããéç¥ããããŠã£ã³ããŠã»ãµã€ãºãèŠãŠ, éä¿¡å¯èœãªæ倧ã®ããŒã¿éãå€æããŠãã.
ãããŒå¶åŸ¡ãšã®é¢ä¿
ã¢ããªã±ãŒã·ã§ã³ã®ããŒã¿åŠçé床ããããã¯ãŒã¯ã®åä¿¡é床ãããååéããã°, ãŠã£ã³ããŠã»ãµã€ãºã¯ãã£ãšå€§ãããŸãŸã§, 垯åå¹ ããã«ã«æŽ»çšããããšãã§ãã.
ã¢ããªã±ãŒã·ã§ã³ã®åŠçé床ãé ããã°, ãŠã£ã³ããŠã»ãµã€ãºãèªåçã«çž®å°ããŠ, ããŒã¿ã®åä¿¡ãæå¶ãã.
ã»ã°ã¡ã³ã
TCP ã«ãããããŒã¿ã®éä¿¡åäœ.
TCP ã§ã¯ã»ã°ã¡ã³ããšãããµã€ãºããšã«åºåã£ãŠããŒã¿ãéä¿¡ããŠãã.
MSS
MSS (Maximum Segment Size. æ倧ã»ã°ã¡ã³ãã»ãµã€ãº).
åä¿¡å¯èœãªã»ã°ã¡ã³ãã®æ倧ãµã€ãºãéä¿¡çžæã«éç¥ããããã®ãªãã·ã§ã³.
MSS ã®ãµã€ãºãåãããš, TCP ããŒã¿ãéä¿¡ããåŽã§ã¯, åžžã«ãã®ãµã€ãºä»¥äžã«ãªãããã«ããŒã¿ãåå²ããŠéä¿¡ããããšãã§ãã. ç¡çšãª IP ãã©ã°ã¡ã³ããŒã·ã§ã³ãèµ·ããããšãªã, åžžã«æ倧ã®å¹çã§ãã±ãããéä¿¡ããããšãã§ãã.
æãå¹çããããŒã¿ãéä¿¡ããããã«ã¯, ãŠã£ã³ããŠã»ãµã€ãºã MSS ã®æŽæ°åã«ããã®ãæãŸãã.
Ethernet ã䜿ããšã, ãã®ãµã€ãºã¯ 1,460 ãªã¯ããããšãªããŸã
ãŠã£ã³ããŠã»ã¹ã±ãŒã«ã»ãªãã·ã§ã³
TCP ã®æ倧 64Kbytes ãšãªã£ãŠãããŠã£ã³ããŠã»ãµã€ãºããã倧ããããããã«å©çšããããªãã·ã§ã³.
åéå¶åŸ¡
TCP ãã±ããåä¿¡åŽã§ã¯, ããŒã¿ãåãåã£ãããšãè¡šããã ACK å¿çãè¿éãã.
TCP ãã±ããéä¿¡åŽã§ã¯, ãã® ACK ãåãåã£ãŠåããŠéä¿¡ãå®äºãããšã¿ãªã. ãã°ããåŸ ã£ãŠã ACK ãåä¿¡ã§ããªããã°, éä¿¡ã倱æãããã®ãšã¿ãªã,åéå¶åŸ¡ãå®æœãã.
ãããããèŠå®ãããåæ° çµã£ãŠã ACK ãåä¿¡ã§ããªãå Žåã¯, TCP ã³ãã¯ã·ã§ã³ãåããŠããŸã£ããšå€æã, äžäœã¢ããªã±ãŒã·ã§ã³ã«å¯ŸããŠãšã©ãŒãªã©ãéç¥ãã.
RTO
Retransmission Time Out.åéã¿ã€ã ã¢ãŠã.
ã¿ã€ã ã¢ãŠãå€ã¯ RTT ãæšæž¬ããããšã§åçã«æ±ºå®ãã.
- RTO ã®åæå€ã¯ RTT ã® 4 å + α
- RTO ã®å€ã¯åéãè¡ããã³ã« 2 åã«å¢ãããã.
- æ倧㧠64 ç§ãŸã§ãªã.
- RTT ã¯åæå€ã 3 ç§ãšã, ãããŸã§ã«éã£ãããŒã¿ã«å¯Ÿã
- ACK ãè¿ã£ãŠæ¥ããŸã§ã«ããã£ãæéããç®åºãã.
ref. TCP ã«ããã確èªå¿çãšåéå¶åŸ¡ â Key:éåŠäºå ž
Windows ã§ã® åéå¶åŸ¡
- TCP æ¥ç¶ã確ç«ããããšãã«, åéã¿ã€ããŒã¯ 3 ç§ã«åæåããã.
- ç¹å®ã®æ¥ç¶ã§éåžžçããé 延ã«å¿ãã調æŽãèªåçã«è¡ã.
- ã¿ã€ã ã¢ãŠãå€ã¯, æ¥ç¶ã§åéãé£ç¶ããŠè¡ãããããšã« 2 åã«ãªã.
- åéåæ°ã®æ¢å®å€ã¯ 5.åæå転éæé㯠5 ç§
以äžã«, åéã¿ã€ã ã¢ãŠã調æŽã®ããã®ã¬ãžã¹ã¿æ å ±ããã.
ç»åä»ã.
WireShark ã§ã®ãšã©ãŒ
TCP Retransmit ã» DupACK ã» Fast Retransmit ãã©ãã«ã·ã¥ãŒãã£ã³ã°æã®ããŒã¯ãŒã
TCP Retransmit
WireShark ã§ã¯, TCP Retransmit ãšããã¡ãã»ãŒãžãåéããããªãããããšã瀺ããŠãã.
TCP DupACK
ãã±ãããã¹çã§, åä¿¡è ãæ³å®ããŠããã·ãŒã±ã³ã¹çªå·ãã, 倧ããªå€ã®ã·ãŒã±ã³ã¹çªå·ãéä¿¡è ããéãããŠããããšããããŸã.
ãããš, åä¿¡è ã¯èªåãæ³å®ããŠããã·ãŒã±ã³ã¹çªå·ãACK çªå·ã«ã»ãããã ACK ãçŽã¡ã«éä¿¡è ã«éããŸã. ããã DupACK ã§ã.
TCP Fast Retransmit
é«éå転é.ããŒã¿éä¿¡è ã, DupACK ãè€æ°ååãåããš, Retransmission Timeout ã®çµéãåŸ ã€ããšãªã, åéãè¡ããŸã.
æããŠããã»ã°ã¡ã³ãã®ã¿éä¿¡ããã®ã§ã¯ãªã, æããŠããã»ã°ã¡ã³ã以éãå šãŠéä¿¡ãçŽã.
é åºå¶åŸ¡
éä¿¡ãããã±ãããé çªãå ¥ãæ¿ãã£ãŠå°çããå¯èœæ§ããã. éä¿¡ãããã±ããã«ã¯çªå·ãä»ããããŠãã, åä¿¡åŽã§ã¯ãã±ãããçªå·é ã«äžŠã¹æ¿ããŠããå ã®ããŒã¿ã埩å ã, ãããäžäœã®ã¢ããªã±ãŒã·ã§ã³ãžæž¡ãããã«ãªã£ãŠãã.
环ç©ç確èªå¿ç
å°çããŠãããã¹ãŠã®ã»ã°ã¡ã³ãã«ã€ããŠ, ãã®æ¬¡ã«å°çããããšãæåŸ ããŠããã·ãŒã±ã³ã¹çªå· + 1 ã ã確èªå¿ççªå·ãšããŠè¿ã.
éžæç確èªå¿ç
é 延確èªå¿ç
é£ç¶ããããŒã¿ã¯é 延ãå ¥ããããšã§ãããã¡ã«è²¯ããŠ, ãŸãšããŠéåºããããšã§, ãããã¯ãŒã¯äžã«æµãããã±ããã®æ°ãæžãããŠ, ãããã®ãªãŒãããããå°ãããã.
é 延æé㯠Nagle ã¢ã«ãŽãªãºã ã§æ±ºå®ãã.
ãªã¢ã«ã¿ã€ã ã«éä¿¡ãããå Žåã¯, TCP ãªãã·ã§ã³ã§ Nagle ã¢ã«ãŽãªãºã ãç¡å¹ã«ãã.
ãããŒå¶åŸ¡
TCP ãããã³ã«ã«ãããéåä¿¡ã§ã¯, ã·ãŒã±ã³ã¹çªå·ãšãŠã£ã³ããŠã»ãµã€ãºãéèŠãªæå³ãæã€.
- ã·ãŒã±ã³ã¹çªå·ã¯, ããããéåä¿¡ããããšããŠããããŒã¿ã®äœçœ®
- ãŠã£ã³ããŠã»ãµã€ãºã¯éä¿¡å¯èœãªããŒã¿ã®æ倧ãµã€ãº
åæ¹ã®ã·ãŒã±ã³ã¹çªå·ã¯åæã (åãå€ãä¿æããŠãã), åããŠã£ã³ããŠã»ãµã€ãºæ å ±ãå ±æããŠãã.
- ã·ãŒã±ã³ã¹çªå·æ å ±ã¯éä¿¡åŽ
- ãŠã£ã³ããŠã»ãµã€ãºæ å ±ã¯åä¿¡åŽ
ã·ãŒã±ã³ã¹çªå·
ãã€ãåäœã®ã¹ããªãŒã åéä¿¡ãå®çŸãããã, TCP ã§ã¯éä¿¡è·¯å ãæµãããã€ãã»ããŒã¿ã«å¯ŸããŠ, ããããã®ãã€ãäœçœ®ã決ãããã·ãŒã±ã³ã¹çªå·ããå®çŸ©ããŠãã.
ã·ãŒã±ã³ã¹çªå·ã«åºã¥ããŠããŒã¿ãæŽåããã, ãŠã£ã³ããŠå¶åŸ¡ãè¡ã£ãããã
ã³ãã¯ã·ã§ã³ããšã«ã©ã³ãã ã«æ±ºãããã.
ããŒã¿éä¿¡
Step1
TCP å±€ã§ã¯, ãŠã£ã³ããŠã»ãµã€ãºã«ä»¥äžã«ãªãããã«ããŒã¿ãåãåã, å é ããé 次éä¿¡ãè¡ã.ãŠã£ã³ããŠã»ãµã€ãºä»¥äžãªãã°, äžåºŠã«éä¿¡ããããšãå¯èœ.
Step2
TCP ãã±ãããåä¿¡ããåŽã§ã¯, ããŒã¿ãåä¿¡ãããã¡ã«ã³ããŒããŠã¢ããªã±ãŒã·ã§ã³ã«éç¥ãããšåæã«,åä¿¡ããããšã瀺ã ACK ãã±ãããè¿ä¿¡ãã.
以äžããã»ãããããŠãã.
- ããŒã¿ãåä¿¡ããããšã瀺ãæŽæ°æžã¿åä¿¡ ACK çªå·
- æ°ãããŠã£ã³ããŠã»ãµã€ãº
Step3
åä¿¡åŽãéã£ã ACK ãã±ãããåãåã.
- èªèº«ã®éå§ã·ãŒã±ã³ã¹çªå·ãæŽæ°ãã
- ããã»ã©åéã«åããŠåã£ãŠãããéä¿¡ããŒã¿ã®ã³ããŒãç Žæ£ãã
- ãŠã£ã³ããŠã»ãµã€ãºã, ACK ãã±ããã§éç¥ããããã®ã«æŽæ°ãã.
Step4
TCP/IP ã®ãããã³ã«ã»ã¹ã¿ãã¯ã§ã¯, åä¿¡ãããã¡ããã¢ããªã±ãŒã·ã§ã³ã«ããŒã¿ãåŒãæž¡ãã, 空ããå¢ããå Žåã«ãŠã£ã³ããŠã»ãµã€ãºãå¢å ããã.
茻茳å¶åŸ¡
茻茳ã¯, ãµããããšãã.
以äžã®äºã€ã§èŒ»èŒ³ãé¿ããä»çµã¿.
- ã¹ããŒã¹ã¿ãŒã
- 茻茳åé¿ã¢ã«ãŽãªãºã
ãŠã£ã³ããŠãµã€ãºã¯,以äžã® 2 ã€ã®å°ããæ¹ãæ¡çšãã.
- éä¿¡åŽã®èŒ»èŒ³ãŠã£ã³ããŠãµã€ãº
- åä¿¡åŽããã®åç¥ãŠã£ã³ããŠãµã€ãº
1 -> 2 -> 4 -> 8 -> 16 -> 32 (ããã§èŒ»èŒ³çºç) -> 17 -> 18 -> 19 -> 20 -> 21 -> 22 ããã§èŒ»èŒ³çºç)
1 -> 2 -> 4 -> 8 -> 16 -> 32 (ããã§èŒ»èŒ³çºç) -> 17 -> 18 -> 19 -> 20 -> 21 -> 22 ããã§èŒ»èŒ³çºç)
âŠ
ref. TCP åããŒãžã§ã³ã®èŒ»èŒ³å¶åŸ¡ã®èŠ³å¯
ã¹ããŒã¹ã¿ãŒã
茻茳ãŠã£ã³ããŠã¯ã¯ãã㯠1 ã«ã»ãããããŠ,ææ°é¢æ°çã«å¢å ããã.
茻茳ãçºçããã, 茻茳åé¿ã¢ã«ãŽãªãºã ãžç§»è¡ãã.
茻茳åé¿ã¢ã«ãŽãªãºã
çŸåšã®èŒ»èŒ³ãŠã£ã³ããŠãµã€ãºãšåãã ãã®ç¢ºèªå¿çããããšããš, ãŠã£ã³ããŠãµã€ãºã 1 ã€å¢ãã.
éä¿¡åŽã§ã¿ã€ã ã¢ãŠããæ€åºãããš, ã¹ããŒã¹ã¿ãŒããžç§»è¡ãã.
TCP ã¿ã€ãã·ã¹ãã
éèŠãªãã®ã¯ä»¥äžã® 4 ã€.
- ã¿ã€ã ã¢ãŠãã¿ã€ã ⊠ã»ã°ã¡ã³ã転éã¿ã€ã.
- æç¶ã¿ã€ã ⊠ãŒããŠã£ã³ããŠæ€æ»çš.
- çµäºæã¿ã€ã ⊠TIME-WAIT ãã CLOSED ç¶æ ãžé·ç§»ããããã®åŸ ã¡æéã¿ã€ã
- keep-alive ã¿ã€ã
Keep-Alive
ãã 2 ã€ã®æ©åšéã®éä¿¡æ¥ç¶ã«ãããŠ, çžæã掻ããŠãããã確èªããã®æ¥ç¶ãç¶æããä»çµã¿.
ããŒã¿éä¿¡ãäœãè¡ãããªãå Žåã§ã, äžå®æéééã§ç©ºã® TCP ãã±ãããéåä¿¡ããããšã«ãã, TCP æ¥ç¶ãã¢ã¯ãã£ãã§ããããšããäºãã«éç¥, 確èªããããã®éä¿¡æ©èœ.
äœãéä¿¡ãè¡ããªãã§ãããš, ç¡éä¿¡ã§åç·ãåæãããŠããŸã£ãã, TCP æ¥ç¶ãã¿ã€ã ã¢ãŠãããŠåæãããŠããŸã£ããããã®ã§, ããŒãã»ã¢ã©ã€ãã§ãããé²ãããšãã§ãã.