IP Address 0 network host 10 network host 110 networkhost 1110 multicast address A B C D class to to to to bits 7 bits 14 bits 21 bits 28 bits Class-based address:
IP addressing: CIDR Classful addressing: –inefficient use of address space, address space exhaustion –e.g., class B net allocated enough addresses for 65K hosts, even if only 500 hosts in that network CIDR: Classless InterDomain Routing –network portion of address of arbitrary length –address format: a.b.c.d/x, where x is # bits in network portion of address network part host part /23
CIDR Network address: /23 –/23 : network mask More efficient use of address –Consider a network with 500 hosts –Classful address: a class B address, wasting over 64K addresses –CIDR: a network with /23 –One class B address can be used for 128 such networks using CIDR Routing difficulty –Classful: only need the IP address to determine the network add –CIDR: also need network mask information to determine the network address –Longest match first
IP addresses: how to get one? Q: How does host get IP address? hard-coded by system admin in a file –Wintel: control-panel->network- >configuration->tcp/ip->properties –UNIX: /etc/rc.config DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server –“plug-and-play” : host automatically obtain an IP and related info –mobile computing
IP addresses: how to get one? Q: How does network get network part of IP addr? A: gets allocated portion of its provider ISP’s address space (a good example for CIDR) ISP's block /20 Organization /23 Organization /23 Organization /23... ….. …. …. Organization /23
IP routing IP address: 32-bit identifier for host, router interface interface: connection between host/router and physical link –router’s typically have multiple interfaces –host may have multiple interfaces –IP addresses associated with each interface = Network address: /24
IP Routing IP address: –network part (high order bits) is used for routing –host part (low order bits) not used for routing network consisting of 3 IP networks (for IP addresses starting with 223, first 24 bits are network address) LAN
Getting a datagram from source to dest. IP datagram: A B E misc fields source IP addr dest IP addr data datagram remains unchanged, as it travels source to destination addr fields of interest here Default router for all other networks Dest. Net. next router Nhops Others x forwarding table in A
Getting a datagram from source to dest. Starting at A, send IP datagram addressed to B: look up net. address of B in forwarding table find B is on same net. as A link layer will send datagram directly to B inside link-layer frame –B and A are directly connected Dest. Net. next router Nhops misc fields data A B E forwarding table in A
Getting a datagram from source to dest. Dest. Net. next router Nhops Starting at A, dest. E: look up network address of E in forwarding table E on different network –A, E not directly attached routing table: next hop router to E is link layer sends datagram to router inside link- layer frame datagram arrives at continued….. misc fields data A B E forwarding table in A
Getting a datagram from source to dest. Arriving at , destined for look up network address of E in router’s forwarding table E on same network as router’s interface –router, E directly attached link layer sends datagram to inside link-layer frame via interface datagram arrives at !!! (hooray!) misc fields data Dest. Net router Nhops interface A B E forwarding table in router
CIDR Routing network part host part / network part host part /17 CIDR routing: longest match first
IP Fragmentation & Reassembly network links have MTU (max.transfer size) - largest possible link-level frame. –different link types, different MTUs large IP datagram divided (“fragmented”) within net –one datagram becomes several datagrams –“reassembled” only at final destination –IP header bits used to identify, order related fragments fragmentation: in: one large datagram out: 3 smaller datagrams reassembly
IP Fragmentation and Reassembly ID =x offset =0 fragflag =0 length =4000 ID =x offset =0 fragflag =1 length =1500 ID =x offset =1480 fragflag =1 length =1500 ID =x offset =2960 fragflag =0 length =1040 One large datagram becomes several smaller datagrams Example 4000 byte datagram MTU = 1500 bytes
LAN Addresses and ARP 32-bit IP address: network-layer address used to get datagram to destination IP network (recall IP network definition) LAN (or MAC or physical or Ethernet) address: used to get datagram from one interface to another physically-connected interface (same network) 48 bit MAC address (for most LANs) burned in the adapter ROM
LAN Addresses and ARP Each adapter on LAN has unique LAN address
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 (b) IP address: like postal address MAC flat address => portability –can move LAN card from one LAN to another IP hierarchical address NOT portable – depends on IP network to which node is attached
Recall earlier routing discussion A B E 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 B’s MAC addr A’s MAC addr A’s IP addr B’s IP addr IP payload datagram frame frame source, dest address datagram source, dest address
ARP: Address Resolution Protocol Each IP node (Host, Router) on LAN has ARP table ARP Table: IP/MAC address mappings for some LAN nodes – TTL (Time To Live): time after which address mapping will be forgotten (typically 20 min) Question: how to determine MAC address of B knowing B’s IP address?
ARP protocol A wants to send datagram to B, and A knows B’s IP address. Suppose B’s MAC address is not in A’s ARP table. A broadcasts ARP query packet, containing B's IP address –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
Routing to another LAN walkthrough: send datagram from A to B via R assume A know’s B IP address Two ARP tables in router R, one for each IP network (LAN) In routing table at source Host, find router In ARP table at source, find MAC address E6-E BB-4B, etc A R B
A creates datagram with source A, destination B A uses ARP to get R’s MAC address for A creates link-layer frame with R's MAC address as dest, frame contains A-to-B IP datagram A’s data link layer sends frame R’s data link layer receives frame R removes IP datagram from Ethernet frame, sees its destined to B R uses ARP to get B’s physical layer address R creates frame containing A-to-B IP datagram sends to B A R B
Ethernet “dominant” LAN technology: cheap $20 for 100Mbs! first widely used LAN technology Simpler, cheaper than token LANs and ATM Kept up with speed race: 10, 100, 1000 Mbps Metcalfe’s Ethernet sketch
Ethernet Frame Structure Sending adapter encapsulates IP datagram (or other network layer protocol packet) in Ethernet frame Preamble: 7 bytes with pattern followed by one byte with pattern used to synchronize receiver, sender clock rates
Ethernet Frame Structure (more) Addresses: 6 bytes –if adapter receives frame with matching destination address, or with broadcast address (eg ARP packet), it passes data in frame to net-layer protocol –otherwise, adapter discards frame Type: indicates the higher layer protocol, mostly IP but others may be supported such as Novell IPX and AppleTalk) CRC: checked at receiver, if error is detected, the frame is simply dropped