Network Layer and IP

                                           CSC 343·643

                                       WAKE ...
Internet Protocols CSC 343·643                                           Network Layer and IP   2




                    ...
Internet Protocols CSC 343·643                                                                                         Net...
Internet Protocols CSC 343·643                                                                                            ...
Internet Protocols CSC 343·643                                                                                     Network...
Internet Protocols CSC 343·643                                                           Network Layer and IP   10




   ...
Internet Protocols CSC 343·643                                                                                            ...
Internet Protocols CSC 343·643                                            Network Layer and IP   14




                  ...
Internet Protocols CSC 343·643                                             Network Layer and IP   16




                 ...
Internet Protocols CSC 343·643                                                                              Network Layer ...
Internet Protocols CSC 343·643                                                                          Network Layer and ...
Internet Protocols CSC 343·643                                                                                            ...
Internet Protocols CSC 343·643                                                                                      Networ...
Internet Protocols CSC 343·643                                                                                            ...
Internet Protocols CSC 343·643                                                                Network Layer and IP   28


...
Internet Protocols CSC 343·643                                               Network Layer and IP   30




             • ...
Internet Protocols CSC 343·643                                                                                            ...
Internet Protocols CSC 343·643                                                                            Network Layer an...
Internet Protocols CSC 343·643                                                                                         Net...
Upcoming SlideShare
Loading in …5
×

Network Layer and IP

873 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
873
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
55
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Network Layer and IP

  1. 1. Network Layer and IP CSC 343·643 WAKE FOREST U N I V E R S I T Y Department of Computer Science Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 1 Network Layer • Concerned with getting packets from the source to the destination • In contrast, the data-link layer – Moves frames from one end of the wire to another – Assume everyone is locally connected • Network layer deals with end-to-end transmission – Routing packets (or datagrams) from one machine to another until destination is reached Token passing required forwarding a frame from one machine to another, is this routing? E. W. Fulp Fall 2009
  2. 2. Internet Protocols CSC 343·643 Network Layer and IP 2 Network Layer Issues Host A B Router R2 R3 R1 R4 D C • Routing – Given different paths, which should be taken? – Should every packet take the same route? • Congestion control – Prevent a link (router) from becoming overwhelmed • Internetworking – Interconnect different networks at the network level E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 3 Network Layer Designs 1. Connectionless (Internet community argument) • Network viewed as unreliable • Hosts perform error control, flow control, and packet ordering • Each packet sent independently – Routes taken may change over time Why would a route change? Implications of multiple routes? Host A B Router R2 R3 R1 R4 D C E. W. Fulp Fall 2009
  3. 3. Internet Protocols CSC 343·643 Network Layer and IP 4 2. Connection-oriented (Telephone company argument) • Network should be reasonably reliable • Path established before packets sent – Negotiate resources (QoS) at each hop Any advantages to establishing a path? Host A B Router R2 R3 R1 R4 D C Any disadvantages to establishing a path? E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 5 Network Layer in the Internet • Internet can be viewed as a set of connected Autonomous Systems The global Internet Access networks Global internetwor k Regional/national networks/internetworks Continental backbones Core backbone North America Asia International and the Europe Pacific links Central and South America = Internet router s = access network gateways = hosts E. W. Fulp Fall 2009
  4. 4. Internet Protocols CSC 343·643 Network Layer and IP 6 • The network layer is what allows the pieces to interconnect • The Internet Protocol (IP) provides 1. Best Effort (BE) transport of datagrams – Unreliable service – Packets may arrive out of order, if at all... – No Quality of Service (QoS) guarantees provided 2. Routing from source to destination – Can route to different AS – Routes can change based on network conditions Is IP connectionless or connection-oriented? E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 7 Internet Operation Overview Network 1 (Ethernet) H7 R3 H8 H1 H2 H3 Network 4 Network 2 (Ethernet) (point-to-point) H1 H8 R1 TCP R1 R2 R3 TCP R2 H4 IP IP IP IP IP Network 3 (FDDI) ETH ETH FDDI FDDI PPP PPP ETH ETH H5 H6 • Network layer takes data streams and breaks into datagrams – Datagram can be up to 64KB each, average is 1500 bytes • Each datagram is transmitted through the Internet – Possibly fragmented • Pieces arrive at destination, reassembled into original datagram • Datagram is passed to the transport layer E. W. Fulp Fall 2009
  5. 5. Internet Protocols CSC 343·643 Network Layer and IP 8 IP Protocol Datagrams • Datagram (packet) consists of a header part and data part • Header consists of: 20 byte fixed part and an optional part 32 Bits Version IHL Type of service Total length D M Identification F F Fragment offset Time to live Protocol Header checksum Source address Destination address Options (0 or more words) • Big endian order (left → right) also called network byte order – SPARC is big endian, while Pentium is little endian E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 9 IP Header: Version and IHL Fields • Version field (4 bits) – Identifies the version of IP (e.g. IPv4 or IPv6) • Internet Header Length (IHL, 4 bits) – Total length of the IP header, in measured 32-bit words – Minimum value is 5 (no options are present) – Maximum value is 15, which is a byte header – This will limit the usefulness of some options E. W. Fulp Fall 2009
  6. 6. Internet Protocols CSC 343·643 Network Layer and IP 10 IP Header: ToS Field Type of Service (ToS) is 8 bits • Indicates the type of service expected, has sub-fields 1. First three bits are the precedence (priority) sub-field – Range from 0 (normal) to 7 (control packet) – “which is ignored today” - Stevens 2. Next four bits request different types of service Min Max Max Min Hex Application Delay Throughput Reliability Cost Value Telnet 1 0 0 0 0x10 FTP data 0 1 0 0 0x08 SNMP 0 0 1 0 0x04 3. One unused bit • ToS feature is not supported by most IP implementations E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 11 IP Header: Total Length and Fragmentation Fields • Total length field (16 bits) – Datagram length (header and data), measured in bytes What is the maximum size of an IP datagram? • Identification field (16 bits) – Identifies which datagram the fragment belongs to – One number for all the fragments of a packet • DF (Don’t Fragment) 1 bit, if set then don’t fragment • MF (More Fragments) 1 bit, set if not last fragment • Fragment offset (13 bits) – Where in the current datagram this fragment belongs – Fragments must be a multiple of 8 bytes (except for last one) E. W. Fulp Fall 2009
  7. 7. Internet Protocols CSC 343·643 Network Layer and IP 12 IP Fragmentation and Reassembly • Different network technologies have different packet sizes – Every network has a Maximum Transmission Unit (MTU) – If the datagram is larger than the MTU, then it is fragmented • “Every internet module must be able to forward a datagram of 68 octets without further fragmentation... Every internet destination must be able to receive a datagram of 576 octets either in one piece or in fragments to be reassembled.” - [RFC791] Network 1 (Ethernet) H7 R3 H8 H1 H2 H3 Network 4 H1 R1 R2 R3 H8 Network 2 (Ethernet) (point-to-point) MTU = 1500 bytes MTU = 532 bytes R1 R2 H4 Network 3 (FDDI) ETH IP (1400) FDDI IP (1400) PPP IP (512) ETH IP (512) MTU = 4500 bytes 1420 bytes total payload PPP IP (512) ETH IP (512) (IP header is 20 bytes) H5 H6 PPP IP (376) ETH IP (376) E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 13 • Assume R2 has a MTU (data) of 532 bytes (allows a 20 byte header and 512 bytes of data) • The original 1420 byte datagram fragmented into 3 pieces at R2 Original Datagram Datagram Fragmented Start of header Start of header Ident = x 0 Offset = 0 Ident = x 1 Offset = 0 Rest of header Rest of header 1400 data bytes 512 data bytes Start of header Ident = x 1 Offset = 512 Rest of header 512 data bytes Start of header Ident = x 0 Offset = 1024 Rest of header 376 data bytes • RFC 1191 gives some example MTU sizes, based on the link layer E. W. Fulp Fall 2009
  8. 8. Internet Protocols CSC 343·643 Network Layer and IP 14 IP Header: TTL and Protocol Fields • Time To Live (TTL, 8 bits) – Counter to limit packet lifetime – Maximum lifetime of packet (in seconds) What is the maximum maximum lifetime? – Time spent at every router is subtracted – Actually decremented once per hop – Once zero is reached, a control packet is sent back What problem does TTL attempt to prevent? • Protocol field (8 bits) – Which transport process the packet belongs to (e.g. TCP or UDP) numbers are global defined in [RFC 1700] E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 15 IP Header: Checksum and Address Fields • Header checksum (16 bits) – Verifies only the header – Add all 16 bit words (one’s complement) then take the one’s complement of the sum A new checksum is computed and stored in the header at every hop, why? What happens if an error is detected? How is the data verified? Do we care at this layer? • Source and destination addresses – 32 bits each, more later... E. W. Fulp Fall 2009
  9. 9. Internet Protocols CSC 343·643 Network Layer and IP 16 IP Header: Options Field • Allow subsequent versions of IP to include new features • Option begins with a one byte idenfication code, 5 are defined 1. Security - Security and handling restrictions [RFC1108] If set, helps a sniffer identify the more interesting datagrams 2. Strict source routing - Gives path to follow (security issue? ) 3. Loose source routing - List routers not to be missed 4. Record route - Make every router append IP address Why is this no longer useful? 5. Timestamp - Make every router append address and time • Options field padded out to end on 32 bit boundary • “these options are rarely used and not all hosts and routers support all the options” - Stevens E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 17 IPv4 Addresses Every host or router (actually interface) has a unique IP address • IP addresses are 32 bits long (IP version 4) and are used in the source and destination fields of the IP datagram • Dotted-decimal notation is used to represent each address, each byte is represented via a decimal number – 193.32.216.9 ⇒ [11000001 00100000 11011000 00001001] The data link layer also has an address, what is the difference? Why is a network address needed? • Addresses are hierarchical and encode two numbers, network and host E. W. Fulp Fall 2009
  10. 10. Internet Protocols CSC 343·643 Network Layer and IP 18 IP Network Example Consider one router and seven hosts (one address per interface) 223.1.3.2 223.1.2.1 223.1.3.27 223.1.2.9 223.1.3.1 223.1.2.2 223.1.1.4 223.1.1.1 223.1.1.2 223.1.1.3 • Three hosts at bottom have similar addresses, 223.1.1.x – The leftmost 24 bits they share is the network portion – Remaining 8 bits is the host portion How many hosts can connect to the 223.1.1.x network? E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 19 • Hosts of 223.1.1.x form a network, interconnected via a LAN – The network address is 223.1.1.0/24 – The /24 is also called the network mask or network prefix ∗ Indicates the 24 leftmost bits define the network address – Any additional host that would attach to this network must have a unique address of the form 223.1.1.x • The remaining networks have a similar structure 223.1.3.0/24 223.1.2.0/24 223.1.1.0/24 E. W. Fulp Fall 2009
  11. 11. Internet Protocols CSC 343·643 Network Layer and IP 20 Multiple IP Networks IP definition of a network is not restricted to Ethernet segments • Consider three routers interconnected via point-to-point links 223.1.1.1 223.1.1.4 223.1.1.3 R1 223.1.9.2 223.1.7.0 223.1.2.1 223.1.3.1 223.1.9.1 223.1.7.1 223.1.2.6 223.1.8.1 223.1.8.0 223.1.3.27 R3 R2 223.1.2.2 223.1.3.2 E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 21 • Each router has three interfaces – One for each point-to-point link – One for the broadcast link to the hosts • What are the networks in the diagram – Three networks interconnecting hosts, 223.1.1.0/24, 223.1.2.0/24, and 223.1.3.0/24 – Three additional networks that interconnect routers ∗ 223.1.7.0/24 connects R1 ⇔ R2 ∗ 223.1.8.0/24 connects R2 ⇔ R3 ∗ 223.1.9.0/24 connects R3 ⇔ R1 • How do we determine what is a network – Detach each interface from host or router – Resulting islands are the networks E. W. Fulp Fall 2009
  12. 12. Internet Protocols CSC 343·643 Network Layer and IP 22 IPv4 Address Classes The original Internet architecture defined 5 different IP address classes • This is also know as classful addressing • Classes differ on how bits are divided (network versus host) 32 Bits Range of host Class addresses 1.0.0.0 to A 0 Network Host 127.255.255.255 128.0.0.0 to B 10 Network Host 191.255.255.255 192.0.0.0 to C 110 Network Host 223.255.255.255 224.0.0.0 to D 1110 Multicast address 239.255.255.255 240.0.0.0 to E 11110 Reserved for future use 247.255.255.255 • This creates 3 different classes of networks (A, B, and C) E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 23 • For example, consider class A addresses 32 Bits 1.0.0.0 to A 0 Network Host 127.255.255.255 – First bit is zero, identifies class A – Next 7 bits identify the network – Last 24 bits identify the host (interface) in the class A network • In comparison, class B has 32 Bits 128.0.0.0 to B 10 Network Host 191.255.255.255 What class is 223.1.1.0/24? As a company, would you prefer an A, B, or C address? E. W. Fulp Fall 2009
  13. 13. Internet Protocols CSC 343·643 Network Layer and IP 24 IP Addresses with Special Meanings 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 This host 0 0 ... 0 0 Host A host on this network Broadcast on the 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 local network Broadcast on a Network 1111 ... 1111 distant network 127 (Anything) Loopback • 0.0.0.0 only used by a host when booting • All zeroes for the network number, refers to the local network – If 223.1.1.0/24 is the network and I am 223.1.1.52, locally I can be reached using 0.0.0.52 • Address of all ones is the broadcast address for the local network What is the dotted-decimal address? E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 25 • Address with the proper network number, and all ones for the host number allows host to broadcast to a different network – If 223.1.1.0/24 is a distant network, then 223.1.1.255 broadcasts to all hosts at the network This and ping can can be used as a network attack, how? • 127.x.y.z is reserved for loop-back testing – Packet is never placed on the network, processed locally Given a class A address, how many hosts can be connected to the network? E. W. Fulp Fall 2009
  14. 14. Internet Protocols CSC 343·643 Network Layer and IP 26 IP Addresses and Routing • We have introduced IP addresses and the concept of a network – IP addresses are 32 bits long, and can be divided into classes – Each class divides address into network and host portion 32 Bits Range of host Class addresses 1.0.0.0 to A 0 Network Host 127.255.255.255 128.0.0.0 to B 10 Network Host 191.255.255.255 192.0.0.0 to C 110 Network Host 223.255.255.255 224.0.0.0 to D 1110 Multicast address 239.255.255.255 240.0.0.0 to E 11110 Reserved for future use 247.255.255.255 – All hosts in one network have the same network portion, different host portion; therefore, the addresses are hierarchical Why is it important to identify the class of an address? E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 27 Routing Tables How does a source host send a datagram to a destination host? • The IP layer maintains a routing table in memory – Remember, routing tables are next hop oriented – Multiple hop paths are not recorded • Each entry in the routing table has the following informationa 1. Destination address, either host or network address 2. IP address of the next-hop router 3. Flags specifying if next hop is host or network 4. Identification of the interface the datagram should be passed to (e.g. multiple Ethernet cards attached) a Abbreviated list of items, more later. E. W. Fulp Fall 2009
  15. 15. Internet Protocols CSC 343·643 Network Layer and IP 28 Example Routing Tables eth0 eth0 223.1.3.2 223.1.2.1 223.1.3.27 223.1.2.9 eth2 eth1 E 223.1.3.1 223.1.2.2 eth0 223.1.1.4 eth0 eth0 eth0 eth0 eth0 A B 223.1.1.1 223.1.1.2 223.1.1.3 • In the diagram, each interface (Ethernet card) is labeled (in red) • For example, the router has 3 interfaces (eth0, eth1, and eth2) – Each interface must be uniquely identified, since it attaches a unique network E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 29 • An abbreviated routing table for host A would be Routing Table for A Destination Next Hop Interface 223.1.1.0/24 eth0 223.1.2.0/24 223.1.1.4 eth0 223.1.3.0/24 223.1.1.4 eth0 – First entry indicates 223.1.1.0/24 is the local network – The second and third entries indicate datagrams for destinations on network 223.1.2.0/24 or 223.1.3.0/24 must be sent to 223.1.1.4 – eth0 is the Ethernet interface (only one card on A) Each network is represented with one entry, how many would be required if each host had a separate entry? E. W. Fulp Fall 2009
  16. 16. Internet Protocols CSC 343·643 Network Layer and IP 30 • An abbreviated routing table for the router would be Routing Table for Router Destination Next Hop Interface 223.1.1.0/24 eth0 223.1.2.0/24 eth1 223.1.3.0/24 eth2 – First entry indicates 223.1.1.0/24 is local on eth0 – Second entry indicates 223.1.2.0/24 is local on eth1 – Third entry indicates 223.1.3.0/24 is local on eth2 E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 31 IP Routing Steps • IP routing performs the following actions 1. Search routing table for complete destination address, if found send packet to the next-hop entry 2. Search routing table for an entry that matches the destination network number, if found send packet to the next-hop entry – Must take into account possible subnet mask 3. Search for default entry, if found send to next-hop router • IP search order is, host address → host network → default • If all the steps fail, then the datagram is not deliverable E. W. Fulp Fall 2009
  17. 17. Internet Protocols CSC 343·643 Network Layer and IP 32 Routing Example: A → B Assume A (223.1.1.1) sends datagram to B (223.1.1.3) 223.1.1.1 223.1.1.3 Link IP Data Header Header Dest: 223.1.1.3 LLA of: 223.1.1.3 • There is no host entry for 223.1.1.3 • There is a network entry for 223.1.1.0/24 • A link layer frame (containing the datagram) is created and addressed to the link layer address of 223.1.1.3 We are at layer 3, how do we get a layer 2 address? • Ethernet frame is sent and received by host B E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 33 Routing Example: A → E Assume A (223.1.1.1) sends datagram to E (223.1.2.2) Routing Table for A Routing Table for Router Destination Next Hop Interface Destination Next Hop Interface 223.1.1.0/24 eth0 223.1.1.0/24 eth0 223.1.2.0/24 223.1.1.4 eth0 223.1.2.0/24 eth1 223.1.3.0/24 223.1.1.4 eth0 223.1.3.0/24 eth2 • Host A finds entry for 223.1.2.0/24 network – Requires sending packet to 223.1.1.4 • Host A creates and sends link-layer frame (containing datagram) addressed to the link-layer address of 223.1.1.4 – Therefore, the next-hop entry is used for the link-layer address – IP destination address remains unchanged E. W. Fulp Fall 2009
  18. 18. Internet Protocols CSC 343·643 Network Layer and IP 34 • Router 223.1.1.4 receives frame and removes datagram – Destination address is 223.1.2.2 – Router is allowed to forward datagrams • Router finds entry for 223.1.2.0/24 network – This is directly connected via eth1 – Datagram will be forwarded • Router creates and sends link-layer frame (containing datagram) addressed to the link-layer address of 223.1.2.2 on eth1 • Frame received by host E, datagram removed and processed • N.B. operation of host and router are equivalent, except routers are allowed to forward datagrams E. W. Fulp Fall 2009 Internet Protocols CSC 343·643 Network Layer and IP 35 eth0 eth0 223.1.3.2 223.1.2.1 223.1.3.27 223.1.2.9 eth2 eth1 E 223.1.3.1 223.1.2.2 2 eth0 223.1.1.4 eth0 eth0 1 eth0 eth0 eth0 A B 223.1.1.1 223.1.1.2 223.1.1.3 Link IP Link IP 1 Data 2 Data Header Header Header Header Dest: 223.1.2.2 Dest: 223.1.2.2 LLA of: 223.1.1.4 LLA of: 223.1.2.2 E. W. Fulp Fall 2009
  19. 19. Internet Protocols CSC 343·643 Network Layer and IP 36 Another Routing Example Assume 140.1.1.1 sends a datagram to 152.24.25.5 Link IP Data Header Header Dest: 152.24.25.5 140.2.2.18 LLA of: 140.2.2.18 140.2.0.0/16 Internet 140.2.2.7 modem SLIP IP Data Header modem Dest: 152.24.25.5 140.1.1.1 140.1.1.25 Link IP 140.1.0.0/16 Data Header Header Dest: 152.24.25.5 LLA of: 140.1.1.25 E. W. Fulp Fall 2009

×