Download Computer network- Chapter 3: Data link layer

Document related concepts

Peering wikipedia , lookup

Distributed firewall wikipedia , lookup

Net bias wikipedia , lookup

AppleTalk wikipedia , lookup

Deep packet inspection wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

Network tap wikipedia , lookup

Multiprotocol Label Switching wikipedia , lookup

Asynchronous Transfer Mode wikipedia , lookup

Internet protocol suite wikipedia , lookup

Computer network wikipedia , lookup

IEEE 1355 wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Airborne Networking wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Packet switching wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Routing wikipedia , lookup

Routing in delay-tolerant networking wikipedia , lookup

Transcript
Olum-fonoon Babol
Computer networks course
Chapter 5
The Network Layer
Fall 2005
By: H. Veisi
Overview
 Functions:
application
transport
network
data link
physical
 Routing issues
 determine “good” path
(sequence of routers) thru
network from source to dest.
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
 Congestion (Not Contention!)
network
data link
physical
 More packets enter an
area than can be processed
network
data link
physical
network
data link
physical
network
data link
physical
 Internetworking
application
transport
network
data link
physical
 connecting different
network technologies together
 Network layer protocols in every host, router
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 2
Network Layer Design Issues
 Services Provided to the Transport Layer
 The network layer should shield the transport layer from having to
know details of the underlying subnet
 Network Layer Services Can:
 Connection-Oriented: Provides Virtual Circuit (VC) subnet,
 source-to-destination path behaves much like telephone
circuit, Avoids choosing a new route for each packet.
 A virtual circuit remembers how to send a packet from source
to destination.
 Connection-less: Provides Datagram subnet,
 Each packet sent is routed independently of its predecessors
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 3
Connectionless: Datagram (1)
 No call setup at network layer
 Packets forwarded using destination host address
 packets between same source-dest. pair may take different paths
 Use in Internet
application
2. Receive Data transport
network
data link
physical
application
transport
network
data link
physical
1. Send Data
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 4
Connectionless: Datagram (2)
 Routing within a diagram subnet:
Store-and-Forward packet
Subnet
Routing tables
The table of router A is
changed because of some
reasons!
Management and update
this tables for routing =
Routing algorithm
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 5
Virtual Circuits (1)
 Call setup, do for each call before data can flow
 Each packet carries VC identifier
 Used in ATM, frame-relay, X.25
6. Receive data application
3. Accept call
transport
2. Incoming call network
data link
physical
5. Data flow begins
4. Call connected
application 1. Initiate call
transport
network
data link
physical
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 6
Virtual Circuits (2)
 Routing within a virtual-circuit subnet:
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 7
ATM (1)
 ATM (Asynchronous Transfer Mode)
 Is underlying mechanism. Transmits in small fixedsize cells.
 A connection-oriented network
 Use virtual circuits and small, fixed-size packets
(Cells)
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 8
ATM (2)
 Packet (cell) switching is dramatic change for phone
companies.
ATM is connection oriented; make connecting
request first; then all cells follow the same path.
Target is 155 Mbps and 622 Mbps. Allows TV
transmission.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 9
ATM (3)
 ATM Reference Model:
 3 layers:
1- Physical layer :
 Physical medium (voltage, bit timing, ….)
2- ATM layer :
 deal with cells and transports it + establish/release
virtual circuits + congestion control
3- ATM adaptive layer :
 Segment large cells and resemble after transmission
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 10
ATM (4)
 ATM Reference Model:
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 11
ATM (5)
 Comparisons to other models:
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 12
Comparison of Virtual-Circuit and Datagram
Internet
Computer networking, Olum-Fonoon Babol
ATM
H. Veisi
Fall 2005
Page 13
Quality of Service: QoS (1)
 Factors:
 Timing
 Connection Establishment Delay
 End-To-End Delay
 Connection Establishment Failure Probability
 Throughput or Bandwidth Guarantee
 Ordering Preservation
 Congestion Control
 Bit-Error rate or Packet-Loss Rate Control
 Protection
 Priority
…
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 14
Quality of Service: QoS (2)
 Requirements:
 Reliability, Delay, Jitter, Bandwidth
 How stringent the quality-of-service requirements are:
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 15
Routing (1)
 The network layer is responsible for routing packets from the source to
destination.
 The routing algorithm is the piece of software that decides where a packet
goes next (e.g., which output line, or which node on a broadcast channel).
 For connectionless networks, the routing decision is made for each
datagram. For connection-oriented networks, the decision is made once, at
circuit setup time.
 The routing algorithm must deal with the following issues:
 Correctness, simplicity, stability, fairness and optimality
 Mimizing mean packet delay or maximizing total network throughput
 Routing is different from Forwarding!:
 Forwarding: Select the output path using routing table
 Routing: Management and updating the routing tables
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 16
Routing (2)
 There are two types:
 Static (Non-Adaptive)
 routes never update or update slowly over time
 Examples: Dijkstra, Flooding algorithm
 Dynamic (Adaptive)
 routes update more quickly use dynamic information of
current topology such as load, delay, …
 Examples: Distance Vector, Link State Routing
 From another view:
 Global: all routers have complete topology, link cost info
 Decentralized: router knows physically-connected neighbors
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 17
Non-Adaptive Algorithm
Dijkstra Algorithm (1)
 Net topology, link costs known to all nodes
Global algorithm
 Cost of a link is a function of :
 Number of Hops, Distance, Average traffic, Delay, …
 Computes least cost paths (Minimum path) from one
node (‘source”) to all other nodes
 gives routing table for that node
 Iterative: after k iterations, know least cost path to k
dest.’s
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 18
Dijkstra Algorithm (2)
 Notation:
 N: set of nodes whose least
cost path definitively known
 c(i,j): link cost from node i
to j. cost infinite if not
direct neighbors
5
5
2
A
23
1
D
3
1
C
5
1
E
F
2
Example: N: A, B, C, D, E, F
 p(v): nodes along path from
source to v
C(A,C)=5; C(C,A)=5
C(B,D)=2; C(D,B)=3
…
 D(v): current value of cost of
path from source to dest. V
Computer networking, Olum-Fonoon Babol
B
3
Source=A
p(F): A-D-E-F
D(F)=4
H. Veisi
Fall 2005
Page 19
Dijkstra Algorithm (3)
v
1 Initialization:
2 N = {A}
3 For all nodes v
4 If v adjacent to A then
5
D(v) = c(A,v)
6
Else D(v) = infinity
c(w,v)
D(v)
w
A
D(w)
8 Loop
9 Find w not in N such that D(w) is a minimum
10 Add w to N
11 Update D(v) for all v adjacent to w and not in N:
12
D(v) = min( D(v), D(w) + c(w,v) )
/* new cost to v is either old cost to v or known shortest path
cost to w plus cost from w to v */
13 until all nodes in N
C version of this algorithm is available in book
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 20
Dijkstra Algorithm (4)
 Example: computes least cost paths from node A to all other nodes
Step
0
1
2
3
4
5
start N
A
AD
ADE
ADEB
ADEBC
ADEBCF
D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E) D(F),p(F)
infinity
5,A-C
2,A-B
infinity
1,A-D
infinity
2,A-B 4,A-D-C
1,A-D 2,A-D-E
2,A-D-E 4,A-D-E-F
1,A-D
2,A-B 3,A-D-E-C
2,A-D-E 4,A-D-E-F
1,A-D
2,A-B 3,A-D-E-C
2,A-D-E 4,A-D-E-F
2,A-B 3,A-D-E-C
1,A-D
2,A-B
5
D(v): Distance (cost) of A to v.
P(v): nodes along path fromA to v.
2
A
3
B
3
2
1
Computer networking, Olum-Fonoon Babol
2,A-D-E
1,A-D
3,A-D-E-C
D
1
C
5
1
E
H. Veisi
4,A-D-E-F
F
2
Fall 2005
Page 21
Dijkstra Algorithm (5)
 Discussion:
 Algorithm complexity:
 Suppose there are n nodes, except source



First iteration: Search through all n nodes to determine the node,
w, not in N that has the minimum cost.
Second iteration: Check n-1 nodes to determine minimum cost.
Third iteration: n-2 nodes, and so on.
 Total number of nodes searched: n(n+1)/2
 The implementation of the algorithm has worst-case
complexity of order n squared: O(n2).
 A more sophisticated implementation of this algorithm, using a
data structure known as a heap, can reducing the complexity
to O( nlog(n) )
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 22
Non-Adaptive Algorithm
Flooding algorithm (1)
 Flooding does not select a specific route. When a router receives a packet,
it sends a copy of the packet out on each line (except the one on which it
arrived)
 To reduce looping even further:
 Using Hop Counter:
 Each router decrements a hop count contained in the packet
header. Whenever the hop count decrements to zero, the router
discards the packet.
 Keep track of which packet have been flood
 Add a sequence number to each packet's header.
 Each router maintains a private sequence number. When it sends
a new packet, it copies the sequence number into the packet, and
increments its private sequence number.
 Keeps track of the highest sequence number seen from S.
 Whenever it receives a packet from S containing a
sequence number lower than the one stored in its table, it
discards the packet. Otherwise, it updates the entry for S
and forwards the packet on
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 23
Flooding algorithm (2)

Another variation of flooding is Selective Flooding:
 Don’t send incoming packets to ALL output lines
 Just forward on that lines which are going approximately in
right direction

Uses:
 In military applications, the network must remain robust in
the face of (extreme) hostility
 Sending routing updates, because updates can't rely on the
correctness of a router's routing table.
 Theoretical-chooses all possible paths, so it chooses the
shortest one
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 24
Adaptive Algorithm
Distance Vector Routing (1)
 Each router
 maintains a table (vector) giving the best known distance to a
destination and the line to use for sending there.
 Tables are updated by exchanging information with neighbors.
 Each router knows the distance (cost) of reaching its neighbors
(e.g. send echo requests).
 Routers periodically exchange routing tables with each of
their neighbors.
 This algorithm was used in the original ARPANET
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 25
Distance Vector Routing (2)
1
B
C
2
8
A
1
D
E
source 2
E’s neighbor
B’s neighbor
destination: i
7
neighbor: j
A
A
B
C
D
A
B
D
1
7
6
4
14
8
9
11
5
5
4
2
E
Distance table:
B
D (A,C)
node E, for dest. A via neighbor B: DE(A,B)
E
C
E
B
c(E,B)
D(i, j)
A
…
Computer networking, Olum-Fonoon Babol
D (A,B)=
= c(E,B) + min {D B(A,w)}
w
= 8 + 6 = 14
H. Veisi
Fall 2005
Page 26
Distance Vector Routing (3)
Distance table for J
DJ (G,?)=
c(J,H)+minw{DH(G,w)}=
6+12=18
(a) A subnet.
(b) Input from A, I, H, K, and the new routing table for J.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 27
Distance Vector Routing (4)
Problem:
 Convergence is slow!
 Good news travels quickly, bad news travels slowly (count-toinfinity) problem
 Example: Propagation of good news
 Initially A is down and all other routers know this
There is no path to A
Table for dest.=A
In a subnet with longest subnet path=N, after N exchanges everyone will know
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 28
Distance Vector Routing (5)
 Example: Propagation of good news
 The count-to-infinity problem
 A goes down after initially
After this A goes down
B thinks that there is a path to A thru C
but C itself go to A via B!
Counting will continuous to infinity
 If the metric is “Number of Hop”, Infinite can define as longest path+1
 If the metric is “delay”, there is no well-defined upper bound
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 29
Adaptive Algorithm
Link State Routing (1)
 The DVR Arpanet routing algorithm was replaced in 1979.
 Problems with old algorithm included:
 Network was too slow in adapting to congestion, too fast to
react to minor changes.
 Average queue length was used to estimate delay
 This works only if all lines have the same capacity and
propagation delay.
 Doesn't take into account that packets have varying
sizes.
 Didn’t take line bandwidth into account when choosing routes
 Because all the line have same capacity, 56 Kbps
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 30
Link State Routing (2)

Each router must do the following:
 Discover its neighbors, learn their network address.

Sends ‘hello' message on booting.
 Measure the delay or cost to each of its neighbors.

Delay= (Send ‘Echo’ message + Receive its reply)/2
 Construct a packet telling all it has just learned.

Construct Link State (LS) packet, it contains:

Source Add., Seq. No., Age No., List of neighbors + their delay
 Send this packet to all other routers.

Forwards link state packets to all other routers using Flooding algorithm.
 Compute the shortest path to every other router.

Each router uses an Dijkstra algorithm to calculate shortest paths
based on the current values in its database.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 31
Link State Routing (3)
The link state packets for this subnet.
The packet buffer for
router B, Used in step 
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 32
Hierarchical Routing (1)

As a network becomes larger, the amount of information that
must be propagated increases, and the routing calculation
becomes increasingly expensive. (Increase the memory amount
and calculation)
 Hierarchical routing:
 Divide the network into regions, with a router only knowing the
details of how to route to other routers in its region.
 Hides information from far-away nodes, reducing the amount of
information a given router needs to perform routing
 Router don’t know about the internal topology of other
regions.
 Gateway is a router that knows about other regions
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 33
Hierarchical Routing (2)
C.b
B.a
A.a
a
b
C
A.c
d
A
Host1
a
a
b
c
Host2
c
B
b
Intra-AS routing
within AS B
Intra-AS routing
within AS A
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 34
Hierarchical Routing (3)
 Advantage:
 Scaling. Each router needs less information
 In Ex. Distance table reduce from 17 entries to 7
 Disadvantage:
 Sub optimal routes. The average path length increases
Optimal path for 1A to 5C
is thru region 2 while
in hierarchical is thru
region 3
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 35
The Network Layer in the Internet (1)
 TCP/IP use the Internet Protocol (IP) in network layer.
 Provides connectionless, datagram service: unreliable
 The IPv4 header:
 Using Big Endian: store/transmit the most significant byte of a bit
stream in the lowest memory address/first (e.g. to the left).
 Machines such as IBM and Sun-3 computers use this mechanism
 Intel use Little Endian
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 36
The Network Layer in the Internet (2)
 Version number (4-bits):
 Including a version number allows a future version of IP be used along
side the current version, facilitating migration to new protocols.
 Header length (4-bits):
 Length of the datagram header (excluding data) in 32-bit words.
 The minimum length is 5 words = 20 bytes, but can be up to 15 words
if options are used.
 Max. length of Option data=40 bytes  Max for IHL=15
 Type-of-service (8-bits):
 A hint to the routing algorithms as to what type of service we desire.
 Precedence (3-bits): A priority indication, where 0 is the lowest
and means normal service, while 7 is highest
 Delay, Throughput, Reliability bits
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 37
The Network Layer in the Internet (3)
 Total length (16-bits):
 Total length of the IP datagram (in bytes).
 Max. length of a packet is 216=65K bytes
 Identification (16-bits), DF (Don’t fragment), MF (More
fragment), Fragment offset (13-bits):
 These three fields are used for fragmentation and reassembly.
 Gateways along a path are free to fragment datagrams as
needed; hosts are required to reassemble fragments before
passing complete datagrams to the higher layer protocols.
 Each fragment contains a complete copy of the original datagram
header plus some portion of the data.
 All fragments of a datagram will have the same source and
destination IP address.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 38
The Network Layer in the Internet (4)




Identification: determine the IP Datagram
DF: Don’t fragment this datagram
MF:1 means that the fragmentation is continued, 0 Just for last packet
Fragmented Offset: Determine the position of current packet in datagram,
 13 bits Max. No. of packets in each datagram=8192
 Time-to-live: TTL (8-bits):
 It guarantees that packets don't stay in the network for longer than 255
seconds, a property needed by higher layer protocols that reuse sequence
numbers.
 A counter that is decremented by each gateway. Should this hopcount
reach 0, discard the datagram.
 Protocol (8-bits):
 What type of data the IP datagram carries (e.g., TCP, UDP, etc.).
 Needed by the receiving IP to know the higher level service that will next
handle the data.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 39
The Network Layer in the Internet (5)
 Header Checksum (16-bits):
 A checksum of the IP header (excluding data) use checksum method
for error detection
 The header must be recalculated at every router since the TTL field
is decremented.
 Source address (32-bits):
 Original sender's address. This is an IP address, not a MAC address.
 Destination address (32-bits):
 Datagram's ultimate destination.
 IP Options:
 IP datagrams allow the inclusion of optional, varying length fields
that need not appear in every datagram.
 Some defined options: Security, Strict source routing, Loose source
routing, Record route, Timestamp
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 40
IP Fragmentation and Reassembly (1)
 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
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 41
IP Fragmentation and Reassembly (2)
20 Byte
 Example
length ID fragflag offset
=4000 =x
=0
=0
data
0……….3979
4000 Bytes
 4000 byte datagram
 MTU = 1500 bytes
length ID fragflag offset
=1500 =x
=1
=0
One large datagram becomes
3 smaller datagrams.
0……….1479
1480…2959
length ID fragflag offset
=1500 =x
=1
=1480
length ID fragflag offset
=1040 =x
=0
=2960
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 42
IP Addresses (1)
 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
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.2.9
223.1.1.3 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
Computer networking, Olum-Fonoon Babol
H. Veisi
1
1
Fall 2005
1
Page 43
IP Addresses (2)
 IP address:
223.1.1.1
 network part (high order
bits)
 host part (low order bits)
223.1.2.1
223.1.1.2
223.1.1.4
 What’s a network ? (from IP
address perspective)
 device interfaces with
same network part of IP
address
 can physically reach each
other without intervening
router
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
LAN
223.1.3.1
223.1.3.2
network consisting of 3 IP networks
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 44
IP Addresses (3)
223.1.1.2
ICANN: Internet Corporation for
Assigned Names and
Numbers allocates
223.1.1.1
223.1.1.4
223.1.1.3
addresses
223.1.7.0
223.1.9.2
223.1.9.1
223.1.7.1
223.1.8.1
223.1.8.0
223.1.2.6
Interconnected
system consisting
of six networks.
223.1.2.1
223.1.3.27
223.1.2.2
Computer networking, Olum-Fonoon Babol
223.1.3.1
H. Veisi
Fall 2005
223.1.3.2
Page 45
IP Addresses (4)
 class-full addressing:
class
16M Hosts
126 Networks A
0 network
65K Hosts
16K Networks
B
10
254 Hosts
4M Networks
C
110
D
1110
1.0.0.0 to
127.255.255.255
host
128.0.0.0 to
191.255.255.255
host
network
network
host
multicast address
192.0.0.0 to
223.255.255.255
224.0.0.0 to
239.255.255.255
32 bits
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 46
IP Addresses (5)
class code
network
host
 Special Cases
 0.0.0.0 :Source IP Addr. Just after Boot
 network part of dest. Addr.= 0 :Source and
Destination are in same network.
 Dest. Addr.=255.255.255.255 :Broadcast in
Sender’s network.
 host part of Dest.=111… : Broadcast in destination
network.
 Dest. Addr. = 127.anything : Loop Back
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 47
IP Addresses (6)
 Subnets (1):
 A large organization or campus might have 30 or more LANs (one
for each department). And will probably have only a single
connection to the rest of the Internet. inefficient use of address
space, address space exhaustion
 e.g., class B net allocated enough addresses for 65K hosts,
even if only 2K hosts in that network
 In order for every local host to be able to communicate with
other Internet machines, routing entries for each of the 30
networks must exist in the core gateways.
 Wouldn't it be nice if we only needed to advertise a single
network number for all 30 networks?
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 48
IP Addresses (7)
 Subnets (2):
 We want to be able to reduce the number of networks seen by
the outside world; simplify the management of those many
networks within the organization;
 Using Subnet addressing: IP addresses have a well-defined
structure that allows a gateway to extract the network portion
of an address by simply looking at its class and an optional
Subnet mask.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 49
IP Addresses (8)
CIDR: Classless Inter Domain Routing (RFC1519)
 network portion of address of arbitrary length
 address format: a.b.c.d/x, where x is # bits in network portion
of address
 Ex.: A class B network subnetted into 64 subnets:

MASK=255.255.252.0 or IP Add./22
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 50
IP Addresses (9)
 Subnet:
 The subnet mask ANDed with the interface address yields the
network number of the interface.
 If ( ( port_interface_address & subnet_mask ) == ( DEST &
subnet_mask
2
2
2
2
2) ),2 direct
2
2 routing with this port can be used.
7
128
6
5
4
3
2
1
0
64
32
16
8
4
2
1
140.192.56.45
140
192
56
45
1 0 0 0 1 1 0 0
1 1 0 0 0 0 0 0
0 0 1 1 1 0 0 0
0 0 1 0 1 1 0 1
Subnet
Host
Network
IP Address
255
255
255
0
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
140
1 0 0 0 1 1 0 0
192
1 1 0 0 0 0 0 0
56
0 0 1 1 1 0 0 0
0
0 0 0 0 0 0 0 0
192
1 1 0 0 0 0 0 0
56
0 0 1 1 1 0 0 0
45
IP Address
0 0 1 0 1 1 0 1
NetMask
Network Address
140.192.56.0/24
24-bit mask
8-bit subnet mask
140.192.56.45
140
1 0 0 0 1 1 0 0
Network
Subnet
Computer networking,
Olum-Fonoon
Babol
255
255
240H.
Veisi
Host
Fall 02005
Page 51
NetMask
Getting a datagram from source to dest. (1)
forwarding table in A
Dest. Net. Next Router Nhops
223.1.1
223.1.2
223.1.3
IP datagram:
misc source dest
fields IP addr IP addr
data
 datagram remains unchanged,
as it travels source to
destination
 addr fields of interest here
A
223.1.1.4
223.1.1.4
1
2
2
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
B
223.1.2.9
223.1.3.27 223.1.2.2
223.1.1.3
223.1.3.1
Computer networking, Olum-Fonoon Babol
H. Veisi
223.1.3.2
Fall 2005
Page 52
E
Getting a datagram from source to dest. (2)
misc
data
fields 223.1.1.1 223.1.1.3
Starting at A, send IP datagram
addressed to B:
forwarding table in A
Dest. Net. Next Router Nhops
223.1.1
223.1.2
223.1.3
223.1.1.4
223.1.1.4
1
2
2
 look up net. address of B in
A 223.1.1.1
forwarding table
223.1.2.1
 find B is on same net. as A
223.1.1.2
223.1.2.9
223.1.1.4
 link layer will send datagram directly
to B inside link-layer frame
B
223.1.3.27 223.1.2.2
 B and A are directly
223.1.1.3
connected
223.1.3.1
Computer networking, Olum-Fonoon Babol
H. Veisi
223.1.3.2
Fall 2005
Page 53
E
Getting a datagram from source to dest. (3)
forwarding table in A
Dest. Net. Next Router Nhops
misc
data
fields 223.1.1.1 223.1.2.3
223.1.1
223.1.2
223.1.3
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 223.1.1.4
 link layer sends datagram to router
223.1.1.4 inside link-layer frame
 datagram arrives at 223.1.1.4
 continued…..
A
1
2
2
223.1.1.4
223.1.1.4
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
B
223.1.2.9
223.1.3.27 223.1.2.2
223.1.1.3
Computer networking, Olum-Fonoon Babol
223.1.3.1
H. Veisi
223.1.3.2
Fall 2005
Page 54
E
Getting a datagram from source to dest. (4)
misc
data
fields 223.1.1.1 223.1.2.3
Arriving at 223.1.4, destined for
223.1.2.2
 look up network address of E in
router’s forwarding table
 E on same network as router’s
interface 223.1.2.9
 router, E directly attached
 link layer sends datagram to
223.1.2.2 inside link-layer frame
via interface 223.1.2.9
 datagram arrives at 223.1.2.2
forwarding table in router
Dest. Net Router Nhops Interface
223.1.1
223.1.2
223.1.3
A
-
1
1
1
223.1.1.4
223.1.2.9
223.1.3.27
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
B
Computer networking, Olum-Fonoon Babol
223.1.2.9
223.1.3.27 223.1.2.2
223.1.1.3
223.1.3.2
223.1.3.1
H. Veisi
Fall 2005
Page 55
E
The Internet Network layer
Host, Router network-layer-functions:
IP protocol
•addressing conventions
•datagram format
•packet handling conventions
Routing protocols
•path selection
• OSPF, BGP
forwarding
table
ICMP protocol
•error reporting
•router “signaling”
Network layer
Transport layer: TCP, UDP
Link layer
physical layer
OSPF: Open Shortest Path First, RFC2328
 BGP: Border Gateway Protocol, RFC1771
 ICMP: Internet Control Message Protocol, RFC792
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 56
IP addresses: how to get one?
 How does host get IP address?
 IP addr. is configures into host by admin. in a file
 Windows: control-panel->network->configuration->tcp/ip->properties
 DHCP: Dynamic Host Configuration Protocol (RFC2131):
 dynamically get address from as server
 “plug-and-play”
 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 “DHCP discover” msg
 DHCP server responds with “DHCP offer” msg
 host requests IP address: “DHCP request” msg
 DHCP server sends address: “DHCP ack” msg
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 57
The Internet Network layer protocols (1)
 ICMP (Internet Control Message Protocol):
 Allows gateways and hosts to send network control
information to each other.
 Two general types of ICMP messages:
 Information messages,
 where a sender sends a query to another machine (either
host or gateway) and expects an answer. For example, a
host might want to know if a gateway is alive.
 Error indication messages,
 where the IP software on a host or gateway has
encountered a problem processing an IP datagram. For
example, it may be unable to route a datagram to its
destination, or it may have had to drop a frame.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 58
The Internet Network layer protocols (2)
 The principal ICMP message types.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 59
The Internet Network layer protocols (3)
 ARP (Address Resolution Protocol): Map IP add. to MAC add.
 Using broadcasting
 RARP (Reverse Address Resolution Protocol): Map MAC add. to IP add.
 Used in diskettes booting
 OSPF (Open Shortest Path First): Routing for inter-AS (Autonomous system)
 Using Link State routing
 BGP (Border Gateway Protocol): Routing for intra-AS
 Distance vector protocol, but not only does it account for
distance, but also for specific route criteria.
Computer networking, Olum-Fonoon Babol
H. Veisi
Fall 2005
Page 60