Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Erlangでソフトウェアルータを作ってる話

1.240 visualizaciones

Publicado el

FUKUOKA Enginners Day 2018 ~Autumn~

Publicado en: Tecnología
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Erlangでソフトウェアルータを作ってる話

  1. 1. Erlang FUKUOKA Enginners Day 2018 ~Autumn~ 2018/9/22
  2. 2. • • Fusic • 
 Erlang Elixir • Twitter @kobatako_
  3. 3. • Erlang • •
  4. 4. Erlang
  5. 5. Erlang • • • •
  6. 6. Erlang 🤔
  7. 7. bitstring
  8. 8. 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>>,
  9. 9. • 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}
  10. 10. • • 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;
  11. 11. • 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).
  12. 12. !!! http://erlang.org/doc/reference_manual/ introduction.html
  13. 13. • ARP • •
  14. 14. ARP
  15. 15. ARP • ARP • IP Mac
  16. 16. ARP % source_ip_addr IP % dest_ip_addr IP % dest_mac_addr Mac % type -record(arp_table, { source_ip_addr, dest_ip_addr, dest_mac_addr, type }).
  17. 17. • •
  18. 18. % 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 }).
  19. 19. % ad % metric % nexthop dest_route IP % age % out_interface -record(routing_table, { source_route, dest_route, dest_route_int, subnetmask, subnetmask_int, ad, metric, nexthop, age, out_interface }).
  20. 20. AD Cisco AD
  21. 21. • • A B C D E
  22. 22. • • • AD •
  23. 23. • • IP dest_route
  24. 24. • AD • • • RIP OSPF
  25. 25. 1. nexthop 2. nexthop Mac ARP 3. ARP ARP ARP 4. IP TTL 5. ARP Mac Mac Mac 6. Mac Mac 7.
  26. 26. ping 😇
  27. 27. • L3 L4 • • • ICMP
  28. 28. 😱 😱 😱 😱 😱 😱
  29. 29. • • Firewall • Load Balancer •
  30. 30. • ping 1ms • • • grep
  31. 31.
  32. 32. 
 
 😄

×