Linux ÏÂTCPÁ¬½Ó¹Ø±ÕÇé¿ö·ÖÎö
Ò»¡¢TCPÁ¬½Ó¹Ø±ÕµÄ¼¸ÖÖ·½Ê½£º
1¡¢“Õý³£”¹Ø±Õ£ºµ÷ÓÃclose()¹Ø±Õsocket¡¢Ã»closeµ«½ø³ÌÕý³£½áÊø(µ±È»ÕâÊDz»Ó¦¸ÃµÄ×ö·¨)¡¢½ø³Ìcoreµô¡¢ÔÚshellÃüÁîÐÐÖÐkillµô½ø³Ì£¬¶¼¿É³éÏó³É“Õý³£”¹Ø±Õ¡£ÒòΪ¼´Ê¹coreµô£¬ÄÚºËÒ²»áÂíÉÏ°ïÓ¦ÓóÌÐò»ØÊÕ(close)socketÎļþÃèÊö·û¡£
“Õý³£”¹Ø±Õ£¬Ä¬ÈÏÇé¿öÏÂ(·ÇĬÈϼ´ÉèÖÃLingerÏÂÃæ»á½éÉÜ)£¬¹Ø±Õ¶Ë¼´¿Í»§¶ËTCP²ã»á·¢FIN°ü£¬¶Ô¶Ë¼´·þÎñÆ÷TCP²ãÊÕµ½ºó£¬»ØACK£¬¿Í»§¶Ë½øÈëFIN_WAIT2״̬¡£´Ëʱ£¬TCPÖÕÖ¹Á¬½ÓµÄ4¸ö·Ö×éÖзþÎñÆ÷Ó¦¸Ã·¢µÄµÚ3¸ö·Ö×éFIN°ü£¬ÆäTCP²ãÊDz»»áÖ÷¶¯·¢µÄ£¬Ö»ÓзþÎñÆ÷¶Ësocket“Õý³£”¹Ø±Õ£¬²Å»á·¢³öÕâ¸öFIN°ü¡£ÖÁ´Ë£¬¿Í»§¶Ë½øÈëTIME_WAIT״̬¡£
2¡¢“·Ç”Õý³£¹Ø±Õ£º¿Í»§¶Ë±ÀÀ£ÁË£¬´Ëʱ¿Ï¶¨·¢²»³öFIN°üÁË(µ±È»À²£¬Äں˶¼Ã»»ú»á°ïÓ¦ÓóÌÐò»ØÊÕ×ÊÔ´ÁË)¡£ÕâÖÖÇé¿ö£¬·þÎñÆ÷¶ËÓÐÈçÏÂÁ½ÖÖÇé¿ö£º
A¡¢·þÎñÆ÷sendÊý¾Ý£¬ÒòΪ¿Í»§¶ËÒѾ±ÀÀ££¬·þÎñÆ÷ÊÕ²»µ½ACK×ÔÈ»»á²»Í£µÄÖØ´«¡£Ô´×Ô
BerkeleyµÄÖØ´«»úÖÆ£¬ÖØ´«8´Î£¬Ïà¶ÔµÚÒ»´Î´«µÄ15·ÖÖÓºóÈÔûÊÕµ½ACK£¬Ôò·µ»Ø
ETIMEDOUT»òEHOSTUNREAC´íÎó¡£Èç¹û·þÎñÆ÷²»Àí»áÕâ¸ö´íÎó£¬Ôٴε÷ÓÃsend£¬Ôò
Á¢Âí·µ»ØBroken Pipe´íÎó¡£
×¢£º15·ÖÖÓ³¬Ê±¿ÉÒÔÔÚ /proc/sys/net/ipv4/tcp_retries2 ÖÐÐÞ¸Ä
B¡¢ ·þÎñÆ÷²»·¢ÈκÎÊý¾ÝÁË£¬ÄÇÖ»Óп¿Ó¦ÓòãÐÄÌø¼ì²â»úÖÆ»òKeepalive£¬À´·¢¾õTCP¶ÏÁ¬ÁË¡£
¶þ¡¢SO_LINGERÌ×½Ó¿ÚÑ¡Ïî
A¡¢l_onoffÉèÖÃΪ0£¬ÕâÒ²ÊÇĬÈÏÇé¿ö£¬º¯Êýclose()ÊÇÁ¢¼´·µ»ØµÄ£¬È»ºóTCPÁ¬½ÓË«·½ÊÇͨ¹ý
FIN¡¢ACK4·Ö×éÀ´ÖÕÖ¹TCPÁ¬½ÓµÄ¡£µ±È»,·¢ËÍ»º³åÇø»¹ÓÐÊý¾ÝµÄ»°£¬ÏµÍ³½«ÊÔ׎«ÕâЩÊý¾Ý
·¢Ë͵½¶Ô·½¡£
B¡¢l_onoff·Ç0£¬l_lingerÉèÖÃ0£¬º¯Êýclose()Á¢¼´·µ»Ø£¬²¢·¢ËÍRSTÖÕÖ¹Á¬½Ó£¬·¢ËÍ»º³åÇøµÄÊý¾Ý¶ªÆú¡£
&
Ïà¹ØÎĵµ£º
1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......
Óùý aMule ¶¼ÖªµÀ£¬ÎÞÂÛÔõôÉèÖã¬ËüµÄËٶȶ¼²»ÁîÈËÂúÒâ¡£ÄÇôÔÚ Ubuntu ϳýÁË mldonkey »¹ÓÐʲôºÃÓõÄ¿×Ó£¿´ð°¸ÊÇ wine+emule£¬²»ÓÃÔõôÉèÖÃËÙ¶ÈÇáÇáËÉËɾÍÄÜ´ïµ½·åÖµ¡£Õâô×ö¿ÉÄÜһЩ Linux ËÀÖÒÃǻ᲻м£¬µ«ÎÞ¿É·ñÈÏ emule ¾ø¶Ô±È amule ÓÅÐ㣬¼ÈÈ»ÄÜÓÃΪʲô²»ÓÃÄØ£¿ÔÚ Windows ÉÏÎÒ¶¼»¹Óà mplayer ÄØ¡£
ÔÚ Ubu ......
Îļþϵͳ¹ÒÔØ£ºmount
¸ñʽ£ºmount [-²ÎÊý] [É豸Ãû³Æ] [¹ÒÔصã]
ÆäÖг£ÓõIJÎÊý£º
¡¡¡¡ -t Ö¸¶¨É豸µÄÎļþϵͳÀàÐÍ£¬³£¼ûµÄÓУº
¡¡¡¡ minix linux×îÔçʹÓõÄÎļþϵͳ
¡¡¡¡ ext2 linuxÄ¿Ç°³£ÓõÄÎļþϵͳ
¡¡¡¡ msdo ......
ϵͳµ÷ÓÃÊÇÓ¦ÓóÌÐòºÍ²Ù×÷ϵͳÄÚºËÖ®¼äµÄ¹¦Äܽӿڡ£ÆäÖ÷ҪĿµÄÊÇʹµÃÓû§
¿ÉÒÔʹÓòÙ×÷ϵͳÌṩµÄÓйØÉ豸¹ÜÀí¡¢ÊäÈë/ÊäÈëϵͳ¡¢ÎļþϵͳºÍ½ø³Ì¿ØÖÆ¡¢
ͨÐÅÒÔ¼°´æ´¢¹ÜÀíµÈ·½ÃæµÄ¹¦ÄÜ£¬¶ø²»±ØÁ˽âϵͳ³ÌÐòµÄÄÚ²¿½á¹¹ºÍÓйØÓ²¼þϸ
½Ú£¬´Ó¶øÆðµ½¼õÇáÓû§¸ºµ£ºÍ±£»¤ÏµÍ³ÒÔ¼°Ìá¸ß×ÊÔ´ÀûÓÃÂʵÄ×÷Óá£
¡¡¡¡Linux²Ù×÷ϵͳ ......