Upgrade to Pro — share decks privately, control downloads, hide ads and more …

enginnerday.pdf

kobatako
September 22, 2018
39

 enginnerday.pdf

kobatako

September 22, 2018
Tweet

Transcript

  1. bitstring • όΠτྻʹରͯ͠Ϗοτ୯ҐͰΞΫηεɺૢ ࡞͢Δ͜ͱ͕Ͱ͖Δ % bitstring <<69,16,0,60,227,255,64,0,63,6,255,108,172,31,0,2,172,17,0,13,198,22,31,64, 73,33,85,221,0,0,0,0,160,2,114,16,88,110,0,0,2,4,5,180,4,2,8,10,8,17,182,34 ,0,0,0,0,1,3,3,7>> %

    Ϗοτ୯ҐͰม਺ʹଋറ͢Δ <<DestMacAddr:48, SourceMacAddr:48, Type:16, Data/bitstring>> = Buf, % Ϗοτ୯ҐͰ֤ม਺ΛbitstringͷҰ෦ͱͯ͠ม਺ʹଋറ͢Δ SendData = <<Ver:4, Len:4, ServiceType, Packetlen:16, IdentificationNumber: 16, Flg:3, Offset:13, CountTTL, Protocol, SourceIp:32, DestIp:32>>,
  2. ύλʔϯϚον • ӈลΛධՁ͠ɺࠨลͱҰக͍ͯ͠Δ͔Λௐ΂Δ 1> N = 9. % NΛ9Ͱଋറ 9

    2> N. 9 3> N = 0. % ӈลͱࠨล͕౳͘͠ແ͍ͨΊΤϥʔ ** exception error: no match of right hand side value 0 4> 9 = N. % ӈลͱࠨล͕౳͍ͨ͠Ίਖ਼ৗ 9 5> {N, M} = {9, 0}. % ӈลͷ9ͱࠨลͷN͕౳͍ͨ͠ΊMʹ0Λଋറͤ͞Δ {9,0} 6> {N, L} = {0, 8}. % ӈลͷ9ͱࠨลͷN͕౳͘͠ແ͍ͨΊΤϥʔ ** exception error: no match of right hand side value {0,8}
  3. ύλʔϯϚον • ؔ਺ͷҾ਺ͱͯ͠΋ѻ͑Δ • ઌ಄͔ΒॱʹධՁ͍͖ͯ͠ɺҰ൪࠷ॳʹϚονͨؔ͠਺Λ࣮ߦ͢Δ handle_event(Buf, Fd) -> <<_:48, SourceMacAddr:48,

    Type:16, Data/bitstring>> = Buf, ɾɾɾ ethernet_type(Type, Data); ɾɾɾ % IP Protocol ethernet_type(16#0800, Data) -> % Type͕16ਐ਺Ͱ0800ͷ৔߹ʹݺ͹ΕΔؔ਺ ip:packet(Data); % ARP Protocol ethernet_type(16#0806, Data) -> % Type͕16ਐ਺Ͱ0806ͷ৔߹ʹݺ͹ΕΔؔ਺ arp:packet(Data); ethernet_type(_Type, _Data) -> % _͸શͯʹϚον͢Δม਺ʹͳΔͷͰɺશͯʹϚον͢Δ false;
  4. ύλʔϯϚον • bitstringΛҾ਺ͱͯ͠౉͠ɺύλʔϯϚονͰ࣮ߦ͢ Δؔ਺Λม͑Δ % IP check sump % ୈҰҾ਺͕͔ΒͷbitstringʹͳͬͨΒ஋Λฦ͢

    checksum(<<>>, Sum) -> Sum bxor 16#FFFF; % ୈҰҾ਺͕16bitҎ্͋Δͱ͖ checksum(<<A:16, Other/bitstring>>, Sum) -> Check = A + Sum, Res = (Check band 16#FFFF) + (Check bsr 16), checksum(Other, Res).
  5. % source_routeɿͲ͔͜Βܦ࿏৘ใΛऔಘ͔ͨ͠ % dest_routeɿͲ͜ʹૹΔࡍͷܦ࿏৘ใͳͷ͔ʢྫɿ{192.168.100.0}ʣ % dest_route_intɿdest_routeΛ਺ྻʹͨ͠΋ͷɻϩϯήετϚονͰ࢖͏ % subnetmaskɿdest_routeͷαϒωοτϚεΫʢྫɿ{255, 255, 255,

    0}ʣ % subnetmask_intɿsubnetmaskΛ਺ྻʹͨ͠΋ͷɻϩϯήετϚονʹ࢖͏ -record(routing_table, { source_route, dest_route, dest_route_int, subnetmask, subnetmask_int, ad, metric, nexthop, age, out_interface }). ϧʔςΟϯάςʔϒϧͷ৘ใ
  6. ϧʔςΟϯάςʔϒϧͷAD஋ σϑΥϧτͷ"%஋ ઀ଓ͞Ε͍ͯΔΠϯλʔϑΣΠε  ελςΟοΫϧʔςΟϯά  αϚϦʔϧʔτ  ֎෦#(1 

    ಺෦&*(31  *(31  041'  *4*4  3*1  &(1  003  ֎෦&*(31  ಺෦#(1  ෆ໌  Ciscoαϙʔτର৅ϓϩτίϧͷAD஋
  7. ϧʔςΟϯάͷྲྀΕ 1. ૹ৴ઌͷnexthopΛϧʔςΟϯάςʔϒϧ͔Βऔಘ 2. nexthopͷMacΞυϨεΛARPςʔϒϧʹཁٻ 3. ʢARPςʔϒϧʹແ͍৔߹ʣARPϦΫΤετΛૹΓɺARPςʔϒϧΛߋ৽͢Δ 4. ʢIPϓϩτίϧͷ৔߹ʣTTLΛҰͭݮΒ͠ɺνΣοΫαϜΛ࠶ܭࢉ 5.

    ARPςʔϒϧ͔Βऔಘͨ͠MacΞυϨεΛ࣍ͷૹ৴ઌMacΞυϨεͱͯ͠Ѽઌ MacΞυϨεʹೖΕΔ 6. ૹ৴ݩͷMacΞυϨεΛࣗ਎ͷΠϯλʔϑΣΠεͷMacΞυϨεʹஔ͖׵͑Δ 7. ૹ৴
  8. ·ͱΊ • όάͬͯΔ࣌͸͜ΜͳͷͱʹΒΊͬ͜Ͱ͢