University of British Columbia CICS 515 (Part 2) Computer Networks Lecture 5 – IP (Ch 4) Instructor: Dr. Son T. Vuong Email: vuong@cs.ubc.ca 1 The World Connected Jump to first page Ch 4: Network Layer and Routing The IP Protocol Routing IP Format, Addressing, fragmentation, Internet Control Protocols (ICMP) (next lecture) RIP (Routing Information Protocol) OSPF (Open Shortest Path First) The Interior Gateway Routing Protocol BGP – The Exterior Gateway Routing Protocol IPv6 Internet Multicasting Mobile IP CICS515 Summer 2012 Instructor: Dr. Son Vuong 2 ISO Architecture End host End host Application Application Presentation Presentation Session Session Transport Transport IP Network Network Network Network Data link Data link Data link Data link Physical Physical Physical Physical One or more nodes within the network CICS515 Summer 2012 Instructor: Dr. Son Vuong 3 Internet Architecture Defined by Internet Engineering Task Force (IETF) Hourglass Design Application vs Application Protocol (FTP, HTTP) FTP HTTP NV TFTP UDP TCP TCP IP NET1 CICS515 Summer 2012 NET2 Application UDP IP … NETn Instructor: Dr. Son Vuong Network 4 Design Principles for Internet Make sure it works. Keep it simple. Make clear choices. Exploit modularity. Expect heterogeneity. Avoid static options and parameters. Look for a good design; it need not be perfect. Be strict when sending and tolerant when receiving. Think about scalability. Consider performance and cost. CICS515 Summer 2012 Instructor: Dr. Son Vuong 5 Collection of Subnetworks The Internet = interconnected collection of many networks. CICS515 Summer 2012 Instructor: Dr. Son Vuong 6 Example TCP/IP internet H2 H1 Network 1 (Ethernet) H7 R3 H8 H3 Network 4 (point-to-point) Network 2 (Ethernet) R1 R2 H4 Network 3 (FDDI) H1 H8 H5 TCP R1 R2 IP IP ETH H6 ETH CICS515 Summer 2012 R3 IP FDDI FDDI Instructor: Dr. Son Vuong IP PPP PPP TCP IP ETH ETH 7 IP Service Model Packet Delivery Model Connectionless (datagram-based) Best-effort delivery (unreliable service) Loss, out-of-order, duplication long, variable delay Global Addressing Scheme IP Addresses Routing info provided within header, no set up phase. IP runs over any Layer 2/3 network Ethernet, CICS515 Summer 2012 FDDI, ATM, Point to Point, etc. Instructor: Dr. Son Vuong 8 IP Packet Format 0 4 8 V ersion HLen 16 TOS 31 Length Ident TTL 19 Flags Protocol Offset Checksum SourceIPAddr DestinationIPAddr Pad (variable) Options (variable) Data CICS515 Summer 2012 Instructor: Dr. Son Vuong 9 The IP Protocol (2) 5-54 Some of the IP options. CICS515 Summer 2012 Instructor: Dr. Son Vuong 10 IP Packet Details Datagram format (4) - Currently set to 4 (IPv4). We’ll discuss IPv6. Hlen (4) - Number of 32-bit words in the header (allows for a variable number of options) TOS (8) - Type of service (not widely used) Length (16) - Number of bytes in this datagram Maximum size is 64KB. Ident (16) - Used for fragmentation Flags(3)/Offset(13) (16) - Used for fragmentation (offset in units of 8 bytes) Version CICS515 Summer 2012 Instructor: Dr. Son Vuong 11 IP Packet Details cont. TTL (8) - Number of hops this datagram can travel (defaults to 64). Originally was intended to count seconds, but impossible without a central clock. Protocol (8) - Demultiplexing key for higher level protocols (TCP=6, UDP=17) Checksum (16) - Of the header only, using Internet Checksum method (as in UDP and TCP) DestAddr & SrcAddr (32) - See later. Options, e.g. timestamp, record route, (strict/loose) source routing CICS515 Summer 2012 Instructor: Dr. Son Vuong 12 Fragmentation and Reassembly Each Layer 2/3 network has a Maximum Transmission Unit (MTU) e.g. Ethernet is 1500, FDDI is 4500 Unreasonable to make all IP packets small enough to fit within all possible MTUs. Strategy Fragment only when necessary (MTU < Datagram) Try to avoid fragmentation at source host Fragments are self-contained IP datagrams Reassembly of fragments at destination host. CICS515 Summer 2012 Instructor: Dr. Son Vuong 13 Fragmentation Example H1 R1 ETH IP (1400) CICS515 Summer 2012 R2 FDDI IP (1400) Instructor: Dr. Son Vuong R3 H8 PPP IP (512) ETH IP (512) PPP IP (512) ETH IP (512) PPP IP (376) ETH IP (376) 14 Fragmentation cont. If one fragment is lost, discard all other fragments. Higher layers will recover. The IP header has fields for handling this type of fragmentation. Set the M bit (in flags) to indicate that more data is coming. Set the offset to indicate where each of the fragmented blocks starts. Set the ident field to identify related packets. CICS515 Summer 2012 Instructor: Dr. Son Vuong 15 IP Fragmentation and Reassembly length ID fragflag offset =4000 =x =0 =0 Example 4000 byte datagram One large datagram becomes several smaller datagrams MTU = 1500 bytes 1480 bytes in data field offset = 1480/8 length ID fragflag offset =1500 =x =1 =0 length ID fragflag offset =1500 =x =1 =185 length ID fragflag offset =1040 =x =0 =370 length = 4000 – 2*1480 = 4000 - 2960 = 1040 CICS515 Summer 2012 Instructor: Dr. Son Vuong 16 IP Fragmentation– Peer Instruction – Question 5.1 A 1300-byte IP datagram sent through a network with 500-byte MTU must be fragmented into 3 fragments with the following respective <length, offset> values in the header: A. <500, 0>, <500, 460>, <500, 920> B. <500, 0>, <500, 480>, <300, 960>. C. <500, 0>, <500, 500, <300, 1000> D. <500, 0>, <500, 60>, <340, 120> E. None of the above CICS515 Summer 2012 Instructor: Dr. Son Vuong 17 Global Addresses Properties of IP addresses. Globally unique - No confusion about where to send a packet. Hierarchical - Network component and host number. Normally written in “Dot notation” (4 byte values, total 32 bits) 10.3.2.4 128.96.33.81 192.12.69.77 142.103.7.7 CICS515 Summer 2012 (cascade.cs.ubc.ca) Instructor: Dr. Son Vuong 18 IP Addresses IP address formats. CICS515 Summer 2012 Instructor: Dr. Son Vuong 19 Address Notation Binary 11000000 00000101 00110000 00000011 Hex Colon C0:05:30:03 Dotted Decimal 192.5.48.3 CICS515 Summer 2012 Instructor: Dr. Son Vuong 20 Class Ranges Dotted Decimal w.x.y.z Class A: w= 0 thru 127 Class B: w= 128 thru 191 Class C: w= 192 thru 223 Class D: w= 224 thru 239 Class E: w= 240 thru 255 CICS515 Summer 2012 Instructor: Dr. Son Vuong 21 Class Formats Class A: 128 Networks, 16777216 hosts each Class B: 16384 Networks, 65536 hosts each Class C: 2097152 Networks, 256 hosts each The plan was to give each organization (company or university) a network number that is appropriate for their size, and let them allocate host numbers. Example: UBC has several class B and C addresses. E.g. 142.103.7.7 and 198.162.33.12 In reality, variations on this method are used. CICS515 Summer 2012 Instructor: Dr. Son Vuong 22 IP Addresses (2) Special IP addresses. CICS515 Summer 2012 Instructor: Dr. Son Vuong 23 Subnets A campus network consisting of LANs for various departments. CICS515 Summer 2012 Instructor: Dr. Son Vuong 24 Subnets (2) A class B network subnetted into 64 subnets. CICS515 Summer 2012 Instructor: Dr. Son Vuong 25 CIDR – Classless InterDomain Routing address format: a.b.c.d/x subnet portion of arbitrary length x subnet part host part 11001000 00010111 00010000 00000000 200.23.16.0/23 A set of IP address assignments CICS515 Summer 2012 Instructor: Dr. Son Vuong 26 NAT – Network Address Translation Placement and operation of a NAT box. CICS515 Summer 2012 Instructor: Dr. Son Vuong 27 Datagram Forwarding Using these IP address, how do we route messages? Strategy every datagram contains destination's address if directly connected to destination network, then forward to host if not directly connected to destination network, then forward to some router forwarding table maps network number into next hop each host has a default router each router maintains a forwarding table A forwarding table maps network numbers into router addresses. CICS515 Summer 2012 Instructor: Dr. Son Vuong 28 Example: Forwarding Table for R2 Network 1 (Ethernet) H7 H2 H1 R3 H8 H3 Network 4 (point-to-point) Network 2 (Ethernet) R1 For Router R2 R2 H4 Network Next Hop 1 2 3 4 R3 R1 interface 1 interface 0 Network 3 (FDDI) H5 CICS515 Summer 2012 H6 Instructor: Dr. Son Vuong 29 Examples Sending from H1 to H2: Same network, so send an Ethernet frame to the Ethernet address for H2 Sending from H1 to H8: Send an Ethernet frame from H1 to R1 Send an FDDI packet from R1 to R2 Send a point to point message from R2 to R3 Send an Ethernet frame from R3 to H8 CICS515 Summer 2012 Instructor: Dr. Son Vuong 30 Scalability In reality, it’s not possible to list an appropriate router for every network on the internet. The table will get too big. Commonly we’ll have a list of well-known networks, but use a default router for all other networks. For example: Network 3 could get to Network 2 via R1, and will use R2 for all other networks. Sometimes, we only have a single default router on each network. CICS515 Summer 2012 Instructor: Dr. Son Vuong 31 Internet Control Message Protocol (ICMP) If something goes wrong with an IP packet, a control message is sent back to the sender: Echo (ping) Request/Reply Timestamp Request/Reply Redirect (from router to source host) Source quench Destination unreachable (protocol, port, or host) TTL exceeded (so datagrams don't cycle forever) Checksum failed Reassembly failed Cannot fragment CICS515 Summer 2012 Instructor: Dr. Son Vuong 32 Summary - What have we covered? CICS515 Summer 2012 internetworks IP (Layer 3.5) packets and fragmentation addressing and address classes packet forwarding ICMP Instructor: Dr. Son Vuong 33