1.ãã£ããã£ãã£ã«ã¿ãŒ
ãã©ãã£ãã¯ã¢ãã©ã€ã¶ãŒã¯ããããã¯ãŒã¯ç®¡çè ã®ç掻ã®äžã§äŸ¿å©ã§å¹æçãªããŒã«ã§ããããããã¯ãŒã¯äžã§å®éã«éä¿¡ããããã®ããèŠããããšãã§ããŸããããã«ãããããŸããŸãªåé¡ã®èšºæãç¹å®ã®ãããã³ã«ããã³ãã¯ãããžãŒã®åäœåçã®ç 究ãç°¡çŽ åãããŸã
ãã ããå€ãã®ããŸããŸãªããŒã¿ãããã¯ããããã¯ãŒã¯äžã§éä¿¡ãããããšãå€ãããããã¯ãŒã¯ã€ã³ã¿ãŒãã§ã€ã¹ãééãããã¹ãŠã匷å¶çã«è¡šç€ºããå Žåãæ¬åœã«å¿ èŠãªãã®ã匷調衚瀺ããããšãåé¡ã«ãªãå¯èœæ§ããããŸãã
ãã®åé¡ã解決ããããã«ããã©ãã£ãã¯ã¢ãã©ã€ã¶ãŒã¯ããã£ããã£ãã£ã«ã¿ãŒãšãã£ã¹ãã¬ã€ãã£ã«ã¿ãŒã®2ã€ã®ã¿ã€ãã«åãããããã£ã«ã¿ãŒãå®è£ ããŠããŸãã ä»æ¥ã¯ãæåã®ã¿ã€ãã®ãã£ã«ã¿ãŒããã£ããã£ãã£ã«ã¿ãŒã«ã€ããŠèª¬æããŸãã
ãã£ããã£ãã£ã«ã¿ãŒã¯ãåæã«å¿ èŠãªãã¬ãŒã ã®ã¿ã«ãã¬ãŒã ã®ãã£ããã£ãå¶éã§ãããã£ã«ã¿ãŒã®äžçš®ã§ããããã«ãããã³ã³ãã¥ãŒã¿ãŒã®ã³ã³ãã¥ãŒãã£ã³ã°ãªãœãŒã¹ã®è² è·ã軜æžãããã©ãã£ãã¯ã®åæããã»ã¹ãç°¡çŽ åããŸãã
2.ãã£ããã£ãã£ã«ã¿ãŒã®æ§æ
ãã£ããã£ãã£ã«ã¿åŒã¯ãããããåé¡åãšãªããžã§ã¯ãèå¥åïŒã¢ãã¬ã¹ããããã¯ãŒã¯ãªããžã§ã¯ãã®ååãããŒãçªå·ïŒããæ§ç¯ãããäžé£ã®ç¹å¥ãªããªããã£ãã§æ§æãããŸãã
泚æ ïŒãã¹ãŠã®åé¡åã¯å€§æåãšå°æåãåºå¥ããããããå°æåã§ã®ã¿èšè¿°ããå¿ èŠããããŸãã
ãããã«ã€ããŠããã«è©³ããèŠãŠãããŸãããã
åé¡åã«ã¯æ¬¡ã®çš®é¡ããããŸãã
- type-ãªããžã§ã¯ãã¿ã€ã
- host -hostïŒããã©ã«ãã®ã¿ã€ããã¿ã€ããæå®ãããŠããªãå Žåãããã¯ãã¹ãã§ãããšæ³å®ãããŸãïŒ
- net-ãããã¯ãŒã¯
- ããŒã -ããŒã
äŸ ïŒ
ãã¹ã192.168.0.1 -IP 192.168.0.1ãã¢ãã¬ã¹ïŒéä¿¡è ãŸãã¯åä¿¡è ïŒãšããŠäœ¿çšããããã©ãã£ãã¯ãã£ããã£
net 172.16.0.0/16-ã¢ãã¬ã¹ïŒéä¿¡è ãŸãã¯åä¿¡è ïŒããããã¯ãŒã¯172.16.0.0/16ããã®IPïŒããæ£ç¢ºã«ã¯ã172.16.0.0ãã172.16.255.255ã®ç¯å²å ïŒã§ãããã©ãã£ãã¯ãã£ããã£ãäžèŽããã¢ãã¬ã¹ã®æ€çŽ¢ãã£ã«ã¿ãŒã§ããã€ã³ã¿ãŒãã§ã€ã¹ã§ã©ã®ãã¹ã¯ãèšå®ãããŠãããã¯é¢ä¿ãããŸãããmask/ 16ã«ãã172.16.0.0ããããã¯ãŒã¯çªå·ã§ãããšæ··åããªãã§ãã ãããã€ã³ã¿ãŒãã§ã€ã¹ã§ã©ã®ãã¹ã¯ãèšå®ãããŠãããã¯å®å šã«ã¯ããããŸããã
ããŒã80-ããŒã80ïŒudpãŸãã¯tcpïŒã«å±ããããŒã¿ããããã©ãã£ãã¯ãã£ããã£
10.0.0.1-ã¢ãã¬ã¹ïŒéä¿¡è ãŸãã¯åä¿¡è ïŒãIP 10.0.0.1ã§ãããã©ãã£ãã¯ãã£ããã£ããã¹ãåé¡åã¯æå®ãããŠããŸããããããã©ã«ãã§æ³å®ãããŠããŸãã
- dir-ãªããžã§ã¯ãã«çžå¯Ÿçãªæ¹åïŒæ¹åïŒ
- src-ãªããžã§ã¯ãã¯éä¿¡è ã§ã
- dst-ãªããžã§ã¯ãã¯åä¿¡è ã§ã
äŸ ïŒ
src host 192.168.0.1 -IPã¢ãã¬ã¹192.168.0.1ãéä¿¡è ïŒåä¿¡è ã§ã¯ãªãïŒã®ã¢ãã¬ã¹ãšããŠäœ¿çšããããã©ãã£ãã¯ãã£ããã£
dst net 172.16.0.0/16-åä¿¡è ïŒéä¿¡è ã§ã¯ãªãïŒã®ã¢ãã¬ã¹ããããã¯ãŒã¯172.16.0.0/16ããã®IPã§ãããã©ãã£ãã¯ãã£ããã£ïŒããæ£ç¢ºã«ã¯ã172.16.0.0ãã172.16.255.255ã®ç¯å²å ïŒã
- proto-çžäºäœçšãããã³ã«
- ether-åºæ¬çãªã€ãŒãµããããããã¯ãŒã¯ãã¯ãããžãŒãéåžžããã£ã«ã¿ãŒãããŒããŠã§ã¢MACã¢ãã¬ã¹ã䜿çšããããšã瀺ããŸã
- ip -IPv4ãããã³ã«
- ip6 -IPv6ãããã³ã«
- arp -ARPãããã³ã«
- tcp -TCPãããã³ã«
- udp -UDPãããã³ã«
- ãããã³ã«ãæå®ãããŠããªãå Žåããªããžã§ã¯ãã®ã¿ã€ããšäºææ§ã®ãããã¹ãŠã®ãã©ãã£ãã¯ããã£ããã£ããå¿ èŠããããšèŠãªãããŸã
äŸ ïŒ
src ether host 00ïŒ11ïŒ22ïŒ33ïŒ44ïŒ55-00ïŒ11ïŒ22ïŒ33ïŒ44ïŒ55ãéä¿¡è ã®MACã¢ãã¬ã¹ãšããŠäœ¿çšããããã©ãã£ãã¯ãã£ããã£ã
ip icmp -ICMPãã±ããããã£ããã£ããŸãã
tcpããŒã80 -TCPããŒã80ã«å±ããããŒã¿ããããã©ãã£ãã¯ãã£ããã£
ãã£ã«ã¿ã«ã¯ããªããžã§ã¯ãèå¥åãšåé¡åã«å ããŠãããŒã¯ãŒãgateway ã broadcast ã multicast ã less ã greatãããã³ç®è¡åŒãå«ããããšãã§ããŸãã
äŸ ïŒ
ip multicast-ã¯ã©ã¹Dããã®ã¢ãã¬ã¹ãå«ãipãã±ããããã£ããã£ããŸãã
1000æªæº -ãµã€ãºã1000ãã€ãæªæºã®ãã¬ãŒã ããã£ããã£ããŸãã
è«çæŒç®ã䜿çšãããšãå€æ°ã®æ¡ä»¶ãçºçããå¯èœæ§ããããŸãã
- ããããŠã-ãããŠïŒ&&ïŒ
- ãŸãã¯-ãŸãã¯ïŒ||ïŒ
- ãNOTã-notïŒïŒïŒ-å€ã®é
ãããã®æäœã®åªå é äœã¯æ¬¡ã®ãšããã§ãã
- å転æäœãæé«ã®åªå 床ãæã¡ãŸã
- è«ççãªãANDã
- æäœã®åªå é äœã¯æäœãORãã§ãã
éåžžã®æ°åŒãšåæ§ã«ãæ¬åŒ§ïŒïŒã䜿çšããŠåªå é äœãå€æŽã§ããŸããæ¬åŒ§ã¯æåã«å®è¡ãããã¢ã¯ã·ã§ã³ã§ãã
äŸ ïŒ
net 192.168.0.0/24ããã³tcpããŒã21-ãããã¯ãŒã¯ïŒç¯å²ïŒ192.168.0.0/24ïŒéä¿¡è ãŸãã¯åä¿¡è ïŒã«å±ãããã©ãã£ãã¯ããã£ããã£ããTCPçµç±ã§ããŒã21ã䜿çšããŠããŒã¿ãéä¿¡ããŸãã
ãã¹ã192.168.0.1ãŸãã¯ãã¹ã192.168.0.221-ãã¹ã192.168.0.1ãŸãã¯ãã¹ã192.168.0.221ã®ããããã«å±ãããã©ãã£ãã¯ã®ãã£ããã£ïŒéä¿¡è ã誰ã§ããããåä¿¡è ã誰ã§ãããã¯é¢ä¿ãªãã2ã€ã®æ¡ä»¶ã®1ã€ã§ããããã®å°ãªããšã1ã€ãäœæããã«ã¯ãã¬ãŒã ã«ã¢ãã¬ã¹ãååšããŠããŸããïŒ
ãã¹ã192.168.0.1ãŸãã¯ãã¹ã192.168.0.2ãštcpããŒã22-ãã¹ã192.168.0.1ã«å±ãããã©ãã£ãã¯ããŸãã¯ãã¹ã192.168.0.2ã«å±ããããŒã22ã䜿çšããTCPãããã³ã«ããã®ãã©ãã£ãã¯ããã£ããã£ããŸãã
ïŒãã¹ã192.168.0.1ãŸãã¯ãã¹ã192.168.0.2ïŒããã³tcpããŒã22 -TCPãããã³ã«ãã©ãã£ãã¯ããã£ããã£ãããã¹ã192.168.0.1ãŸãã¯ãã¹ã192.168.0.2ïŒã©ã¡ããããŸãã¯äž¡æ¹ïŒã«å±ããããŒã22ã䜿çšããŸãã
ïŒãã¹ã192.168.0.1 ||ãã¹ã192.168.0.1ïŒ&& not tcp port 22 -TCPãããã³ã«ãã©ãã£ãã¯ãé€ããã¹ãŠã®ãã©ãã£ãã¯ããã£ããã£ãããã¹ã192.168.0.1ãŸãã¯ãã¹ã192.168.0.2ïŒã©ã¡ããããŸãã¯äž¡æ¹ïŒã«å±ããããŒã22ã䜿çšããŸãã
ãã£ã«ã¿ãŒã«è€æ°ã®åäžã®ç¹°ãè¿ãåé¡åãããå Žåãã¬ã³ãŒããæžããããã«ããããçç¥ããããšãã§ããŸãã
äŸ ïŒ
net 192.168.0.0/24ããã³ïŒtcpããŒã21ãŸãã¯tcpããŒã20ãŸãã¯tcpããŒã25ãŸãã¯tcpããŒã80ãŸãã¯tcpããŒã110ïŒ
ã«æžããããšãã§ããŸã
ããã192.168.0.0/24ããã³ïŒtcpããŒã21ãŸãã¯20ãŸãã¯25ãŸãã¯80ãŸãã¯110ïŒ
泚æ ïŒ
ã¢ãã¬ã¹ã1.1.1.1ããã³1.1.1.2ã®ãã±ãããé€å€ããåŒïŒ
notïŒãã¹ã1.1.1.1ããã³ãã¹ã1.1.1.2ïŒ
次ã®ããã«ççž®ã§ããŸãã
notïŒãã¹ã1.1.1.1ããã³1.1.1.2ïŒ
ãããã奜ãã§ã¯ãããŸããïŒ
ãã¹ã1.1.1.1ããã³1.1.1.2ã§ã¯ãããŸãã -ãã®å Žåãæåã®ã¢ãã¬ã¹ããªãã2çªç®ã®ã¢ãã¬ã¹ããããã±ããã衚瀺ãããŸãã
ããã§ã¯ãªã
notïŒãã¹ã1.1.1.1ãŸãã¯1.1.1.2ïŒ -ãã®å Žåãæå®ããã2ã€ã®ã¢ãã¬ã¹ã®å°ãªããšã1ã€ãååšãããã±ããã¯é€å€ãããŸãã
ãã£ããã£ãã£ã«ã¿ãŒã®äœæã«äœ¿çšã§ããåºæ¬çãªããªããã£ãã®ãªã¹ããè¡š2-1ã«ç€ºããŸãã
è¡š2-1ã ãã£ããã£ãã£ã«ã¿ãŒã®äœæã«äœ¿çšã§ããåºæ¬çãªããªããã£ãã®ãªã¹ãã
åå§ç | 説æ |
dst host ip_address | å®å IPv4 / IPv6ããããŒã«æå®ããããã¹ãã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
src host ip_address | IPv4 / IPv6ããããŒã®ããããŒã®éä¿¡è ã¢ãã¬ã¹ãã£ãŒã«ãã«æå®ããããã¹ãã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
ãã¹ãip_address | IPv4 / IPv6ããããŒã«æå®ããããã¹ãã¢ãã¬ã¹ãããããŒã®éä¿¡è
ãŸãã¯åä¿¡è
ã¢ãã¬ã¹ãã£ãŒã«ãã«å«ãŸããŠãããã¬ãŒã ããã£ããã£ããŸãã
ãã£ã«ã¿ãŒãšåçïŒ ether proto ipããã³ãã¹ãip_address |
ãšãŒãã«dst mac_address | ããŒãã®æå®ãããMACã¢ãã¬ã¹ããªã³ã¯ã¬ã€ã€ãŒããããŒã®åä¿¡è ã®ã¢ãã¬ã¹ãã£ãŒã«ãã«ãããã¬ãŒã ããã£ããã£ãã |
ether src mac_address | ãªã³ã¯ã¬ã€ã€ãŒããããŒã®éä¿¡è ã¢ãã¬ã¹ãã£ãŒã«ãã§æå®ãããããŒãã®MACã¢ãã¬ã¹ã«å«ãŸãããã¬ãŒã ããã£ããã£ãã |
ãšãŒãã«ãã¹ãmac_address | ãªã³ã¯ã¬ã€ã€ãŒããããŒã®éä¿¡è ãŸãã¯åä¿¡è ã®ã¢ãã¬ã¹ãã£ãŒã«ãã«æå®ãããããŒãã®MACã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ããŸãã |
dst netãããã¯ãŒã¯ | IPv4 / IPv6ããããŒã¢ãã¬ã¹ãã£ãŒã«ãã«ãæå®ãããã¯ã©ã¹ãããã¯ãŒã¯ã®ç¯å²ã«å±ããæå®ãããã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
src netãããã¯ãŒã¯ | IPv4 / IPv6ããããŒã«ãæå®ãããã¯ã©ã¹ãããã¯ãŒã¯ç¯å²ã®éä¿¡è ã¢ãã¬ã¹ãã£ãŒã«ãã«æå®ãããã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
ããããããã¯ãŒã¯ | éä¿¡è ãŸãã¯åä¿¡è ãã£ãŒã«ãã«æå®ããããããã¯ãŒã¯ããã®ã¢ãã¬ã¹ãå«ããã¹ãŠã®IPv4 / IPv6ãã±ãããéžæããŸã |
ããããããã¯ãŒã¯ãã¹ã¯ãã¹ã¯ | IPv4 / IPv6ããããŒã®æå®ããããããã¯ãŒã¯ç¯å²ã®éä¿¡è ãŸãã¯åä¿¡è ã¢ãã¬ã¹ãã£ãŒã«ãã«æå®ãããã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
ããããããã¯ãŒã¯/ mask_length | IPv4 / IPv6ããããŒã®æå®ããããããã¯ãŒã¯ç¯å²ã®éä¿¡è ãŸãã¯åä¿¡è ã¢ãã¬ã¹ãã£ãŒã«ãã«æå®ãããã¢ãã¬ã¹ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
dstããŒãport | UDPãŸãã¯TCPããããŒã®å®å ããŒãã«æå®ã®ãââãŒãçªå·ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
src portããŒã | UDPãŸãã¯TCPããããŒããŒãã«æå®ãããããŒãçªå·ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
ããŒãããŒã | UDPãŸãã¯TCPããããŒããŒãã«æå®ãããããŒãçªå·ãå«ãŸãããã¬ãŒã ããã£ããã£ãã |
ããçãé·ã | æå®ããå€ä»¥äžã®ãã¬ãŒã ããã£ããã£ããŸã |
ããé·ã | ãµã€ãºãæå®å€ããå°ãããªããã¬ãŒã ããã£ããã£ããŸã |
IPãããã³ã« | [ãããã³ã«]ãã£ãŒã«ãã«æå®ããããããã³ã«ã®èå¥åãIPv4ããããŒã«å«ãŸãããã¬ãŒã ããã£ããã£ããŸãã ãã®å Žåããããã³ã«ã®æ°å€ã ãã§ãªããæšæºåïŒicmpãigmpãigrpãpimãahãespãvrrpãudpãtcpãªã©ïŒãæå®ã§ããŸãã ãã ããtcpãudpãããã³icmpãããŒã¯ãŒããšããŠäœ¿çšãããããããããã®ã·ã³ããªãã¯èå¥åã®åã«ããã¯ã¹ã©ãã·ã¥æåïŒ "\"ïŒãè¿œå ããå¿ èŠãããããšã«æ³šæããŠãã ããã |
ip6 protoãããã³ã« | [ãããã³ã«]ãã£ãŒã«ãã«æå®ããããããã³ã«ã®èå¥åãIPv4ããããŒã«å«ãŸãããã¬ãŒã ããã£ããã£ããŸãã ããã«ããããã³ã«ã®æ°å€ã ãã§ãªããæšæºåïŒicmp6ãigmpãigrpãpimãahãespãvrrpãudpãtcpãªã©ïŒãæå®ã§ããŸãã ãã ããtcpãudpãããã³icmp6ãããŒã¯ãŒããšããŠäœ¿çšãããããããããã®ã·ã³ããªãã¯èå¥åãããã¯ã¹ã©ãã·ã¥æåïŒ "\"ïŒã®åã«ããããšã«æ³šæããŠãã ããã |
ãšãŒãã«æŸé | ãã¹ãŠã®ãããŒããã£ã¹ãã€ãŒãµããããã¬ãŒã ããã£ããã£ããŸãã EtherããŒã¯ãŒãã¯çç¥å¯èœ |
IPãããŒããã£ã¹ã | IPv4ãã±ããããããŒã«ãããŒããã£ã¹ãã¢ãã¬ã¹ãå«ããã¬ãŒã ããã£ããã£ããŸãã ãã®å Žåãã¢ãã¬ã¹ããããŒããã£ã¹ããã©ãããå€æããããã«ããã±ããã®ãã£ããã£ã«äœ¿çšãããã€ã³ã¿ãŒãã§ã€ã¹ã«ãµãããããã¹ã¯ã䜿çšãããŸãã ãŸããå¶éããããããŒããã£ã¹ãã¢ãã¬ã¹ã«éä¿¡ããããã±ããããã£ããã£ããŸã |
ãšãŒãã«ãã«ããã£ã¹ã | ãã¹ãŠã®ã€ãŒãµããããã«ããã£ã¹ããã¬ãŒã ããã£ããã£ããŸãã EtherããŒã¯ãŒãã¯çç¥å¯èœ |
IPãã«ããã£ã¹ã | IPv4ãã±ããããããŒã«ãã«ããã£ã¹ãã¢ãã¬ã¹ãå«ããã¬ãŒã ããã£ããã£ãã |
ip6ãã«ããã£ã¹ã | IPv6ãã±ããããããŒã«ãã«ããã£ã¹ãã¢ãã¬ã¹ãå«ããã¬ãŒã ããã£ããã£ãã |
ãšãŒãã«ãããã¿ã€ãprotocol_type | æå®ããããããã³ã«ã¿ã€ãã§ã€ãŒãµããããã¬ãŒã ããã£ããã£ããŸãã ãããã³ã«ã¯ãçªå·ãŸãã¯ååïŒipãip6ãarpãrarpãatalkãaarpãdecnetãscaãlatãmopdlãmoprcãisoãstpãipxãnetbeuiïŒã§æå®ã§ããŸãã |
ipãip6ãarpãrarpãatalkãaarpãdecnetãisoãstpãipxãnetbeuiãtcpãudpãicmp | æå®ããããããã³ã«ã®ããŒã¿ãéä¿¡ãããã¬ãŒã ããã£ããã£ããŸãã 以äžã®ç¥èšãšããŠäœ¿çšãããŸãã
ãšãŒãã«ããããããã³ã« |
vlan [vlan_id] | IEEE 802.1Qã«æºæ ãããã¬ãŒã ããã£ããã£ããŸãã vlan_idãæå®ãããŠããå Žåãæå®ãããVLANã«å±ãããã¬ãŒã ã®ã¿ããã£ããã£ãããŸã |
3.ãã£ããã£ãã£ã«ã¿ãŒã®é«åºŠãªäŸ
ãã£ããã£ãã£ã«ã¿å ã®ã¢ãã¬ã¹ãšãããã³ã«ã®åçŽãªè¡šç€ºã«å ããŠããã埮åŠãªããããŒåæãå¯èœã«ããããè€éãªæ§æã䜿çšã§ããŸãã
ããã«ã¯ã次ã®åœ¢åŒã®è«çå€ãè¿ãåŒã䜿çšãããŸãã
åŒæŒç®åŒ
åŒã¯å®æ°ãç®è¡æŒç®ïŒ+ã-ã*ã/ïŒãŸãã¯2é²ãããæŒç®ïŒïŒ-ãANDãã|-ãORãã<<-å·Šãžã·ããã>>-å³ãžã·ããïŒã®çµæã«ãªããŸããæŒç®åã¯long offset ãããŒã¿ãŸãã¯ããããŒãã£ãŒã«ããã£ãŒã«ãã§ãã èšå·ã>ãïŒãã£ãšïŒãã<ãïŒããå°ãªãïŒãã> =ãïŒããçããïŒãã<=ãïŒããå°ãªãïŒãã=ãïŒçããïŒããïŒ=ãæäœãšããŠäœ¿çšã§ããŸãïŒçãããªãïŒã ãããã£ãŠãç¹å®ã®ãã£ãŒã«ããŸãã¯ãã¬ãŒã ã®ãã€ãã®å¿ èŠãªå€ãšã®äžèŽãŸãã¯äžäžèŽããã§ãã¯ããç°ãªãããããŒãã£ãŒã«ããäºãã«æ¯èŒãããããã«å¯ŸããŠããã€ãã®ç®è¡ããã³è«çæŒç®ãå®è¡ãããããã®æŒç®ã®çµæãç¹å®ã®å€ãšæ¯èŒããããšãã§ããŸãã
é«åºŠãªãã£ã«ã¿ãŒã䜿çšããæãç°¡åãªäŸã¯ã 5 = 3 + 1 ãã§ãã 5 ããšã 3 + 1 ãã¯åŒã§ãã = ãã¯æŒç®ã§ãã ãã®æååãèšç®ããçµæãããŒã«å€ããã®å Žåã¯falseãè¿ãããŸã ã
ããŒã¿ãŸãã¯ãã¬ãŒã ããããŒãååŸããã«ã¯ã proto [ offset ïŒ size ]ããªããã£ãã䜿çšãããŸãã
泚 ïŒãã®å Žåã®è§æ¬åŒ§ã¯æ§æèŠçŽ ã§ããããªãã·ã§ã³ãã£ãŒã«ãã®èšå·ã§ã¯ãããŸããã
protoãã©ã¡ãŒã¿ãŒã«ã¯ãããããŒããç¹å®ã®ããŒã¿ïŒetherãfddiãtrãwlanãpppãslipãlinkãipãarpãrarpãtcpãudpãicmpãip6ãªã©ïŒãéžæããå¿ èŠããããããã³ã«ã®ååãå«ãŸããŠããŸãã
offsetãã©ã¡ãŒã¿ã¯ãæå®ããããããã³ã«ã®ããããŒã®å é ããã®ãªãã»ããããã€ãåäœã§ç€ºããŸãããã€ãã®çªå·ã¯0ããå§ãŸããŸããip[0]ã¯IPãã±ããã®å é ããã®æåã®ãã€ãã tcp [1]ã¯TCPã»ã°ã¡ã³ãã®å é ãã2çªç®ã®ãã€ãã ether [3]ã¯4çªç®ã®ãã€ãã§ãã€ãŒãµããããã¬ãŒã ã®å é ããã
sizeãã©ã¡ãŒã¿ãŒã¯ã offsetã§æå®ããããã€ãããéå§ããŠãååŸãããã€ãæ°ã瀺ããŸããsizeãã£ãŒã«ãã¯ãªãã·ã§ã³ã§ããååšããªãå Žåã¯ã1ãã€ããååŸããå¿ èŠããããšèŠãªãããŸããip[2ïŒ2]-3çªç®ãšIPãã±ããã®å é ãã4çªç®ã®ãã€ãã tcp [4]-TCPã»ã°ã¡ã³ãã®å é ãã5çªç®ã®ãã€ãã ether [6-6] -ã€ãŒãµããããã¬ãŒã ã®å é ãã7çªç®ãã12çªç®ã®ãã€ãã
offsetãã£ãŒã«ãã«è² ã®å€ãèšå®ãããšã protoãã©ã¡ãŒã¿ãŒã§æå®ããããããã³ã«ããããŒã«ç§»åããåã®ããããŒã®ãã€ããéžæãããŸãã ãã ããåæã«ããããããªããã£ãã§æå®ããããããã³ã«ããããŒããã¬ãŒã ã«ååšããå¿ èŠããããŸãã ãããã£ãŠããã£ã«ã¿ãŒã¯[11] = 0x37 ïŒã€ãŒãµããããã¬ãŒã ã®12çªç®ã®ãã€ããååŸããŠå€0x37ãšæ¯èŒããŸãïŒããã³ip [-3] = 0x37 ïŒIPããããŒã®åã®ããããŒã®æåŸãã3çªç®ã®ãã€ããååŸããŠæ¯èŒããŸãïŒå€ã0x37ã§ããïŒã¯åäžã§ã¯ãããŸããã æåã«ãéä¿¡è ã®MACã¢ãã¬ã¹ã37ã§çµãããã¹ãŠã®ãã¬ãŒã ãã¹ãããããã2çªç®ã«ãIPãããã³ã«ã®ååšãå¿ èŠãšãªããIPãããã³ã«ãå«ãŸãªããã¬ãŒã ïŒARPãã¬ãŒã ãªã©ïŒã¯ãã£ããã£ãããŸããã
äŸ ïŒ
åŒip [1ïŒ1]ãšip [1]ã¯åãçµæã«ãªããŸã-IPv4ããããŒã®2çªç®ã®ãã€ããéžæãããŸã
tcp [8ïŒ2]åŒã¯ãTCPããããŒã®9çªç®ãš10çªç®ã®ãã€ãïŒãœãŒã¹ããŒããã£ãŒã«ãïŒãéžæããŸãã
åŒip [-3] = 0x37ã¯ãéä¿¡è MACã¢ãã¬ã¹ãã0x37ãã§çµãããã¹ãŠã®IPv4ãã±ãããéžæããŸãã
TCPããã³UDPãããã³ã«ã®proto [ offset ïŒ size ]ã³ã³ã¹ãã©ã¯ãã䜿çšããŠããŒã¿ãéžæããå ŽåãIPãã±ããã®æçåãèæ ®ãããããšã«æ³šæããŠãã ããã ãã®çµæã tcp [0]ã¯åžžã«TCPããããŒã®æåã®ãã€ããæå³ãããã©ã°ã¡ã³ããã§ãŒã³ã®æåã®ãã©ã°ã¡ã³ãã§ã¯ãªã転éãããã±ããããŒã¿ã®æåã®ãã€ãã®éžæã«ã€ãªããããšã¯ãããŸããã
äžéšã®ãããã³ã«ã§ã¯ãç¹å®ã®ãã£ãŒã«ããšãªãã»ããå€ã¯ãæ°åã ãã§ãªãååã§ãæå®ã§ããŸãã ããšãã°ãICMPã®å Žåã icmptypeãã©ã¡ãŒã¿ãŒããµããŒããããŠãããå€icmp-echoreply ã icmp-unreach ã icmp-sourcequench ã icmp-redirect ã icmp-echo ã icmp-routeradvert ã icmp-routersolicit ã icmp-timxceed ã icmp-paramprob ã icmpã åãããšãã§ããŸã -tstamp ã icmp-tstam-preply ã icmp-ireq ã icmp-ireqreply ã icmp-maskreq ã icmp-maskreply TCPãã©ã°ãåæããã«ã¯ã tcpflagsãã©ã¡ãŒã¿ãŒèå¥åtcp-fin ã tcp-syn ã tcp-rst ã tcp-push ã tcp-ackããã³tcp-urgã䜿çšã§ããŸãã
äŸ ïŒ
åŒtcp [tcpflags]ïŒïŒtcp-syn | tcp-finïŒïŒ= 0ã¯ãã»ãã·ã§ã³ãéå§ãŸãã¯çµäºããTCPã»ã°ã¡ã³ããå«ããã¹ãŠã®ãã¬ãŒã ãéžæããŸãã
åŒi cmp [icmptype]ïŒ= Icmp-echoããã³icmp [icmptype]ïŒ= Icmp-echoreply㯠ããšã³ãŒèŠæ±ããã³ãšã³ãŒå¿çãé€ããICMPãããã³ã«ãå«ããã¹ãŠã®ãã¬ãŒã ãéžæããŸãã
ç¹å®ã®ãã€ãã®ãããã®äžéšã®ã¿ãåæããå¿ èŠãããå ŽåããããŸãã ãããã®åé¡ã解決ããã«ã¯ããããæŒç®ãANDãïŒïŒïŒã䜿çšããŸãã ããã䜿çšãããšããã€ãã®ç¹å®ã®ãããã®ã¿ãä¿åã§ããæ®ãã¯ãªã»ããã§ããŸãã
ããšãã°ããããŒããã£ã¹ããŸãã¯ã°ã«ãŒããã¬ãŒã ã«ãã£ãŠãã£ãã«ã¬ãã«ã§éä¿¡ããããã¬ãŒã ã®ã¿ãéžæããå¿ èŠããããŸãã MACã¢ãã¬ã¹ã®çš®é¡ã¯äžäœãã€ãã§å€æã§ããããšãããã£ãŠããŸãã
äœæã®çš®é¡ | 16çªç®ã®ã·ã¹ãã ã®äžäœãã€ãå€ | 2çªç®ã®ã·ã¹ãã ã®äžäœãã€ãå€ |
æåæ§\ãŠããã£ã¹ã | 00 | 0000000 0 |
ã°ã«ãŒã\ãã«ããã£ã¹ã | 01 | 0000000 1 |
管çè ãå²ãåœãŠã\管çè ID | 01 | 0000001 0 |
æŸé\æŸé | Ff | 1111111 1 |
ãã®æ å ±ã«åºã¥ããŠããããŒããã£ã¹ãã¢ãã¬ã¹ãŸãã¯ãã«ããã£ã¹ãã¢ãã¬ã¹ã§ã¯ãã¢ãã¬ã¹ã®äžäœãã€ãã®æäžäœãããã1ã§ãæ®ãã®éšåã§ã¯ãŒãã§ãããšçµè«ä»ããããšãã§ããŸãã ã¢ãã¬ã¹ã®äžäœãã€ããååŸããæäžäœããããé€ããã¹ãŠã®ãããããªã»ãããããã€ãå€ã1ã«çãããªã£ãå Žåããã®ã¢ãã¬ã¹ã¯ãããŒããã£ã¹ããŸãã¯ãã«ããã£ã¹ãã§ããããã€ãå€ããŒãã«ãªã£ãå Žåããã®ã¢ãã¬ã¹ã¯æ瀺ãŸãã¯ç®¡çã®ããããã§ããäžããããã ãã®çµæããã®ãã§ãã¯ãå®è¡ããã«ã¯ã次ã®åŒã䜿çšããå¿ èŠããããŸãïŒ ether [0]ïŒ1 = 1 ã ether [0] -ã€ãŒãµãããããããŒã®æåã®ãã€ãã®å€ãåä¿¡ãããã³1-è«çãAndããããæäœã ã " = 1 "-ãŠããããšã®äžèŽã®çµæã確èªããŸãã
ãã1ã€ã®äŸãããã«è©³ãã調ã¹ãŠã¿ãŸãããã
IPv4ããããŒã®Type Of ServiceïŒToSïŒãã£ãŒã«ãã®å 容ãååŸããå¿ èŠããããŸãã ãããè¡ãã«ã¯ãRFC-791ãåç §ãããšããã®ãã£ãŒã«ãã¯ã·ã³ã°ã«ãã€ããã£ãŒã«ãã§ãããããããŒã®2çªç®ã®ãã€ãã§ããããšãããããŸãã
3.1ã ã€ã³ã¿ãŒãããããããŒåœ¢åŒ ã€ã³ã¿ãŒãããããããŒã®å 容ã®æŠèŠã¯æ¬¡ã®ãšããã§ãã 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ |ããŒãžã§ã³| IHL |ãµãŒãã¹ã®çš®é¡| å šé·| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | èå¥|ãã©ã°| ãã©ã°ã¡ã³ããªãã»ãã| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | çåæé| ãããã³ã«| ããããŒãã§ãã¯ãµã | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | éä¿¡å ã¢ãã¬ã¹| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | å®å ã¢ãã¬ã¹| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | ãªãã·ã§ã³| ããã£ã³ã°| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+
å€ãååŸããã«ã¯ã次ã®ããªããã£ãã䜿çšããå¿ èŠããããŸãã
ip [1ïŒ1] -ãã€ãçªå·1ããå§ãŸãIPããããŒã®1ãã€ããååŸããŸãïŒãã€ãçªå·ã¯0ããå§ãŸããŸãïŒã
ããã§ããã®ãã£ãŒã«ãã®å 容ã«åºã¥ããŠãã£ã«ã¿ãŒãäœæã§ããŸãã
ToSãã£ãŒã«ãããŒãã§ããIPv4ããããŒãå«ããã¹ãŠã®ãã¬ãŒã ã衚瀺ããã«ã¯ã ip [1ïŒ1] = 0ãèšè¿°ããå¿ èŠããããŸã ã
ToSãã£ãŒã«ãããŒãã§ã¯ãªãIPv4ããããŒãå«ããã¹ãŠã®ãã¬ãŒã ã衚瀺ããå Žåã¯ã ip [1ïŒ1]ïŒ= 0ãèšè¿°ããå¿ èŠããããŸã ã
ããããRFC-791ã«ããã°ãToSãã£ãŒã«ãã¯è€åãã£ãŒã«ãã§ããã次ã®æ§é ãæã£ãŠããŸãã
0 1 2 3 4 5 6 7 + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + | | | | | | | | åªå é äœ| D | T | R | 0 | 0 | | | | | | | | + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ããã0ã2ïŒåªå é äœã ããã3ïŒ0 =éåžžã®é 延ã1 =äœé 延ã ããã4ïŒ0 =éåžžã®ã¹ã«ãŒãããã1 =é«ã¹ã«ãŒãããã ããã5ïŒ0 =éåžžã®ä¿¡é Œæ§ã1 =é«ã®ä¿¡é Œæ§ã ããã6-7ïŒå°æ¥ã®äœ¿çšã®ããã«äºçŽæžã¿ã
æåã®3ãããã¯ããªãã¡ã¬ã³ã¹ã4çªç®ã¯é 延èŠä»¶ã5çªç®ã¯åž¯åå¹ èŠä»¶ã6çªç®ã¯ãªã³ã¯ä¿¡é Œæ§èŠä»¶ã7çªç®ãš8çªç®ã¯å°æ¥ã®äœ¿çšã®ããã«äºçŽãããŠããŸãã
æ°ããæšæºïŒRFC1349ïŒã«ç®ãåãããšã7çªç®ã®ãããã®å€ã¯æ¢ã«å®çŸ©ãããŠããŸã-äŸ¡æ Œã®èŠä»¶ã¯ãã³ã¹ããïŒåçã®éé¡ïŒã§ãã
次ã«ããããã¯ãŒã¯äžã«ToSãã£ãŒã«ãã®7çªç®ã®ããããIPv4ããããŒã«èšå®ãããŠãããã¬ãŒã ããããã©ãããå€æããããšããŸãã ã©ããã£ãŠããã®ïŒ ãã®åé¡ã解決ããã«ã¯ã埮ç©åã®ãã€ããªã·ã¹ãã ãèŠããŠããïŒãŸãã¯åŠã¶ïŒDïŒå¿ èŠããããŸãã ãã€ãã§ã¯ãåãããã«ã¯ç¬èªã®éã¿ãããã1ããå§ãŸããæ¯å2ãæãããã³ã«å³ããå·Šã«å¢å ããŸãã
0 1 2 3 4 5 6 7 + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + | | | | | | | | åªå é äœ| D | T | R | C | 0 | | 0 0 0 | 0 | 0 | 0 | 1 | 0 | | | | | | | | + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + 128 64 32 16 8 4 2 1
èå³ã®ãããããã®éã¿ã¯2ã§ããããšãããããŸãã
ToSãã£ãŒã«ãã®å€ã2ãšæ¯èŒãããšã©ããªããŸããïŒ
ip [1ïŒ1] = 2
質åãžã®åçãåŸãããŸããïŒãã®ããããŒã«ã¯å°ãèå³ããããŸããïŒ äžæ¹ã§ãã¯ãããããä»æ¹ã§ããããã
ããšãã°ãToSãã£ãŒã«ãã«ãã³ã¹ãããããã«å ããŠãä»ã®ãããã1ã«èšå®ãããŠããå Žåã ããã垯åå¹ ã®èŠä»¶ãæ åœãããããã§ãããšããŸããã-ãã¹ã«ãŒããããã
0 1 2 3 4 5 6 7 + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + | | | | | | | | åªå é äœ| D | T | R | C | 0 | | 0 0 0 | 0 | 1 | 0 | 1 | 0 | | | | | | | | + ----- + ----- + ----- + ----- + ----- + ----- + ----- + ----- + 128 64 32 16 8 4 2 1
ãã®çµæããã®ãã€ãã®å€ã¯2ã§ã¯ãªã10ã«ãªããåçŽãªæ¯èŒã§ã¯ã察象ã®ãã£ãŒã«ãã«ç¹å®ã®ããããèšå®ãããŠãããã©ããã®è³ªåã«çããããšãã§ããŸããã
èå³ã®ããçããåŸãããªãã®ã¯ãªãã§ããïŒ ãããã®åäœã«èšå®ãããŠããå¯èœæ§ãããä»ã®å€ã«ãã£ãŠåŠšå®³ãããŠããŸãã ãããã£ãŠãããããåãé€ãå¿ èŠããããŸãã ãã®åé¡ã解決ããããã«ãã·ã³ãã«ã ïŒ ãã§ç€ºããããããåäœã®è«çãANDãïŒè«çä¹ç®ãšãåŒã°ããŸãïŒã®æäœã䜿çšããŸãã ãåãã®ããã«ãè«çæŒç®ãANDãã§ã¯ã第1ãªãã©ã³ããšç¬¬2ãªãã©ã³ãã®äž¡æ¹ã1ã«çããå Žåãåºåã¯1ã€ã ãã«ãªããŸãã ãããã£ãŠãToSãã£ãŒã«ãã®å¯Ÿè±¡ãããã®äœçœ®ã«ãããããã®ã¿ã1ã«èšå®ãããç¹å¥ãªãã¹ã¯ã«ãã£ãŠãToSãã£ãŒã«ãã®å€ã®ãããããšã®ä¹ç®ãå®è¡ãããšãçµæããä»ã®ãã¹ãŠã®ããããé€å€ãããŸãã
ToSãã£ãŒã«ãïŒ00001010 = 10 ãã¹ã¯ïŒ00000010 = 2 çµæïŒ00000010 = 2
æ®ãã®ãããã®å€ã«é¢ä¿ãªãããã®ãã¹ã¯ãé©çšãããšãçµæã¯å¯Ÿè±¡ãã£ãŒã«ãã®å€ã®ã¿ãååŸããŸãã ãã¹ãŠã®ãããã1ã«èšå®ããŠããçµæã«ã¯åœ±é¿ããŸããã
ToSãã£ãŒã«ãïŒ11111111 = 255 ãã¹ã¯ïŒ00000010 = 2 çµæïŒ00000010 = 2
ãããŠããã¹ãã³ã°ã®çµæãšããŠé¢å¿ã®ãããããããŒãã§ããå Žåã«ã®ã¿ããŒããååšããŸãã
ToSãã£ãŒã«ãïŒ11111101 = 253 ãã¹ã¯ïŒ00000010 = 1 çµæïŒ00000000 = 0
ãããã£ãŠãé¢å¿ã®ãããããã1ã«çããå Žåããã¹ãã³ã°ã®çµæãšããŠãã®ãããã®éã¿ãååŸãããŒãã«çããå ŽåããŒããååŸããŸãã
ããã«åºã¥ããŠããã®åé¡ã解決ããã«ã¯ã次ã®ãã£ã«ã¿ãŒãé©çšããå¿ èŠããããŸãã
ip [1ïŒ1]ïŒ2 = 2
2çªç®ã®ãã€ãã®å€ãååŸããç¹å®ã®ãããã®å€ããåãåãããã¹ã¯ãé©çšããŠãçµæããã®ãããã®éã¿ãšæ¯èŒããŸãã
IPããããŒã®Type Of Serviceãã£ãŒã«ãã®åæã«åºã¥ããŠå¥ã®äŸãæããããšãã§ããŸãïŒToSãã£ãŒã«ãã®IPv4ããããŒã§åªå ãããïŒåªå ïŒããŒãã§ãªããã¹ãŠã®ãã¬ãŒã ãèŠãå¿ èŠããããŸãã ãããè¡ãã«ã¯ãåªå é äœãæ åœããããããéžæãããã¹ã¯ãé©çšããŸãã
ToSãã£ãŒã«ãïŒ10111101 = 189 ãã¹ã¯ïŒ11100000 = 224 çµæïŒ10100000 = 160
çµæã¯ãŒãã«çãããªããããã¯ãåªå é äœãã£ãŒã«ãããŒãã«çãããªãããšã瀺ããŸãã
ToSãã£ãŒã«ãïŒ00011111 = 31 ãã¹ã¯ïŒ11100000 = 224 çµæïŒ00000000 = 0
çµæã¯ãŒãã§ããããã¯ãåªå é äœãã£ãŒã«ãããŒãã§ããããšã瀺ããŠããŸãã
ãã®çµæãIPv4ããããŒã®ToSãã£ãŒã«ãã®ãŒã以å€ã®å€ã確èªãããšã次ã®ããã«ãªããŸãã
ip [1ïŒ1]ïŒ224ïŒ= 0
ãŸãã¯åãããšã§ããã16é²ãªãã·ã§ã³ã䜿çšããŸãã
ip [1ïŒ1]ïŒ0xe0ïŒ= 0
å¥ã®ãããã³ã«ã®äŸãèããŠã¿ãŸãããã TCPãããã³ã«ã䜿çšããŸãã
ããšãã°ããªãã·ã§ã³ä»ãã®TCPã»ã°ã¡ã³ããéä¿¡ãããã¹ãŠã®ãã¬ãŒã ããã£ããã£ããå¿ èŠããããŸãã äœãæ¢ãå¿ èŠãããã®ãââããããŠã©ãã§RFC-793ãåç §ããã®ããç解ããããã
TCPããããŒåœ¢åŒ 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | éä¿¡å ããŒã| å®å ããŒã| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | ã·ãŒã±ã³ã¹çªå·| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | è¬èŸçªå·| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | ããŒã¿| | U | A | P | R | S | F | | | ãªãã»ãã| äºçŽæžã¿| R | C | S | S | Y | I | ãŠã£ã³ããŠ| | | | G | K | H | T | N | N | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | ãã§ãã¯ãµã | ç·æ¥ãã€ã³ã¿| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | ãªãã·ã§ã³| ããã£ã³ã°| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+ | ããŒã¿| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+
ã»ã°ã¡ã³ãã«ãªãã·ã§ã³ããããã©ãããå€æããããã«ããããŒã¿ãªãã»ããããã£ãŒã«ãã䜿çšããã4ãã€ãã®åèªã§ã¿ã€ãã«ã®é·ãã衚瀺ãããŸãã TCPã»ã°ã¡ã³ãããããŒã®æå°é·ã¯20ãã€ãã§ã5ã€ã®4ãã€ãã¯ãŒãã§ãã ãããã£ãŠãã»ã°ã¡ã³ãã®TCPããããŒã«ãªãã·ã§ã³ãããå Žåããã®ãã£ãŒã«ãã®å€ã¯5ãè¶ ããŸãã
ãã®ãã£ãŒã«ãã®å€ãååŸããã«ã¯ã tcpããªããã£ã[12ïŒ1]ã䜿çšããå¿ èŠããããŸãã ãã ããåãããšãã§ããæå°ããŒã¹ã1ãã€ãã§ããã4ãããããå¿ èŠãªããšããäºå®ãèãããšãå°ãèããªããã°ãªããŸããã
tcpããªããã£ã[12ïŒ1]ãé©çšãããšã次ã®ããããŒéšåãåŸãããŸããã
+-+-+-+-+-+-+-+- | ããŒã¿| | ãªãã»ãã| äºçŽæžã¿ | | +-+-+-+-+-+-+-+-
ãããŒã¿ãªãã»ããããã£ãŒã«ãããã€ãã®äžéšã«ããå Žåããã€ããªè¡šçŸã®æ°åã5ãã¯æ¬¡ã®ããã«ãªããŸãã
128 64 32 16 8 4 2 1 0 0 0 0 0 1 0 1 = 5
ããããç§ãã¡ã«ãšã£ãŠèå³ã®ããéšåã¯ãå·Šã§ã¯ãªããè¥ãéšåã«ãããŸãããããã£ãŠã10é²æ°ã®åçç©ãåŸãããã«ããããããã€ãã®å³åŽã«è»¢éããŸãã
128 64 32 16 8 4 2 1 0 1 0 1 0 0 0 0 = 80ïŒ16é²æ°ã§0x50ïŒ
æäžäœããããéžæããã«ã¯ããã¹ã¯ããå¿ èŠããããŸãã
ããŒã¿ãªãã»ãããã£ãŒã«ãïŒ01010000 = 80 ãã¹ã¯ïŒ11110000 = 240 çµæïŒ01010000 = 80
ããããŒã«ãŸã ãªãã·ã§ã³ãããå ŽåããããŒã¿ãªãã»ãããã®å€ã¯5ãè¶ ããŸããããšãã°ãããããŒã«1ã€ã®8ãã€ããªãã·ã§ã³ãããå Žåããã®ãã£ãŒã«ãã®å€ã¯7ïŒããããŒã®åºå®éšåã®5ã€ã®4ãã€ãã¯ãŒããš2ã€ã®4ãã€ããªãã·ã§ã³ã¯ãŒãïŒã«ãªããŸãã
128 64 32 16 8 4 2 1 0 0 0 0 0 1 1 1 = 7
察å¿ããããããäžéšã«è»¢éãããšã次ã®ããã«ãªããŸãã
128 64 32 16 8 4 2 1 0 1 1 1 0 0 0 0 = 112ïŒ16é²æ°ã§0x70ïŒ
ãã¹ãã³ã°ã«ãã£ãŠäžäœãããã匷調衚瀺ããŸãã
ããŒã¿ãªãã»ãããã£ãŒã«ãïŒ01110000 = 112 ãã¹ã¯ïŒ11110000 = 240 çµæïŒ01110000 = 112
ãããã£ãŠãçµæã80ãã倧ããå€ã§ããå ŽåãTCPããããŒã«ãªãã·ã§ã³ãããããšãããããŸãã äœåãªãããã¯ãŸã åé·ã§ãããåžžã«ãŒãã§ããå¿ èŠããããããååãšããŠããã«ãã¹ã¯ãé©çšããå¿ èŠã¯ãããŸããã§ããããäœãå€æŽã§ãããã¯ããããŸããããŸãããã£ã«ã¿ãŒãæžãæããªãããã«ãæšæºãçªç¶å€æŽãããå Žåã¯ããã¹ã¯ã§ããããã«ããããæ¹ãè¯ãã§ãããã
çµæã®ãã£ã«ã¿ãŒã¯ãTCPããããŒã®é·ãã5ã€ã®4ãã€ãã¯ãŒããè¶ ããTCPã»ã°ã¡ã³ãã衚瀺ãã次ã®ãšããã§ãã
tcp [12ïŒ1]ïŒ240ïŒ= 80
ãŸãã¯
tcp [12ïŒ1]ïŒ240> 80
ãŸãã¯
tcp [12ïŒ1]ïŒ0xf0> 80
ãŸããTCPãã©ã°ã䜿çšããå¯èœæ§ã«ã€ããŠãèããŠã¿ãŸãããã ãããã¯ããã¹ã¯ã䜿çšããŠåãæ¹æ³ã§åºå¥ã§ããŸãããäžèšã§æå®ããã·ã³ããªãã¯åé¡åã䜿çšããããšãã§ããŸãã
ããšãã°ãSYNãŸãã¯FINãã©ã°ãæã€ã»ã°ã¡ã³ããå«ããã¬ãŒã ããã£ããã£ããã«ã¯ã次ã®ãã£ã«ã¿ãŒãèšè¿°ããå¿ èŠããããŸãã
tcp [tcpflags]ïŒïŒtcp-syn | tcp-finïŒïŒ= 0
ããã¯éåžžã«èªã¿ããããç¹å¥ãªèª¬æã¯å¿ èŠãªããšæããŸãã
ããããšãã¹ã¯ã䜿çšããŠåæ§ã®ã¿ã¹ã¯ãå®çŸãããšã次ã®ãããªãã£ã«ã¿ãŒåœ¢åŒã«ãªããŸãã
tcp [13ïŒ1]ïŒ2ïŒ= 0ãŸãã¯tcp [13ïŒ1]ïŒ1ïŒ= 0
ãããã¯ã®ç解ãçµ±åããããã«ããã®ãã£ã«ã¿ãŒãªãã·ã§ã³ãããèªäœã§ã©ã®ããã«æ©èœããããç解ããŠãã ããã
äŸ ïŒ
åŒether [0]ïŒ1ïŒ= 0ã¯ããã¹ãŠã®ãããŒããã£ã¹ããã¬ãŒã ãéžæããŸãã
åŒether [0]ïŒ1 = 0ããã³ip [16]> = 244ã¯ãããŒã¿ãªã³ã¯å±€ã§ãããŒããã£ã¹ããŸãã¯ãã«ããã£ã¹ãMACã¢ãã¬ã¹ã䜿çšããªããã¹ãŠã®ãããŒããã£ã¹ããŸãã¯ãã«ããã£ã¹ãIPãã±ãããéžæããŸãã
åŒip [0]ïŒ0xf = 5ã¯ããªãã·ã§ã³ã®ãªããã¹ãŠã®IPãã±ãããéžæããŸãã
åŒip [6ïŒ2]ïŒ0x1fff = 0ã¯ããã¹ãŠã®æçåãããŠããªãIPãã±ãããšãæçåããããã±ããã®æåã®ãã©ã°ã¡ã³ããéžæããŸãã
åŒip [-3]ïŒ0xff = 0x37ã¯ãéä¿¡è MACã¢ãã¬ã¹ãã0x37ãã§çµãããã¹ãŠã®IPãã±ãããéžæããŸãã
ãããæŒç®ã®ãã1ã€ã®èå³æ·±ãã»ããã¯ããããã·ããæŒç®ã§ãã ãããã®æäœã¯ãã·ã³ãã«ãç¢å°ã®ãã¢ãã§ç€ºãããŸããã<<ã-å·Šã«ã·ãããã>>ã-å³ã«ã·ããããŸãã
圌ãã¯ã©ã®ããã«æ©èœããŸããïŒ
ä»»æã®ãã€ããåããç°¡åã«ããããã«ãŠããããåãããã®å€ããã€ããªã·ã¹ãã ã«æžã蟌ã¿ãŸãã
128 64 32 16 8 4 2 1 0 0 0 0 0 0 0 1 = 1
次ã«ãå·Šã«ãããã·ããæŒç®ãå®è¡ãããã¹ãŠã®ãããã®å€ã1ããžã·ã§ã³ã ãã·ããããæå°ç©ºããããã«ãŒããèšå®ããŸãã
128 64 32 16 8 4 2 1 0 0 0 0 0 0 1 <<
128 64 32 16 8 4 2 1 0 0 0 0 0 0 1 0 = 2
ãã®çµæããã€ãå€ã¯2ã«çãããªããŸãããã€ãŸãã2åã«ãªããŸããã ãããŠåã³ãã®æäœãé©çšããŸãïŒ
128 64 32 16 8 4 2 1 0 0 0 0 0 1 0 <<
128 64 32 16 8 4 2 1 0 0 0 0 0 1 0 0 = 4
ãã®çµæããã€ãå€ã¯4ã«çãããªããŸãããã€ãŸããåã³2åã«ãªããŸããã ãããã£ãŠãå·Šãžã®ãããã·ããã®æäœã¯ããã€ãå€ã«2ãä¹ç®ããããšãšåçã§ãããšçµè«ä»ããããšãã§ããŸãïŒãã€ããªã·ã¹ãã ã§äœæ¥ããŠããããïŒã
ããè€éãªæ°ãããšãã°100ã§ãã®ã«ãŒã«ã®æå¹æ§ã確èªããŸãããããã€ããªåœ¢åŒã§èšè¿°ããŸãã
128 64 32 16 8 4 2 1 0 1 1 0 0 1 0 0 = 100
次ã«ãå·Šã·ããæäœãå®è¡ããŸãã
128 64 32 16 8 4 2 1 1 1 0 0 1 0 0 <<
128 64 32 16 8 4 2 1 1 1 0 0 1 0 0 0 = 200
ãã®çµæããã€ãå€ã¯200ã«ãªããåã«ãªããŸããã
ãããã£ãŠãå³ãžã®ãããã·ããã¯ãæ°å€ã2ã§é€ç®ããããšãšåçã§ãããšããã«çµè«ä»ããããšãã§ããŸãã
ããšãã°ãçªå·240ïŒ
128 64 32 16 8 4 2 1 1 1 1 1 0 0 0 0 = 240
å³ã«ã·ããæäœãå®è¡ããŸãããïŒ
128 64 32 16 8 4 2 1 >> 1 1 1 1 0 0 0
128 64 32 16 8 4 2 1 0 1 1 1 1 0 0 0 = 120
ãã€ãå€ã¯120ã«çãããªããååã«æžå°ããŸããã
ãã®æäœã¯ã©ã®ããã«äœ¿çšã§ããŸããïŒ IPããããŒã®IHLïŒã€ã³ã¿ãŒãããããããŒé·ïŒãã£ãŒã«ãã¯ãããããŒã®é·ãããã€ãåäœã§ã¯ãªã4ãã€ãã¯ãŒãã§ç€ºããŠããããšãæãåºããŠãã ããããã±ããã«ãªãã·ã§ã³ãå«ãŸããŠãããã©ããã確èªããããã«ã次ã®æäœã䜿çšããŸããã
ip [0]ïŒ0xf = 5
ã€ãŸããå®éã®å€ã§ã¯ãªãã4ã«åå²ãããå€ãšæ¯èŒãããŸããïŒ20ãã€ãã¯5ã€ã®4ãã€ãã¯ãŒãã§ãïŒã äœããã®çç±ã§ããããŒã®é·ãããã€ãåäœã§åŠçããæ¹ã䟿å©ãªå ŽåïŒããšãã°ããã®å€ããã®åŸãã±ããã®åèšé·ããæžç®ããå¿ èŠãããå ŽåïŒã4ãæããå¿ èŠããããŸãã4ãæããã«ã¯ã2åããå¿ èŠããããŸããã€ãŸãããããå·Šã·ããæäœã2åå®è¡ããŠãããå¿ èŠãªãã€ãåäœã®é·ãIPããããŒãšæ¯èŒããŸãã
ip [0] << 2 = 20
ãããŠãã¡ããããããã¯ãã¹ãŠè€åã«ãŒã«ã»ããã«çµã¿åãããããšãã§ããŸãã
ïŒicmp [icmptype]ïŒ= icmp-echoããã³icmp [icmptype]ïŒ= icmp-echoreplyïŒãŸãã¯ïŒudpããã³udpããŒãã§ã¯ãªã67ããã³ip [16] <224ïŒãŸãã¯ïŒtcp [0ïŒ2] <1024ããã³tcp [ 2ïŒ2] <1024ïŒ
ãã®ãã£ã«ã¿ã䜿çšãããšãããã°ã©ã ã¯æ¬¡ã®3ã€ã®èª¬æã®ããããã«é©åãããã¬ãŒã ã®ã¿ããã£ããã£ããŸãã
- echoããã³echoreplyïŒpingãŠãŒãã£ãªãã£ã§äœ¿çšïŒãé€ãICMPã¡ãã»ãŒãžãå«ã
- UDPããŒã¿ã°ã©ã ã¯ãéä¿¡è ãŸãã¯åä¿¡è ããŒããšããŠããŒã67ã䜿çšãããã®ãé€ãããã«ããã£ã¹ãã¢ãã¬ã¹ããã³å¶éããããããŒããã£ã¹ãã¢ãã¬ã¹ã«éä¿¡ããããã®ãé€ããéä¿¡ãããŸãã
- éä¿¡åŽããŒããšåä¿¡åŽããŒãã®äž¡æ¹ããæ¢ç¥ã®ããŒããç¯å²ã«ããTCPã»ã°ã¡ã³ããéä¿¡ããŸã
4.èªå·±æ€æ»ã¿ã¹ã¯ïŒD
è€éãªãã£ããã£ãã£ã«ã¿ã䜿çšããŠäœæ¥ãçµ±åããã«ã¯ããã®ãã£ã«ã¿ã®èª¬æãšãã®æ©èœãç解ããŠãã ããã
tcpããŒã80ããã³ïŒip [2ïŒ2]-ip [0]ïŒ0xf << 2-tcp [12]ïŒ0xf0 >> 2ïŒ= 0ïŒ
泚 ïŒ
ããã¯æšæºçãªäŸã®1ã€ã§ãããå¿ èŠã«å¿ããŠãã€ã³ã¿ãŒãããæ€çŽ¢ã䜿çšããŠç°¡åã«èªåèªèº«ã確èªã§ããŸãããããã§ãåªåããŠèªåã§å¯ŸåŠããããšããŸãã
çŽ æµãªåããããïŒ