Sie sind auf Seite 1von 21

CS 455/555 Intro to Networks and Communications The Network Layer

Michele Weigle
Department of Computer Science Old Dominion University mweigle@cs.odu.edu

http://www.cs.odu.edu/~mweigle/courses/cs455-f06/ http://www.cs.odu.edu/~mweigle/courses/cs555-f06/
1

The Network Layer: Routing & Addressing


Outline
! ! ! !

Network layer functions Router architecture IP Internet Protocol


Addressing

application transport network link physical

Routing algorithms
Least cost path computation algorithms

! !

Hierarchical routing
Connecting networks of networks

Routing on the Internet


Intra-domain routing Inter-domain routing
application transport network link physical

The Network Layer


Network Layer Functions
!

Application-layer protocols dene when and how Logical end-to-end messages are sent transport Transport-layer protocols deliver data between processes on different end-systems
Transport protocols execute only on end systems

application transport network link physical

Physical endto-end packet delivery


network link physical network link physical network link physical

network link physical

network link physical

network link physical

network link physical

Network-layer protocols deliver data from one end-system to another


Network layer protocols execute on every end-system and router

network link physical

application transport network link physical


3

The Network Layer


Network Layer Functions
!

The network-layer provides two important functions:


Routing: the route taken by packets from source to destination (involves all routers) Forwarding (aka Switching): the movement of packets from an input interface to an appropriate output interface (involves a single router)
4

The Network Layer: Routing & Addressing


Outline
! ! ! !

Network layer functions Router architecture IP Internet Protocol


Addressing

application transport network link physical

Routing algorithms
Least cost path computation algorithms

! !

Hierarchical routing
Connecting networks of networks

Routing on the Internet


Intra-domain routing Inter-domain routing
application transport network link physical

Router Architecture
Overview

Routing Architecture
Input Port Functions

Decentralized switching:
! ! !

Given datagram destination, lookup output port using forwarding table in input port memory (forwarding table copied to input port) Goal: complete input port processing at line speed
Lookup should take less time than time to receive next packet at input port

Queuing: if datagrams arrive faster than forwarding rate into switch fabric

Routing Architecture
Three Types of Switching Fabrics

Output Ports

! !

Buffering required when datagrams arrive from fabric faster than the transmission rate Scheduling discipline chooses among queued datagrams for transmission

The Network Layer: Routing & Addressing


Outline
! ! ! !

Network layer functions Router architecture IP Internet Protocol


Addressing

application transport network link physical

Routing algorithms
Least cost path computation algorithms

! !

Hierarchical routing
Connecting networks of networks

Routing on the Internet


Intra-domain routing Inter-domain routing
application transport network link physical

10

The Internet Network layer


Host and router network layer functions
Transport layer: TCP, UDP
Routing protocols path selection RIP, OSPF, BGP IP protocol addressing conventions IP datagram format packet handling conventions

Network layer

routing table

ICMP protocol error reporting router signaling

Link layer Physical layer

11

The Internet Network layer


IP datagram format
32 bits head. type of ver len service 16-bit identifier flgs time to live upper layer length fragment offset Internet checksum

IP datagrams
The protocol data units at the IP network layer)

(Not to be confused with UDP datagrams)


The protocol data units at the UDP transport layer are also called datagrams

32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP segment or UDP datagram)

12

IP Addressing
Introduction
! !

IP address: 32-bit identier for host or router interface Interface: connection between host or router and a physical link
Routers typically have multiple interfaces Host may have multiple interfaces (typically not) IP addresses are associated with an interface, not the host or router

223.1.1.1 223.1.1.2 223.1.2.1 223.1.1.4 223.1.2.9 223.1.2.2 223.1.1.3 223.1.3.27

223.1.3.1

223.1.3.2

223.1.3.2 = 11011111 00000001 00000011 00000010 223 1 3 2

13

IP Addressing
Host address v. Network addresses
!

IP address:
Network part (high order bits) Host part (low order bits)
223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.1.3 223.1.3.27

Whats a network?
The set of devices that can communicate with each other without an intervening router
"

The devices attached to the same physical network

From an IP address perspective its:


"

223.1.3.1

223.1.3.2

The set of device interfaces with IP addresses having a common network part

Ethernet
14

IP Addressing
Host address v. Network addresses
!

A network (subnet) is the set of hosts reachable without having to traverse a router
Detach each interface from router or host Create islands of isolated networks

223.1.1.1

223.1.1.2 223.1.1.4

223.1.1.3 223.1.9.2 223.1.7.0 point-to-point

Note: single

link is an (IP) network

223.1.9.1 223.1.8.1 223.1.2.6 223.1.2.1 223.1.2.2 223.1.3.1 223.1.8.0

223.1.7.1

223.1.3.27 223.1.3.2

15

IP Addressing
Class-Based (or classful) Addressing
Class A
1.0.0.0 - 127.255.255.255

0 N N N N N N N. H H H H H H H H.H H H H H H H H.H H H H H H H H 7 bits 24 bits


(128 networks) (16,777,216 hosts)

Class B

128.0.0.0 - 191.255.255.255

1 0 N N N N N N.N N N N N N N N .H H H H H H H H.H H H H H H H H 14 bits 16 bits


(16,384 networks) (65,536 hosts)

Class C

192.0.0.0 - 223.255.255.255

1 1 0 N N N N N.N N N N N N N N.N N N N N N N N . H H H H H H H H 21 bits 8 bits


(2,097,152 networks) (256 hosts)
16

Addressing
Class-Based Addressing

Class A B C D

Range 0 - 127 128 - 191 192 - 223 224 - 239


17

Addressing
Private Addresses
!

Network addresses assigned by IANA (Internet Assigned Number Authority) Private addresses available
10.0.0.0 - 10.255.255.255 172.16.0.0 - 172.31.255.255 192.168.0.0 - 192.168.225.255 (see RFC 1597)

18

Addressing
Special IP Addresses

127.0.0.1 is the most popular address for loopback

19

Addressing
Class-Based Addressing

20

Addressing
Classless Addressing (CIDR)
!

Why dont we use class-based addressing anymore? Today, we use subnet addressing, or classless addressing (CIDR) Netmask
32-bit number to identify which bits are network prex in the IP address

21

Addressing
Classless Addressing (CIDR)
!

Router compares destination IP with known network IP D is dest IP addr, M is mask, A is network IP addr A == (D & M) Example: M = 11111111 11111111 00000000 00000000 (255.255.0.0) D = 10000000 00001010 00000010 00000011 (128.10.2.3) A = 10000000 00001010 00000000 00000000 (128.10.0.0) Using binary AND between M and D, we get A.

22

IP Addressing
Classless InterDomain Routing (CIDR)
Network part Host part

11001000 00010111 00010000 00000000 200.23.16.0 / 23


! !

Network portion of address has an arbitrary length Address format: a.b.c.d/x, where x is the number of bits in network portion of address; called the network mask (netmask)
Used only in routing tables, not IP datagram source/destination

23

Addressing
Classless Addressing (CIDR)
!

With CIDR, 128.10.0.0 Class B address becomes 128.10.0.0/16 rst 16 bits are network prex second 16 bits are host sufx

10000000 00001010 00000000 00000000


Network part Host part

128 10 0 0

11001000 00010111 00010000 00000000 200.23.16.0 / 23


24

Addressing
Classless Addressing (CIDR)
!

Example w/class-based addressing


ISP has one class B address (128.211.0.0) Two customers have 12 computers ISP cant assign them (cant break up the class B address space)

Example w/classless addressing


one customer gets 128.211.0.16/28 one customer gets 128.211.0.32/28 ISP keeps rest of the addresses for other customers

25

Addressing
Classless Addressing (CIDR)
!

One customer gets 128.211.0.16/28


28 bits for network prex, 4 bits for host sufx 10000000 128 11010011 211 00000000 0 00010000 16

! !

How do customers assign addresses to hosts? 128.211.0.17 - 128.211.0.30


host part all 0s and host part all 1s are reserved

26

/8 /9 /10 /11 /12 /13 /14 /15 /16 /17 /18 /19 /20 /21 /22 /23 /24 /25 /26 /27 /28 /29 /30

255.0.0.0 255.128.0.0 255.192.0.0 255.224.0.0 255.240.0.0 255.248.0.0 255.252.0.0 255.254.0.0 255.255.0.0 255.255.128.0 255.255.192.0 255.255.224.0 255.255.240.0 255.255.248.0 255.255.252.0 255.255.254.0 255.255.255.0 255.255.255.128 255.255.255.192 255.255.255.224 255.255.255.240 255.255.255.248 255.255.255.252

16777216 8388608 4194304 2097152 1048576 524288 262144 131072 65536 32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4

Class A

Class B ISP / large business ISP / large business ISP / large business Small ISP / large business Small ISP / large business Class C Large LAN Small LAN Small LAN Small LAN

27

Problems
!

152.2.136.0/26
How many assignable IP addresses? What is the range of assignable IP addresses? What is the proper netmask?

130.127.128.0/20
How many assignable IP addresses? What is the range of assignable IP addresses? What is the proper netmask?

range: 130.127.64.129 - 130.127.64.134 and netmask: 255.255.255.248


What is the CIDR address?
28

IP addresses
How are IP addresses assigned?
!
223.1.1.1 223.1.1.4

The network address is assigned by the ISP


Hosts portion only; all hosts share the same network portion

223.1.1.2

Host address
Static assignment:
"

DCHP Server

223.1.1.3

Conguration parameter (manually) set during system installation DHCP: Dynamic Host Conguration Protocol ! Host broadcasts a DHCP discover message ! DHCP server responds with a DHCP offer message ! Host requests IP address: DHCP request message ! DHCP server sends address: DHCP ack message
29

Dynamic assignment at boot/wake-up time


"

Datagram Routing and Transmission


IP datagram encapsulation (Ethernet)
8 bytes 6 bytes
2 6 bytes bytes

46 to 1500 bytes

4 bytes
CRC CRC

Preamble

Destination Source Address Address Type


IP header

Data

data

IP Datagram
user data

Link layer addresses (not same as IP addresses)

TCP header

TCP Segment

Sending interface adapter encapsulates IP datagram (or other network layer protocol packet) in an Ethernet frame
30

Datagram Routing and Transmission


IP datagram format
32 bits head. type of ver len service 16-bit identifier flgs time to protocol type live

IP protocol version Header length (bytes) Network layer service requested Maximum number of remaining hops (decremented at each router) Transport layer protocol to receive payload (UDP, TCP)

length fragment offset Internet checksum

Total IP datagram length (bytes)

32 bit source IP address 32 bit destination IP address


Options (if any)

For fragmentation/ reassembly

Data (variable length, typically a TCP segment or UDP datagram)

E.g.: Timestamp, record route taken, specify routing path, etc.

31

IP Datagrams
Fragmentation & Reassembly
!

Network links have a maximum frame size


Called the maximum transmission unit (MTU) Different link types, different MTUs

...

Large IP datagrams must be fragmented to link MTU sizes


One IP datagram becomes several IP datagrams as it transits networks Fragments reassembled only at the nal destination

Fragmentation

All fragments carry the same IP identication number


All fragments (except the last) have the fragment bit set
Reassembly
32

IP Fragmentation and Reassembly


Ethernet MTU example
length ID fragment offset = 4000 = x =0 =0

IP datagram (20 byte IP header + 3,980 byte TCP segment) encapsulated in one FDDI frame

One large IP datagram becomes several smaller IP datagrams


length ID fragment offset =1500 =x =1 =0 length ID fragment offset =1500 =x =1 =1480 length ID fragment offset =1040 =x =0 =2960
! !

Each IP datagram encapsulated in one Ethernet frame

Consider a 3,980 byte message sent in an FDDI frame (MTU 4000B) The message generates 3 fragments when it transits an Ethernet (MTU 1500 B)
How much application data is in each fragment?
33

Problem
! ! ! !

Original MTU of 4000 B Sending IP datagram of 2000 B (including IP header) Transits over network with MTU of 576 B How is datagram fragmented?

34

Routing IP Datagrams
Example
Routing table in A
misc source dest fields IP addr IP addr IP Datagram data

Dest. Net. next router Nhops 223.1.1/24 *(default) 223.1.1.4 1 2

All routing is based on the IP destination address eld in the IP header IP destination address (and data elds) never change!
Delivery to intermediate hops involves link-layer addresses

A 223.1.1.1
223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9

B
223.1.1.3 223.1.3.1 223.1.3.27

223.1.2.2

223.1.3.2

35

Routing IP Datagrams
Routing to a local destination
misc 223.1.1.1 223.1.1.3 elds

Routing table in A
data

Dest. Net. next router Nhops 223.1.1/24 *(default) 223.1.1.4 1 2

An application on A generates an IP datagram addressed to B


The IP layer on A looks up the network address of B... And determines that B is on same network as A (223.1.1)

A 223.1.1.1
223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9

As link layer sends the IP datagram directly to B inside link-layer frame


B and A are assumed to be connected to the same physical network

B
223.1.1.3 223.1.3.1 223.1.3.27

223.1.2.2

223.1.3.2

36

Routing IP Datagrams
Routing to a remote destination
misc 223.1.1.1 223.1.2.2 elds data

Routing table in A
Dest. Net. next router Nhops 223.1.1/24 *(default) 223.1.1.4 1 2

Host A generates an IP datagram addressed to E


The IP layer on A looks up up network address of E (223.1.2) A determines that E is NOT on same network as A As routing table shows router 223.1.1.4 as the default for all networks

A 223.1.1.1
223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9

B
223.1.1.3 223.1.3.1 223.1.3.27

223.1.2.2

As link layer sends IP datagram to router inside link-layer frame

223.1.3.2

37

Routing IP Datagrams
Routing to a remote destination
misc 223.1.1.1 223.1.2.2 elds

Routing table in router


data

Dest. next network router Nhops interface 223.1.1/24 223.1.2/24 223.1.3/24 A 223.1.1.1
223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9

! As

datagram addressed to E arrives at the router


The router looks up network address of E (223.1.2) E has the same network address as routers interface 223.1.2.9 Router is directly attached to the same network (223.1.2) as E

1 1 1

223.1.1.4 223.1.2.9 223.1.3.27

B
223.1.1.3 223.1.3.1 223.1.3.27

223.1.2.2

! Routers

link layer sends the datagram to 223.1.2.2 inside a link-layer frame via interface 223.1.2.9
Datagram arrives at 223.1.2.2

223.1.3.2

38

The Internet Network Layer


The Internet control message protocol ICMP
!

Used by hosts, routers, gateways to communicate network-level information


Error reporting: e.g., unreachable {host, network, port, protocol} Echo request/reply (used by ping)

Provides network-layer functions logically above IP


ICMP is encapsulated in IP datagrams

Type 0 3 3 3 3 3 3 4 8 9 10 11 12

Code 0 0 1 2 3 6 7 0 0 0 0 0 0

description echo reply (ping) network unreachable host unreachable protocol unreachable port unreachable network unknown host unknown source quench (congestion control - not used) echo request (ping) route advertisement router discovery TTL expired bad IP header

ICMP is assigned a protocol number in the IP header just like TCP and UDP
!

ICMP message: type + code + rst 8 bytes of IP datagram triggering the ICMP message

39

The Internet Network Layer


NAT: Network Address Translation
rest of Internet local network (e.g., home network) 10.0.0/24
10.0.0.4 10.0.0.2 138.76.29.7 10.0.0.3

10.0.0.1

All datagrams leaving local network have same single source NAT IP address: 138.76.29.7, different source port numbers

Datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual)

40

The Internet Network Layer


NAT: Network Address Translation
2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table 2 NAT translation table WAN side addr LAN side addr 138.76.29.7, 5001 10.0.0.1, 3345 1: host 10.0.0.1 sends datagram to 128.119.40, 80

S: 10.0.0.1, 3345 D: 128.119.40.186, 80

S: 138.76.29.7, 5001 D: 128.119.40.186, 80

1
10.0.0.4
S: 128.119.40.186, 80 D: 10.0.0.1, 3345

10.0.0.1 10.0.0.2

138.76.29.7
S: 128.119.40.186, 80 D: 138.76.29.7, 5001

4
10.0.0.3

3: Reply arrives dest. address: 138.76.29.7, 5001

4: NAT router changes datagram dest addr from 138.76.29.7, 5001 to 10.0.0.1, 3345

41

Problems
192.168.2.1 192.168.2.254 192.168.2.2

The Internet
152.13.76.3 138.76.29.7

192.168.2.3

1) You are using 192.168.2.3 and want to access a web server running on 152.13.76.3.
a) b) What data is lled into the NAT table during connection setup? What information is changed in the SYN and SYN/ACK packets leaving and entering your network?

2) Youve setup a web server on 192.168.2.2 and want your friend at 152.13.76.3 to be able to access it.
a) b) What should you put in the NAT table at your router? What address and port should you tell your friend to contact in order to reach your web server?
42