index.md (3997B)
1 +++ 2 title = 'Networking basics' 3 +++ 4 5 # Networking basics 6 ## Domain name system (DNS) 7 People can't remember IPs, need names that are easy to remember. 8 9 Before DNS, you just had a hosts file that was periodically updated via FTP. 10 11 DNS: 12 - distributed, so no centralization and good scalability 13 - simple client/server architecture via UDP port 53 14 - hierarchical namespace: 15 - root name server by ICANN 16 - responsible for root zone file -- lists TLDs and who owns them 17 - 13 root servers, globally replicated 18 - contacted when names can't be resolved locally 19 - top-level domains managed by Verisign and others 20 21 Resolving a name via recursive DNS query, e.g. "www.google.com" 22 - query local DNS server (e.g. dns.vu.nl) 23 - no entry found, go to root 24 - root says to contact "com" nameserver 25 - query "com" NS for "www.google.com" 26 - "com" NS says to contact "ns1.google.com" 27 - query "ns1.google.com" for "www.google.com" 28 - "ns1.google.com" returns IP address 29 30 DNS types: 31 - A (IPv4), AAAA (IPv6): DNS resolution 32 - CNAME: look for alias 33 - NS: query for DNS responsible for partial name 34 - MX: look for mail server 35 36 ## Socket and TCP 37 Berkeley sockets: 38 39 ![Berkeley sockets flowchar 40 t](berkeley-sockets.png) 41 42 Transmission control protocol (TCP): 43 - uses a three-way handshake 44 45 ![TCP flow](tcp.png) 46 47 TCP functionality: 48 - reliable delivery: integrity check (header checksum), packet retransmission when lost (sequence number), packet reordering 49 - flow control: receiver not overrun by sender 50 - congestion control: network not overrun by sender 51 52 ## IP routing 53 IP addresses made up of 32 bits, in groups of 8. 54 Contain network identifier (IP prefix), subnet identifier, host identifier. 55 56 CIDR notation: 10.0.0.1/24 57 - first 24 bits for network identifier 58 - rest for host identifier 59 - alternative subnet mask notation: 255.255.255.0 60 61 Generating forwarding tables: 62 - control plane: routers use distributed protocol to exchange messages and compute shortest paths to other routers 63 - OSPF: within domain. routers exchange link-state messages to learn topology, each router uses Dijkstra's to get shortest path, and generates forwarding table entries 64 - BGP: between autonomous systems. 65 66 MPLS: multiprotocol label switching 67 - uses a label field, which routers use to forward traffic 68 - useful for traffic engineering (optimization, performance improvement, etc.) 69 70 ## Ethernet and ARP 71 Switched Ethernet: 72 - switching creates Ethernet segments and forwards frames between them based on MAC address 73 - Ethernet MAC address: 6 bytes, unique among all network adapters, managed by IEEE 74 - switches forward/broadcast/drop frames based on switch table 75 - switches don't need MAC address - they operate transparently to hosts 76 - generating table: 77 - learn new MAC interface mappings through incoming frames 78 - if destination MAC unknown, broadcast frame on all interfaces except the one where the frame originated 79 - store-and-forward: packets received in full, buffered, then forwarded onto output link 80 - cut-through: when lookup is done, can receive and send packet at the same time (reduces latency, but can't do integrity check) 81 - redundancy without loops: use logical spanning tree (STP), automatically rebuild on failure 82 - with loops, you'd get packets bouncing around constantly 83 - traffic isolation: VLAN 84 - network manager partitions ports into subsets, assigns to VLANs 85 - ports in same VLAN form broadcast domain, ports on different VLANs routed through internal router in switch 86 - switches connected on trunk ports belonging to all VLANs 87 88 ARP: obtaining destination MAC address 89 - ARP query: ask host with IP to respond with MAC address 90 - ARP reply: MAC address response sent 91 - ARP table is cached locally 92 93 ## Network address translation (NAT) 94 NAT: way to map IP address space into another, used to mask network changes and prevent running out of IPv4 addresses 95 96 From the outside, your IP is the address of your router. 97 When your router gets traffic, it sends it to the appropriate host on the local network.