Download Lecture (Network)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Deep packet inspection wikipedia , lookup

AppleTalk wikipedia , lookup

IEEE 1355 wikipedia , lookup

Zigbee wikipedia , lookup

Asynchronous Transfer Mode wikipedia , lookup

Distributed firewall wikipedia , lookup

Dynamic Host Configuration Protocol wikipedia , lookup

CAN bus wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Computer network wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Internet protocol suite wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

Network tap wikipedia , lookup

Airborne Networking wikipedia , lookup

UniPro protocol stack wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Transcript
Chapter 4
Network Layer
All material copyright 1996-2009
J.F Kurose and K.W. Ross, All Rights Reserved
Network Layer
4-1
Network layer
❒  transport segment from
❒ 
❒ 
❒ 
❒ 
sending to receiving host
on sending side
encapsulates segments
into _______________
on rcving side, delivers
segments to _________
network layer protocols
in every _______, ____
router examines header
fields in all IP datagrams
passing through it
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
Network Layer
application
transport
network
data link
physical
4-2
Forwarding table
# possible entries?
Destination Address Range
Link Interface
11001000 00010111 00010000 00000000
through
11001000 00010111 00010111 11111111
0
11001000 00010111 00011000 00000000
through
11001000 00010111 00011000 11111111 1
11001000 00010111 00011001 00000000
through
11001000 00010111 00011111 11111111 2
otherwise
3
Network Layer
4-3
Longest prefix matching
Prefix Match
11001000 00010111 00010
11001000 00010111 00011000
11001000 00010111 00011
otherwise
Link Interface
0
1
2
3
Examples
DA: 11001000 00010111 00010110 10100001
Which interface?
DA: 11001000 00010111 00011000 10101010
Which interface?
Network Layer
4-4
IP datagram format
32 bits
ver head. type of
len service
how much overhead
with TCP?
❒  20 bytes of TCP
❒  ____ bytes of IP
❒  = ___ bytes + app
layer overhead
length
fragment
16-bit identifier flgs
offset
time to upper
header
layer
live
checksum
32 bit source IP address
32 bit destination IP address
Options (if any)
data
(variable length,
typically a TCP
or UDP segment)
Network Layer
4-5
IP Addressing: introduction
❒  IP address: ____-bit
identifier for host,
router interface
❒  interface: connection
between host/router
and physical link
❍ 
❍ 
❍ 
routers typically have
multiple interfaces
host typically has one
interface
IP addresses
associated with each
interface
223.1.1.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.1
223.1.2.9
223.1.3.27
223.1.2.2
223.1.3.2
223.1.3.1
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
Network Layer
1
4-6
Subnets
❒  IP address:
❍  subnet part (high
order bits)
❍  host part (low order
bits)
❒ 
What’s a subnet ?
❍ 
❍ 
device interfaces with
same subnet part of IP
address
can physically reach
each other without
intervening router
223.1.1.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.1
223.1.2.9
223.1.3.27
223.1.2.2
subnet
223.1.3.1
223.1.3.2
network consisting of 3 subnets
Network Layer
4-7
Subnets
Recipe
❒  To determine the
subnets, detach each
interface from its
host or router,
creating islands of
isolated networks.
Each isolated network
is called a subnet.
223.1.1.0/24
223.1.2.0/24
223.1.3.0/24
Subnet mask: /24
Network Layer
4-8
Subnets
223.1.1.2
How many?
223.1.1.1
223.1.1.4
223.1.1.3
223.1.9.2
223.1.7.0
223.1.9.1
223.1.7.1
223.1.8.1
223.1.8.0
223.1.2.6
223.1.2.1
223.1.3.27
223.1.2.2
223.1.3.1
223.1.3.2
Network Layer
4-9
IP addressing: CIDR
CIDR: Classless InterDomain Routing
❍  subnet
portion of address of arbitrary length
❍  address format: a.b.c.d/x, where x is # bits in
subnet portion of address
11001000 00010111 00010000 00000000
200.23.16.0/23
Network Layer 4-10
DHCP: Dynamic Host Configuration Protocol
Goal: allow host to dynamically obtain its IP address from
network server when it joins network
Can renew its lease on address in use
Allows reuse of addresses (only hold address while connected an
“on”)
Support for mobile users who want to join network (more shortly)
DHCP overview:
❍  host broadcasts “_________” msg [optional]
❍  DHCP server responds with “__________” msg
[optional]
❍  host requests IP address: “___________” msg
❍  DHCP server sends address: “___________” msg
Network Layer
4-11
DHCP client-server scenario
A
B
223.1.2.1
223.1.1.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.3.1
223.1.2.9
223.1.3.27
223.1.2.2
E
223.1.3.2
Network Layer 4-12
DHCP client-server scenario
DHCP server: 223.1.2.5
DHCP
UDP
IP
Eth
Phy
DHCP discover
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
arriving
client
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
time
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
Network Layer 4-13
NAT: Network Address Translation
10.0.0.1
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
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)
Network Layer 4-14
NAT: Network Address Translation
❒  Motivation: local network uses just one IP address as
far as outside world is concerned:
❍  ________________________________
❍  ________________________________
❍  ________________________________
❍  ________________________________
Network Layer 4-15
NAT: Network Address Translation
Implementation: NAT router must:
❍  outgoing
datagrams: replace (source IP address, port
#) of every outgoing datagram to (NAT IP address,
new port #)
. . . remote clients/servers will respond using (NAT
IP address, new port #) as destination addr.
❍  remember
(in NAT translation table) every (source
IP address, port #) to (NAT IP address, new port
#) translation pair
❍  incoming
datagrams: replace (NAT IP address, new
port #) in dest fields of every incoming datagram
with corresponding (source IP address, port #)
stored in NAT table
Network Layer 4-16
NAT: Network Address Translation
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
2
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
138.76.29.7
S: 128.119.40.186, 80
D: 138.76.29.7, 5001
3
1
10.0.0.4
S: __________, __
D: _________, ____
10.0.0.1
10.0.0.2
4
10.0.0.3
Network Layer 4-17
NAT: Network Address Translation
❒  _______ port-number field:
❍  60,000
simultaneous connections with a single
LAN-side address!
❒  NAT is controversial:
❍  routers should only process up to layer 3
❍  violates end-to-end argument
•  NAT possibility must be taken into account by app
designers, eg, P2P applications
❍  address
IPv6
shortage should instead be solved by
Network Layer 4-18
NAT traversal problem
❒  client wants to connect to
server with address 10.0.0.1
❍ 
❍ 
server address 10.0.0.1 local
Client
to LAN (client can’t use it as
destination addr)
only one externally visible
NATted address: 138.76.29.7
❒  solution 1: statically
configure NAT to forward
incoming connection
requests at given port to
server
❍ 
10.0.0.1
?
138.76.29.7
10.0.0.4
NAT
router
e.g., (123.76.29.7, port 2500)
always forwarded to 10.0.0.1
port 25000
Network Layer 4-19
NAT traversal problem
❒  solution 2: Universal Plug and
Play (UPnP) Internet Gateway
Device (IGD) Protocol. Allows
NATted host to:
!  learn public IP address
(138.76.29.7)
!  add/remove port mappings
(with lease times)
10.0.0.1
IGD
10.0.0.4
138.76.29.7
NAT
router
i.e., automate static NAT port
map configuration
Network Layer 4-20
NAT traversal problem
❒  solution 3: relaying (used in Skype)
❍  NATed
client establishes connection to relay
❍  External client connects to relay
❍  relay bridges packets between to connections
10.0.0.1
Client
138.76.29.7
NAT
router
Network Layer 4-21
Distance Vector Algorithm
Bellman-Ford Equation (dynamic programming)
Define
dx(y) := cost of least-cost path from x to y
Then
dx(y) = __________________
Network Layer 4-22
Bellman-Ford example
5
2
u
v
2
1
x
3
w
3
1
5
z
1
y
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
2
B-F equation says:
du(z) =
Node that achieves minimum is next
hop in shortest path ➜ forwarding table
Network Layer 4-23
Distance Vector Algorithm
❒  Dx(y) = estimate of least cost from x to y
❒  Node x knows cost to each neighbor v: c(x,v)
❒  Node x maintains distance vector Dx = [Dx(y): y є N ]
❒  Node x also maintains its neighbors’ distance vectors
❍  For each neighbor v, x maintains
Dv = [Dv(y): y є N ]
Network Layer 4-24
Distance vector algorithm (4)
Basic idea:
❒  From time-to-time, each node sends its own
distance vector estimate to neighbors
❒  Asynchronous
❒  When a node x receives new DV estimate from
neighbor, it updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)}
for each node y ∊ N
❒  Under minor, natural conditions, the estimate
Dx(y) converge to the actual least cost dx(y)
Network Layer 4-25
Distance Vector Algorithm (5)
Iterative, asynchronous:
each local iteration caused by:
❒  local link cost change
❒  DV update message from
neighbor
Each node:
wait for (change in local link
cost or msg from neighbor)
Distributed:
❒  each node notifies neighbors
only when its DV changes
❍ 
neighbors then notify their
neighbors if necessary
recompute estimates
if DV to any dest has
changed, notify neighbors
Network Layer 4-26
node x table
cost to
x y z
from
from
x 0 2 7
y ∞∞ ∞
z ∞∞ ∞
node y table
cost to
x y z
cost to
x y z
x
y
z
x ∞∞∞
y 2 0 1
z ∞∞ ∞
node z table
cost to
x y z
from
from
x
x ∞ ∞
∞ ∞
y ∞∞
z 71 0
time
2
y
7
1
z
Network Layer 4-27
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2
node x table
cost to
x y z
x ∞ ∞
∞ ∞
y ∞∞
z 71 0
from
from
from
from
x 0 2 7
y 2 0 1
z 7 1 0
cost to
x y z
x 0 2 7
y 2 0 1
z 3 1 0
x 0 2 3
y 2 0 1
z 3 1 0
cost to
x y z
x 0 2 3
y 2 0 1
z 3 1 0
x
2
y
7
1
z
cost to
x y z
from
from
from
x ∞∞∞
y 2 0 1
z ∞∞ ∞
node z table
cost to
x y z
x 0 2 3
y 2 0 1
z 7 1 0
cost to
x y z
cost to
x y z
from
from
x 0 2 7
y ∞∞ ∞
z ∞∞ ∞
node y table
cost to
x y z
cost to
x y z
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
x 0 2 3
y 2 0 1
z 3 1 0
time
Network Layer 4-28
Intra-AS Routing
❒  also known as Interior Gateway Protocols (IGP)
❒  most common Intra-AS (autonomous systems)
routing protocols:
❍  RIP:
Routing Information Protocol
❍  OSPF:
Open Shortest Path First
❍  IGRP:
Interior Gateway Routing Protocol (Cisco
proprietary)
Network Layer 4-29
RIP ( Routing Information Protocol)
❒  distance vector algorithm
❒  included in BSD-UNIX Distribution in 1982
❒  distance metric: # of hops (max = 15 hops)
From router A to subnets:
u
v
A
z
C
B
D
w
x
y
destination hops
u
1
v
2
w
2
x
3
y
3
z
2
Network Layer 4-30
RIP advertisements
❒  distance
vectors: exchanged among
neighbors every 30 sec via Response
Message (also called advertisement)
❒  each advertisement: list of up to 25
destination subnets within AS
Network Layer 4-31
RIP: Example
z
w
A
x
D
B
y
C
Destination Network
w
y
z
x
….
Next Router
Num. of hops to dest.
….
....
A
B
B
--
2
2
7
1
Routing/Forwarding table in D
Network Layer 4-32
RIP: Example
Dest
w
x
z
….
Next
C
…
w
hops
1
1
4
...
A
Advertisement
from A to D
z
x
Destination Network
w
y
z
x
….
D
B
C
Next Router
A
B
y
Num. of hops to dest.
-….
Routing/Forwarding table in D
2
2
1
....
Network Layer 4-33
RIP: Link Failure and Recovery
If no advertisement heard after 180 sec --> neighbor/
link declared dead
❍  routes via neighbor invalidated
❍  new advertisements sent to neighbors
❍  neighbors in turn send out new advertisements (if
tables changed)
❍  link failure info quickly (?) propagates to entire net
❍  poison reverse used to prevent ping-pong loops
(infinite distance = 16 hops)
Network Layer 4-34