Introduction to Networks CSEN 404 Introduction to Networks Amr El Mougy Ali Saudi ** Slides are attributed to J. F. Kurose
Link Layer Application Transport Network Data Link PHY
Link Layer: Introduction Some terminology: hosts and routers are nodes communication channels that connect adjacent nodes along communication path are links wired links wireless links LANs layer-2 packet is a frame, encapsulates datagram data-link layer has responsibility of transferring datagram from one node to adjacent node over a link
Link Layer Functions Framing Medium Access Control (MAC) Reliable delivery Flow control Error detection and correction
IP Address vs. MAC Address 32-bit IP address: network-layer address used to get datagram to destination IP subnet MAC (or LAN or physical or Ethernet) address: function: get frame from one interface to another physically- connected interface (same network) 48 bit MAC address (for most LANs) burned in NIC ROM, also sometimes software settable Each network card (adapter) has a permanent unique MAC address (a.k.a hardware address, physical address, LAN address) represented in hexadecimal notation 5: DataLink Layer
IP Address vs. MAC Address xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx 223 191 056 008 xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx 1C 22 F3 D1 42 A9 5: DataLink Layer
LAN Addresses and ARP Broadcast address = FF-FF-FF-FF-FF-FF LAN Each adapter on LAN has unique LAN address 1A-2F-BB-76-09-AD Broadcast address = FF-FF-FF-FF-FF-FF LAN (wired or wireless) = adapter 71-65-F7-2B-08-53 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 5: DataLink Layer
LAN Address (more) MAC address allocation administered by IEEE manufacturer buys portion of MAC address space (to assure uniqueness) analogy: (a) MAC address: like Social Security Number, SIN (b) IP address: like postal address MAC flat address ➜ portability can move LAN card from one LAN to another IP hierarchical address NOT portable address depends on IP subnet to which node is attached 5: DataLink Layer
MACs in Frame Starting at A, given IP datagram addressed to B: look up net. address of B, find B on same net. as A link layer send datagram to B inside link-layer frame
ARP: Address Resolution Protocol Each IP node (host, router) on LAN has ARP table ARP table: IP/MAC address mappings for some LAN nodes < IP address; MAC address; TTL> TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) 137.196.7.78 1A-2F-BB-76-09-AD 137.196.7.23 137.196.7.14 LAN 71-65-F7-2B-08-53 58-23-D7-FA-20-B0 0C-C4-11-6F-E3-98 137.196.7.88
ARP protocol: Same LAN (network) A wants to send datagram to B, and B’s MAC address not in A’s ARP table. A broadcasts ARP query packet, containing B's IP address dest MAC address = FF-FF-FF-FF-FF-FF all machines on LAN receive ARP query B receives ARP packet, replies to A with its (B's) MAC address frame sent to A’s MAC address (unicast) A caches (saves) IP-to-MAC address pair in its ARP table until information becomes old (times out) soft state: information that times out (goes away) unless refreshed ARP is “plug-and-play”: nodes create their ARP tables without intervention from net administrator
Addressing: routing to another LAN walkthrough: send datagram from A to B via R assume A knows B’s IP address two ARP tables in router R, one for each IP network (LAN) 1A-23-F9-CD-06-9B 222.182.191.007 193.154.112.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 193.154.112.112 193.154.112.111 A 74-29-9C-E8-FF-55 222.182.191.008 88-B2-2F-54-1A-0F B 222.182.191.009 49-BD-D2-C7-56-2A LAN 5: DataLink Layer
R A B A creates IP datagram with source A, destination B A uses ARP to get R’s MAC address for 111.111.111.110 A creates link-layer frame with R's MAC address as dest, frame contains A-to-B IP datagram A’s NIC sends frame R’s NIC receives frame R removes IP datagram from Ethernet frame, sees its destined to B R uses ARP to get B’s MAC address R creates frame containing A-to-B IP datagram sends to B R 1A-23-F9-CD-06-9B 222.222.222.220 111.111.111.110 E6-E9-00-17-BB-4B CC-49-DE-D0-AB-7D 111.111.111.112 111.111.111.111 A 74-29-9C-E8-FF-55 222.222.222.221 88-B2-2F-54-1A-0F B 222.222.222.222 49-BD-D2-C7-56-2A 5: DataLink Layer
Switches and Routers Routers Switches Traffic Isolation Yes Plug and Play No Optimal Routing Larger networks require routers as they have better traffic isolation and can find better routes
A Day in the Life of a Webpage Request DNS Server 68.87.71.226 GUC 68.85.2.0/24 Bob 00:16:D3:23:63:8A ISP 68.80.0.0/13 00:22:6B:45:1F:1B 68.85.2.1 Bob wishes to retrieve a page from www.google.com Bob has just booted up the computer www.google.com 68.233.169.105 Google 68.233.160.0/19
A Day in the Life of a Webpage Request 68 67 0.0.0.0 255.255.255.255 00:16:D3:23:63:8A FF:FF:FF:FF:FF:FF DNS Server 68.87.71.226 GUC 68.85.2.0/24 Bob 00:16:D3:23:63:8A ISP 68.80.0.0/13 00:22:6B:45:1F:1B 68.85.2.1 Yiaddr: 68.85.2.101 67 68 68.85.2.1 255.255.255.255 00:22:6B:45:1F:1B FF:FF:FF:FF:FF:FF DHCP ACK also includes IP of default gateway (router in this case) and DNS server www.google.com 68.233.169.105 Google 68.233.160.0/19
A Day in the Life of a Webpage Request ARP Query 68.85.2.101 68.85.2.1 00:16:D3:23:63:8A FF:FF:FF:FF:FF:FF DNS Server 68.87.71.226 GUC 68.85.2.0/24 Bob 00:16:D3:23:63:8A 68.85.2.101 ISP 68.80.0.0/13 00:22:6B:45:1F:1B 68.85.2.1 ARP Reply 68.85.2.1 68.85.2.101 00:22:6B:45:1F:1B 00:16:D3:23:63:8A Before sending a DNS query, Bob must first discover the MAC address of the router through ARP www.google.com 68.233.169.105 Google 68.233.160.0/19
A Day in the Life of a Webpage Request DNS query: www.google.com 61334 53 68.85.2.101 68.87.71.226 00:16:D3:23:63:8A 00:22:6B:45:1F:1B DNS reply: 68.233.169.105 53 61334 68.87.71.226 68.85.2.101 MAC of DNS MAC of default R DNS Server 68.87.71.226 GUC 68.85.2.0/24 Bob 00:16:D3:23:63:8A 68.85.2.101 ISP 68.80.0.0/13 00:22:6B:45:1F:1B 68.85.2.1 To send HTTP request, Bob’s browser has to create a TCP socket. Thus, it needs the IP address of www.google.com www.google.com 68.233.169.105 Google 68.233.160.0/19
A Day in the Life of a Webpage Request 52122 80 68.85.2.101 68.233.169.105 00:16:D3:23:63:8A 00:22:6B:45:1F:1B DNS Server 68.87.71.226 GUC 68.85.2.0/24 Bob 00:16:D3:23:63:8A 68.85.2.101 ISP 68.80.0.0/13 00:22:6B:45:1F:1B 68.85.2.1 To establish TCP connection, TCP SYN packet is sent www.google.com 68.233.169.105 Google 68.233.160.0/19 80 52122 68.233.169.105 68.85.2.101 MAC of web server MAC of default R
A Day in the Life of a Webpage Request HTTP Request: google search 52122 80 68.85.2.101 68.233.169.105 00:16:D3:23:63:8A 00:22:6B:45:1F:1B DNS Server 68.87.71.226 GUC 68.85.2.0/24 Bob 00:16:D3:23:63:8A 68.85.2.101 ISP 68.80.0.0/13 00:22:6B:45:1F:1B 68.85.2.1 Finally HTTP request can be sent HTTP Reply: search results 80 52122 68.233.169.105 68.85.2.101 MAC of web server MAC of default R www.google.com 68.233.169.105 Google 68.233.160.0/19