notes

Networking

Arhitectual Design Principles

  1. Shared use of single communication chanell.
    1. statical multiplexing / packet switching - information for forwarding traffic contained in destination address of packet. It allows many senders to send data simultaniously via shared link
  2. Interconnet many existing networks. Hide underlying technology from applications.
    1. Physical layer (sonet).
    2. Link Layer (Ethernet). Provides point to point connectivity.
    3. Network layer (IP). If a host has an IP address then Network Layer provides guarantee that a packet with host destination IP address, should reach the destination with the corresponding ip address.
    4. Transport layer (TCP, UDP). Gurantee: reliable transport, congestion control
    5. Application layer (HTTP, SMTP)
  3. Survivability. Network works even if some devices fail.
    1. replication
    2. fate sharing. If a device failes then all its state fails with it.
  4. Heterogeneity.
  5. Distributed Management.
  6. End-to-End Argument. Network should be dump and minimal and end points should be intelligent. End points should be responsible for:
    • Error handling in file transfer
    • End-to-end encryption
    • TCP/IP split in error handling.

Diagnostic Utils

  1. traceroute - tracks the route packets taken from an IP network on their way to a given host.

     $ traceroute google.com
     traceroute to google.com (173.194.44.72), 30 hops max, 60 byte packets
         1  192.168.10.1 (192.168.10.1)  0.282 ms  0.268 ms  0.396 ms
         2  bsr02.tomsk.ertelecom.ru (109.194.32.69)  2.716 ms  2.886 ms  3.306 ms
         3  lag-2-436.bgw01.tomsk.ertelecom.ru (109.194.40.22)  1.259 ms  1.449 ms  1.462 ms
         4  72.14.215.165 (72.14.215.165)  41.599 ms  47.736 ms  41.773 ms
         5  72.14.215.166 (72.14.215.166)  41.787 ms  41.766 ms  41.761 ms
         6  66.249.94.94 (66.249.94.94)  42.176 ms  41.686 ms  41.857 ms
         7  108.170.232.47 (108.170.232.47)  42.602 ms  42.585 ms  42.903 ms
         8  173.194.44.72 (173.194.44.72)  42.846 ms  42.518 ms  42.616 ms
    
  2. netstat - print network information
     netstat --ip -p # show ip connections with processes
    
     netstat -r # show routes
    
     netstat --ip -l -p # show listening ports
    
  3. To show a machine IP address:

     ip addr show
    
     ifconfig
    
  4. ping

     ping [-c count] server
    
  5. To get an information about domain use

     dig <domain>
    

Netcad

  1. To listen to a port with netcat use

     nc -l <port>
    

Switching

  1. To send a packet through the internet sender need an IP address and MAC address of reciever. Ethernet packet contains source and destination MAC addresses, IP packet contains source and destination IP addresses.
  2. Typically we know DNS name or IP address of reciever. To get the MAC address we use ARP protocol
  3. ARP (Address Resolution Protocol) - host broadcas query with an IP address: “Who has IP address x.x.x.x?” to every host on a LAN.
  4. When sender receives MAC address it constructs local ARP table (IP => MAC address)

Стэк сетевых протоколов

Network Protocol Stack

  1. HTTP и TLS реализованна в браузере или веб сервере
  2. TCP и IP реализованна в ОС
  3. Порядок работы на клиенте:
    1. HTTP: формируется запрос. Вызывает функцию протокола TLS.
    2. TLS: шифрует данные, вызывает функцию протокола TCP.
    3. TCP: добавляет контрольные суммы, делит на сегменты если это нужно, ставит свои флаги и передаёт данные протоколу более нижнего уровня (IP). Отвечает за flow controle и congestion control
    4. IP: передача данных через сеть интернет. Отвечает за маршрутизацию пакета по сети.
  4. Порядок работы на сервере: IP => TCP => TLS => HTTP.