Sie sind auf Seite 1von 241

Computer Networks Research Center (CNRC)

Computer Science Department, CIIT, Lahore.


http://research.ciitlahore.edu.pk/Groups/CNRC/

Network Layer
Agenda
• Network Layer
• Internet Protocol
• IP Datagram
• NAT
• Subneting

Network Layer 2
The Internet Network layer
Host, router network layer functions:

Transport layer: TCP, UDP

Routing protocols IP protocol


•path selection •addressing conventions
•RIP, OSPF, BGP •datagram format
Network •packet handling conventions
layer forwarding
ICMP protocol
table •error reporting
•router “signaling”

Link layer

physical layer

Network Layer 3
IP datagram format
IP protocol version 32 bits
number total datagram
header length length (bytes)
ver head. type of length
(bytes) len service for
“type” of data fragment
16-bit identifier flgs fragmentation/
offset
max number time to upper reassembly
Internet
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to Options (if any) E.g. timestamp,
record route
how much overhead data taken, specify
with TCP? (variable length, list of routers
 20 bytes of TCP typically a TCP to visit.
 20 bytes of IP or UDP segment)
 = 40 bytes + app
layer overhead
Network Layer 4
IP Fragmentation & Reassembly
• network links have MTU
(max.transfer size) - largest
possible link-level frame.
– different link types, different fragmentation:
MTUs in: one large datagram
• large IP datagram divided out: 3 smaller datagrams
(“fragmented”) within net
– one datagram becomes
several datagrams
reassembly
– “reassembled” only at final
destination
– IP header bits used to identify,
order related fragments

Network Layer 5
IP Fragmentation and Reassembly
length ID fragflag offset
Example =4000 =x =0 =0
 4000 byte datagram
One large datagram becomes
 MTU = 1500 bytes
several smaller datagrams

length ID fragflag offset


=1500 =x =1 =0
1480 bytes in
data field length ID fragflag offset
=1500 =x =1 =185
offset =
1480/8 length ID fragflag offset
=1040 =x =0 =370

Network Layer 6
IP Addressing: introduction
223.1.1.1
• IP address: 32-bit
identifier for host, router 223.1.2.1
223.1.1.2
interface 223.1.1.4 223.1.2.9
• interface: connection
223.1.2.2
between host/router and 223.1.1.3 223.1.3.27

physical link
– router’s typically have
multiple interfaces 223.1.3.1 223.1.3.2
– host may have multiple
interfaces
– IP addresses associated
with each interface 223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 1 1

Network Layer 7
Subnets
223.1.1.1
• IP address:
– subnet part (high order 223.1.2.1
223.1.1.2
bits) 223.1.1.4 223.1.2.9
– host part (low order bits)
223.1.2.2
• What’s a subnet ? 223.1.1.3 223.1.3.27
– device interfaces with
same subnet part of IP LAN
address 223.1.3.2
223.1.3.1
– can physically reach each
other without intervening
router
network consisting of 3 subnets

Network Layer 8
Subnets
223.1.1.0/24
223.1.2.0/24

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.3.0/24
Subnet mask: /24

Network Layer 9
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.3.27

223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2

Network Layer 10
IP addresses: how to get one?

Q: How does host get IP address?

• hard-coded by system admin in a file


– Wintel: control-panel->network->configuration->tcp/ip->properties
– UNIX: /etc/rc.config
• DHCP: Dynamic Host Configuration Protocol: dynamically get address from as
server
– “plug-and-play”
(more in next chapter)

Network Layer 11
IP addressing: the last word...

Q: How does an ISP get block of addresses?


A: ICANN: Internet Corporation for Assigned
Names and Numbers
– allocates addresses
– manages DNS
– assigns domain names, resolves disputes

Network Layer 12
NAT: Network Address Translation

rest of local network


Internet (e.g., home network)
10.0.0/24 10.0.0.1

10.0.0.4
10.0.0.2
138.76.29.7

10.0.0.3

All datagrams leaving local Datagrams with source or


network have same single source destination in this network
NAT IP address: 138.76.29.7, have 10.0.0/24 address for
different source port numbers source, destination (as usual)

Network Layer 13
NAT: Network Address Translation

• Motivation: local network uses just one IP address as far as


outside word is concerned:
– no need to be allocated range of addresses from ISP:
- just one IP address is used for all devices
– can change addresses of devices in local network
without notifying outside world
– can change ISP without changing addresses of
devices in local network
– devices inside local net not explicitly addressable,
visible by outside world (a security plus).
Network Layer 14
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 15
NAT: Network Address Translation
NAT translation table
2: NAT router 1: host 10.0.0.1
WAN side addr LAN side addr
changes datagram sends datagram to
138.76.29.7, 5001 10.0.0.1, 3345 128.119.40, 80
source addr from
…… ……
10.0.0.1, 3345 to
138.76.29.7, 5001, S: 10.0.0.1, 3345
updates table D: 128.119.40.186, 80
10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345 4
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: Reply arrives changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345

Network Layer 16
NAT: Network Address Translation

• 16-bit 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 shortage should instead be solved by IPv6

Network Layer 17
The 32 bit Binary IP Adress
• An IP address is represented by a 32 bit binary
number
• The value of the right-most bit (also called the least
significant bit) is either 0 or 1
• The corresponding decimal value of each bit doubles
as you move left in the binary number
• So the decimal value of the 2nd bit from the right is
either 0 or 2. The third bit is either 0 or 4, the fourth
bit 0 or 8, etc ...
• IP addresses are expressed as dotted-decimal
numbers
• we break up the 32 bits of the address into four
octets (an octet is a group of 8 bits).
Network Layer 18
• The maximum decimal value of each octet is 255
• The largest 8 bit binary number is 11111111
• Those bits, from left to right, have decimal values of
128, 64, 32, 16, 8, 4, 2, and 1. Added together, they
total 255

Network Layer 19
Network Layer 20
• The network number of an IP address identifies the
network to which a device is attached
• The host portion of an IP address identifies the
specific device on that network

Network Layer 21
Network Layer 22
• When written in a binary format, the first (leftmost) bit of a Class
A address is always 0.
• Example of a Class A IP address is 124.95.44.15
• The first octet, 124, identifies the network number assigned by
ARIN
• which will range from 0-126. (127 does start with a 0 bit, but has
been reserved for special purposes.)
• The internal administrators of the network assign the remaining
24 bits
• All Class A IP addresses use only the first 8 bits to identify the
network part of the address
• Every network that uses a Class A IP address can have
assigned up to 2 to-the-power of 24 (224) (minus 2), or
16,777,214, possible IP addresses to devices that are attached
to its network
Network Layer 23
• The first 2 bits of a Class B address are always 10
(one and zero).
• example of a Class B IP address is 151.10.13.28
• The first two octets identify the network number
assigned by ARIN
• Class B IP addresses always have values ranging
from 128 to 191 in their first octet
• Every network that uses a Class B IP address can
have assigned up to 2 to-the-power of 16 (216) (minus
2 again!), or 65,534, possible IP addresses to devices
that are attached to its network
Network Layer 24
• The first 3 bits of a Class C address are always 110
(one, one and zero).
• An example of a Class C IP address is 201.110.213.28
• The first three octets identify the network number
• Class C IP addresses always have values ranging from
192 to 223 in their first octet.
• All Class C IP addresses use the first 24 bits to identify
the network part of the address
• Every network that uses a Class C IP address can have
assigned up to 28 (minus 2), or 254, possible IP
addresses to devices that are attached to its network
Network Layer 25
Network Layer 26
IP reserved Addresses
• If your computer wanted to communicate with all of the devices
on a network, it would be quite unmanageable to write out the IP
address for each device
• An IP address that ends with binary 0s in all host bits is
reserved for the network address (sometimes called the wire
address)
• Therefore, as a Class A network example, 113.0.0.0 is the IP
address of the network containing the host 113.1.2.3
• A router uses a network's IP address when it forwards data on
the Internet. As a Class B network example, the IP address
176.10.0.0 is a network address.
• If you wanted to send data to all of the devices on a network,
you would need to use a broadcast address

Network Layer 27
• Broadcast IP addresses end with binary 1s in the
entire host part of the address (the host field)
• For the network in the example (176.10.0.0)
• where the last 16 bits make up the host field (or host
part of the address), the broadcast that would be sent
out to all devices on that network would include a
destination address of 176.10.255.255 (since 255 is
the decimal value of an octet containing 11111111).
• When you send a broadcast packet on a network, all
devices on the network notice it

Network Layer 28
Subnets
• Network administrators sometimes need to divide
networks, especially large ones, into smaller
networks
• These smaller divisions are called subnetworks and
provide addressing flexibility. Most of the time
subnetworks are simply referred to as subnets
• each subnet address is unique.
• Subnet addresses include the Class A, Class B, or
Class C network portion, plus a subnet field and a
host field

Network Layer 29
Network Layer 30
• The subnet field and the host field are created from
the original host portion for the entire network
• To create a subnet address, a network administrator
borrows bits from the original host portion and
designates them as the subnet field.
• The minimum number of bits that can be borrowed is
2

Network Layer 31
Why subnets!
• A primary reason for using subnets is to reduce the
size of a broadcast domain
• When broadcast traffic begins to consume too much
of the available bandwidth, network administrators
may choose to reduce the size of the broadcast
domain.

Network Layer 32
Subnet Mask
• The subnet mask (formal term: extended network
prefix), is not an address, but determines which part
of an IP address is the network field and which part is
the host field
• A subnet mask is 32 bits long and has 4 octets, just
like an IP address. 
• To determine the subnet mask for a particular
subnetwork IP address follow these steps
– Express the subnetwork IP address in binary form
– Replace the network and subnet portion of the address with
all 1s
– Replace the host portion of the address with all 0s
– As the last step convert the binary expression back to
dotted-decimal notation.Network Layer 33
• The term "operations" in mathematics refers to rules
that define how one number combines with other
numbers
• The basic Boolean operations are AND, OR, and
NOT.

Network Layer 34
Network Layer 35
• In order to route a data packet, the router must first
determine the destination network/subnet address by
performing a logical AND using the destination host's
IP address and the subnet mask
• The result will be the network/subnet address
• The router has received a packet for host
131.108.2.2 - it uses the AND operation to learn that
this packet should be routed to subnet 131.108.2.0

Network Layer 36
Subnet Mask (Cont.)
• The process used to apply the subnet mask
involves Boolean Algebra to filter out non-
matching bits to identify the network
address.

Network Layer 37
Boolean Algebra
• Boolean Algebra is a process that applies
binary logic to yield binary results.
• Working with subnet masks, you need only 4
basic principles of Boolean Algebra:
– 1 and 1 = 1
– 1 and 0 = 0
– 0 and 1 = 0
– 0 and 0 = 0

Network Layer 38
Boolean Algebra (Cont.)
• In another words, the only way you can get
a result of a 1 is to combine 1 & 1.
Everything else will end up as a 0.
• The process of combining binary values
with Boolean Algebra is called Anding.

Network Layer 39
Default Standard Subnet Masks
• There are default standard subnet masks
for Class A, B and C addresses:

Network Layer 40
A Trial Separation
• Subnet masks apply only to Class A, B or C
IP addresses.
• The subnet mask is like a filter that is
applied to a message’s destination IP
address.
• Its objective is to determine if the local
network is the destination network.

Network Layer 41
A Trial Separation (Cont.)
• The subnet mask goes like this:
1. If a destination IP address is
206.175.162.21, we know that it is a Class
C address & that its binary equivalent is:
11001110.10101111.10100010.00010101

Network Layer 42
A Trial Separation (Cont.)
1. We also know that the default standard
Class C subnet mask is: 255.255.255.0 and
that its binary equivalent is:
11111111.11111111.11111111.00000000

Network Layer 43
A Trial Separation (Cont.)

1. When these two binary numbers (the IP


address & the subnet mask) are
combined using Boolean Algebra, the
Network ID of the destination network is
the result:

Network Layer 44
A Trial Separation (Cont.)
1. The result is the IP address of the network
which in this case is the same as the local
network & means that the message is for
a node on the local network.

Network Layer 45
Subnetting Networks ID
• A 3-step example of how the default Class A
subnet mask is applied to a Class A address:

Network Layer 46
Subnetting Networks ID (Cont.)
• In the previous slide, the default Class A subnet
mask (255.0.0.0) is AND’d with the Class A
address (123.123.123.001) using Boolean Algebra,
which results in the Network ID (123.0.0.0) being
revealed.
• The default Class B subnet mask (255.255.0.0)
strips out the 16-bit network ID & the default
Class C subnet mask (255.255.255.0) strips out
the 24-bit network ID.

Network Layer 47
Subnetting, Subnet & Subnet Mask

• Subnetting, a subnet & a subnet mask are


all different.
• In fact, the 1st creates the 2nd & is identified
by the 3rd.
• Subnetting is the process of dividing a
network & its IP addresses into segments,
each of which is called a subnetwork or
subnet.
Network Layer 48
Subnetting, Subnet & Subnet Mask
(Cont.)

• The subnet mask is the 32-bit number that


the router uses to cover up the network
address to show which bits are being used
to identify the subnet.

Network Layer 49
Subnetting
• A network has its own unique address, such as
a Class B network with the address 172.20.0.0
which has all zeroes in the host portion of the
address.
• From the basic definitions of a Class B network
& the default Class B subnet mask, you know
that this network can be created as a single
network that contains 65,534 individual hosts.

Network Layer 50
Subnetting (Cont.)
• Through the use of subnetting, the network
from the previous slide can be logically
divided into subnets with fewer hosts on
each subnetwork.
• It does not improve the available shared
bandwidth only, but it cuts down on the
amount of broadcast traffic generated over
the entire network as well.
Network Layer 51
Subnetting (Cont.)
• The 2 primary benefits of subnetting are:
1. Fewer IP addresses, often as few as one, are
needed to provide addressing to a network &
subnetting.
2. Subnetting usually results in smaller routing
tables in routers beyond the local
internetwork.

Network Layer 52
Subnetting (Cont.)
• Example of subnetting: when the network
administrator divides the 172.20.0.0
network into 5 smaller networks –
172.20.1.0, 172.20.2.0, 172.20.3.0,
172.20.4.0 & 172.20.5.0 – the outside world
stills sees the network as 172.20.0.0, but the
internal routers now break the network
addressing into the 5 smaller subnetworks.

Network Layer 53
Subnetting (Cont.)
• In the example, only a single IP address is
used to reference the network & instead of
5 network addresses, only one network
reference is included in the routing tables
of routers on other networks.

Network Layer 54
Borrowing Bits to Grow a Subnet
• The key concept in subnetting is borrowing
bits from the host portion of the network to
create a subnetwork.
• Rules govern this borrowing, ensuring that
some bits are left for a Host ID.
• The rules require that two bits remain
available to use for the Host ID& that all of
the subnet bits cannot be all 1s or 0s at the
same time.
Network Layer 55
Borrowing Bits to Grow a Subnet
(Cont.)
• For each IP address class, only a certain
number of bits can be borrowed from the
host portion for use in the subnet mask.

Network Layer 56
Borrowing Bits to Grow a Subnet
(Cont.)
Bits Available for Creating Subnets

Address Class Host Bits Bits Available for


Subnet

A 24 22

B 16 14

C 8 6

Network Layer 57
Subnetting a Class A Network
• The default subnet mask for a class A
network is 255.0.0.0 which allows for more
than 16,000,000 hosts on a single network.
• The default subnet mask uses only 8 bits to
identify the network, leaving 24 bits for
host addressing .

Network Layer 58
Subnetting a Class A Network (Cont.)
• To subnet a Class A network, you need to borrow
a sufficient number of bits from the 24-bit host
portion of the mask to allow for the number of
subnets you plan to create, now & in the future.
• Example: To create 2 subnets with more than 4
millions hosts per subnet, you must borrow 2 bits
from the 2nd octet & use 10 masked (value equals
one) bits for the subnet mask
(11111111.11000000) or 255.192 in decimal.

Network Layer 59
Subnetting a Class A Network (Cont.)

• Keep in mind that each of the 8-bit octets


has binary place values.
• When you borrow bits from the Host ID
portion of the standard mask, you don’t
change the value of the bits, only how they
are grouped & used.

Network Layer 60
Class A Subnet Masks (Cont.)
• A sample of subnet mask options available for Class A addresses.

Network Layer 61
Class A Subnet Masks (Cont.)
• All subnet masks contain 32 bits; no more,
no less.
• However a subnet mask cannot filter more
than 30 bits. This means 2 things:
– One, that there cannot be more than 30 ones
bits in the subnet mask.
– Two, that there must always be at least 2 bits
available for the Host ID.

Network Layer 62
Class A Subnet Masks (Cont.)
• The subnet mask with the highest value
(255.255.255.252) has a binary
representation of:
11111111.11111111.11111111.11111100
• The 2 zeroes in this subnet mask represent
the 2 positions set aside for the Host
address portion of the address.

Network Layer 63
Class A Subnet Masks (Cont.)
• Remember that the addresses with all ones
(broadcast address) & all zeroes (local
network) cannot be used as they have
special meanings.

Network Layer 64
Subnetting Class B & Class C
• The table on previous slide “Class A Subnet
Masks” is similar to the tables used for Class
B & Class C IP addresses & subnet masks.
• The only differences are that you have
fewer options (due to a fewer number of
bits available) & that you’re much more
likely to work with Class B & Class C
networks in real life.

Network Layer 65
Subnetting Class B & Class C (Cont.)
• A sample of the subnet masks available for Class B networks.

Network Layer 66
Subnetting Class B & Class C (Cont.)
• A list of the subnet masks available for Class C networks.

Network Layer 67
Knowing How to Calculate Subnets

• To determine the number of subnets & hosts


per subnet available for any of the available
subnet masks, 2 simple formulas to calculate
these numbers:

Network Layer 68
Knowing How to Calculate Subnets
(Cont.)

• Although the 2 formulas look identical, the


key is to remember the number you’re
trying to calculate, hosts or subnets.
• Eg., suppose you are asked to determine
the number of subnets available & the
number of hosts available on each subnet
on the network 192.168.1.0 

Network Layer 69
Knowing How to Calculate Subnets
(Cont.)

• Using the subnet & hosts formulas, the


answers are easily calculated. Of course,
you must know your powers of 2 to
calculate the answers.

Network Layer 70
Class C Subnets
• Knowing the relationships in this table will
significantly reduce the time you spend
calculating subnetting problems.

Network Layer 71
Class B Subnets
• To calculate the number of subnets & hosts
available from a Class B subnet mask, you
use the same host & subnet formulas
described for calculating Class C values.
• Using these formulas I have constructed a
table that contains the Class B subnet &
host values.

Network Layer 72
Class B Subnets (Cont.)

Network Layer 73
So How Does This Work?
• We ask our ISP for a Class C license.
• They give us the Class C bank of 206.15.143.0
• This gives us 1 Network (206.15.143.0) with
the potential for 254 node addresses
(206.15.143.1 to 206.15.143.254).
• But we have a LAN made up of 5 Networks
with the largest one serving 25 nodes.
• So we need to Subnet our 1 IP address...

Network Layer 74
So How Does This Work?
• To calculate the number of subnets
(networks) and/or nodes, we need to do
some math:

• Use the formula 2n-2 where the n can


represent either how many subnets
(networks) needed OR how many nodes per
subnet needed.
Network Layer 75
So How Does This Work?
• We know we need at least 5 subnets. So 23-2 will
give us 6 subnet addresses (Network Addresses).
• We know we need at least 25 nodes per
network. 25-2 will give us 30 nodes per subnet
(network).
• This will work, because we can steal the first 3
bits from the node’s portion of the address to
give to the network portion and still have 5 (8-3)
left for the node portion:

Network Layer 76
Break it down:
• Let’s go back to what portion is what:
We have a Class C address:
NNNNNNNN.NNNNNNNN.NNNNNNNN.nnnnnnnn
With a Subnet mask of:
11111111.11111111.11111111.00000000

We need to steal 3 bits from the node portion to give it to


the Network portion:
NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNnnnnn

Network Layer 77
Break it down:
• NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNnnnnn

• This will change our subnet mask to the following:


• 11111111.11111111.11111111.11100000

• Above is how the computer will see our new subnet


mask, but we need to express it in decimal form as well:
255.255.255.224 128+64+32=224

Network Layer 78
What address is what?
• Which of our 254 addresses will be a Subnet (or
Network) address and which will be our node
addresses?
• Because we are using the first 3 bits for our subnet
mask, we can configure them into eight different ways
(binary form):
000 001
010 011
100 101
110 111

Network Layer 79
What address is what?
• We cannot use all “0”s or all “1”s
000 001
010 011
100 101
110 111

•We are left with 6 useable network numbers.

Network Layer 80
Network (Subnet) Addresses
• Remember our values:
128 64 32 16 8 4 2 1 Equals
Now our 3 bit configurations:
0 0 1 n n n n n 32
0 1 0 n n n n n 64
0 1 1 n n n n n 96
1 0 0 n n n n n 128
1 0 1 n n n n n 160
1 1 0 n n n n n 192

Network Layer 81
Network (Subnet) Addresses
0 0 1 n n n n n 32
0 1 0 n n n n n 64
0 1 1 n n n n n 96
1 0 0 n n n n n 128
1 0 1 n n n n n 160
1 1 0 n n n n n 192

Each of these numbers becomes the Network


Address of their subnet...
Network Layer 82
Network (Subnet) Addresses
206.15.143.32
206.15.143.64
206.15.143.96
206.15.143.128
206.15.143.160
206.15.143.192

Network Layer 83
Node Addresses
• The device assigned the first address will receive the
first number AFTER the network address shown before.
206.15.143.33 or 32+1
0 0 1 0 0 0 0 1
And the last address in the Network will look like this:
206.15.143.62
0 0 1 1 1 1 1 0
*Remember, we cannot use all “1”s, that is the broadcast address
(206.15.143.63)

Network Layer 84
Node Addresses
• The next network will start at 206.15.143.64
• The first IP address on this subnet network will
receive:
206.15.143.65
0 1 0 0 0 0 0 1
And the last address in the Network will receive:
206.15.143.94
0 1 0 1 1 1 1 0
*Remember, the broadcast address (206.15.143.95)

Network Layer 85
Can you figure out the rest?
• Network: Host Range
• 206.15.143.32 206.15.143.32 to 206.15.143.62
• 206.15.143.64 206.15.143.65 to 206.15.143.94
• 206.15.143.96
• 206.15.143.128 206.15.143.97 to 206.15.143.126
• 206.15.143.160 206.15.143.129 to 206.15.143.158
• 206.15.143.192
206.15.143.161 to 206.15.143.190
206.15.143.193 to 206.15.143.222
Network Layer 86
How the computer finds the
Network Address:
• 200.15.143.89 An address on the subnet
• 225.225.225.224 The new subnet mask
• When the computer does the Logical Bitwise AND
Operation it will come up with the following Network
Address (or Subnet Address):
11001000.00001111.10001111.01011001= 200.15.143.89
11111111.11111111.11111111.11100000 = 255.255.255.224
11001000.00001111.10001111.01000000 = 200.15.143.64 (Network)
This address falls on our 2nd Subnet (Network)

Network Layer 87
Review
• We have one class C license.
• We need to subnet that into 12 possible
networks.
• Each network needs a maximum of 10 nodes.
• How many bits do we need to take?
24-2=14
4 bits need to be taken from the node portion and
given to the network portion.
Network Layer 88
Review
• Will that leave enough bits for the node
portion? We need a maximum of 10 on
each network…
24-2=14
• If we take 4 away, that leaves us with 4.
That is enough for our individual networks
of 10 nodes each.

Network Layer 89
Review
• Our new subnet mask will look like this:
11111111.11111111.11111111.11110000
255.255.255.240 128+64+32+16= 240
• Our subnet, or network addresses will be:
206.15.143.16 206.15.143.32 206.15.143.48
206.15.143.64 206.15.143.80 206.15.143.96
206.15.143.112 206.15.143.128 206.15.143.144
206.15.143.160 206.15.143.176 206.15.143.192
206.15.143.208 206.15.143.224
Network Layer 90
VLSM
• VLSM – the process
of sub-netting a
subnet to fit your
needs
• Example:
– Subnet 10.1.0.0/16, 8
more bits are borrowed
again, to create 256
subnets with a /24 mask.
– Mask allows for 254 host
addresses per subnet
– Subnets range from:
10.1.0.0 / 24 to
10.1.255.0 / 24
VLSM
• Find the largest segment. Segment which need largest
number of hosts address.
• Do Subnetting to fulfill the requirement of largest segment.
• Assign the appropriate subnet mask for the largest segment.
• For second largest segments, take one of these newly
created subnets and apply a different, more appropriate,
subnet mask to it.
• Assign the appropriate subnet mask for the second largest
segment.
• Repeat this process until the last network.
VLSM
• Step 1- Oder Segments from largest to
smallest
Subnet Segment Hosts
1 Computer Science 74
2 EE 52
3 Physics 28
4 Wan link 1 2
5 Wan link 2 2
6 Wan link 3 2
• Step 2: largest segment needs 74 host
addresses. /25 provide us two subnets with
126 hosts in each subnet. 192.168.1.0/25
Subnet Subnet 1 Subnet 2
Network ID 192.168.1.0 192.168.1.128

First host address 192.168.1.1 192.168.1.129

Last host address 192.168.1.126 192.168.1.254

Broadcast ID 192.168.1.127 192.168.1.255


• Step 3: Assign subnet Segment Computer Science

mask to the largest Requirement 74

segment. As you can CIDR /25

see in the previous Subnet mask 255.255.255.128


table, subnet 1 fulfill Network ID 192.168.1.0
our largest segment First hosts 192.168.1.1
requirement. Assign Last hosts 192.168.1.126
it to our segment.
Broadcast ID 192.168.1.127
• Do subnetting for second largest segment from next available subnet. Next segment requires
52 host addresses. Subnetting of /25 has given us two subnets with 126 hosts in each, from
that we have assigned first subnet to Computer Science segment. Second segment is
available, we would do subnetting of this.
• /26 provide us 4 subnets with 62 hosts in each subnet.
• 192.168.1.0/26

Subnet Subnet 1 Subnet 2 Subnet 3 Subnet 4

Network ID 0 64 128 192

First address 1 65 129 193

Last address 62 126 190 254

Broadcast ID 63 127 191 255

We cannot use subnet 1 and subnet 2 ( address from 0 to 127 ) as they are already
assigned to Computer Science department. We can assign subnet 3 to EE department.
Segment EE

Requirement 52

CIDR /26

Subnet mask 255.255.255.192

Network ID 192.168.1.128

First hosts 192.168.1.129

Last hosts 192.168.1.190

Broadcast ID 192.168.1.191
• Step 4 :- Our next segment requires 28 hosts. From above subnetting we
have subnet 3 and subnet 4 available. Do subnetting for the requirement of
28 hosts.
• 192.168.1.0/27
Subnet Sub 1 Sub 2 Sub 3 Sub 4 Sub 5 Sub 6 Sub 7 Sub 8

Net ID 0 32 64 96 128 160 192 224

First Host 1 33 65 95 129 161 193 225

LastHost 30 62 94 126 158 190 222 254

Broadcast ID 31 63 95 127 159 191 223 255

* Subnets 1 to 6 [ address from 0 to 191] are already occupied by previous segments.


We can assign subnet 7 to this segment.
Segment Physics

Requirement 28

CIDR /27

Subnet mask 255.255.255.224

Network ID 192.168.1.192

First hosts 192.168.1.193

Last hosts 192.168.1.222

Broadcast ID 192.168.1.223
ICMP: Internet Control Message Protocol

• used by hosts & routers to communicate network-level information


Type Code description
– error reporting: unreachable host, network, port, protocol
0 0 echo reply (ping)
– echo request/reply (used by ping) 3 0 dest. network unreachable
• network-layer “above” IP: 3 1 dest host unreachable
– ICMP msgs carried in IP datagrams 3 2 dest protocol unreachable
• 3 of IP3datagram
ICMP message: type, code plus first 8 bytes destcausing
port unreachable
error
3 6 dest network unknown
3 7 dest host unknown
4 0 source quench (congestion
control - not used)
8 0 echo request (ping)
9 0 route advertisement
10 0 router discovery
11 0 TTL expired
12 0 bad IP header

Network Layer 101


Traceroute and ICMP
• When
SourceICMP
sendsmessage
series ofarrives,
UDP segments
source calculates
to dest RTT
– First hasdoes
• Traceroute TTL =1this 3 times
– Second
Stopping has TTL=2, etc.
criterion
– Unlikely port number
• UDP segment eventually arrives at destination host
•• When nth datagram
Destination arrives
returns ICMP to nth
“host router:
unreachable” packet (type 3, code 3)
– Router discards datagram
• When source gets this ICMP, stops.
– And sends to source an ICMP message (type 11, code 0)
– Message includes name of router& IP address

Network Layer 102


IPv6
• Initial motivation: 32-bit address space soon
to be completely allocated.
• Additional motivation:
– header format helps speed processing/forwarding
– header changes to facilitate QoS
IPv6 datagram format:
– fixed-length 40 byte header
– no fragmentation allowed

Network Layer 103


IPv6 Header (Cont)
Priority: identify priority among datagrams in flow
Flow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
Next header: identify upper layer protocol for data

Network Layer 104


Other Changes from IPv4
• Checksum: removed entirely to reduce
processing time at each hop
• Options: allowed, but outside of header,
indicated by “Next Header” field
• ICMPv6: new version of ICMP
– additional message types, e.g. “Packet Too Big”
– multicast group management functions

Network Layer 105


Transition From IPv4 To IPv6
• Not all routers can be upgraded simultaneous
– no “flag days”
– How will the network operate with mixed IPv4 and
IPv6 routers?
• Tunneling: IPv6 carried as payload in IPv4
datagram among IPv4 routers

Network Layer 106


Tunneling
A B E F
Logical view: tunnel

IPv6 IPv6 IPv6 IPv6

A B C D E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6

Flow: X Src:B Src:B Flow: X


Src: A Dest: E Dest: E Src: A
Dest: F Dest: F
Flow: X Flow: X
Src: A Src: A
data Dest: F Dest: F data

data data

A-to-B: E-to-F:
B-to-C: B-to-C:
IPv6 IPv6
IPv6 inside IPv6 inside
IPv4 IPv4
Network Layer 107
Graph abstraction
5
3
v w 5
2
u 2 1 z
3
1 2
Graph: G = (N,E)
x 1
y

N = set of routers = { u, v, w, x, y, z }

E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }

Remark: Graph abstraction is useful in other network contexts

Example: P2P, where N is set of peers and E is set of TCP connections

Network Layer 108


Graph abstraction: costs
5 • c(x,x’) = cost of link (x,x’)
3
v w 5
2 - e.g., c(w,z) = 5
u 2 1 z
3 • cost could always be 1, or
1 2 inversely related to bandwidth,
x 1
y
or inversely related to
congestion

Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

Question: What’s the least-cost path between u and z ?

Routing algorithm: algorithm that finds least-cost path


Network Layer 109
Routing Algorithm classification
Global or decentralized Static or dynamic?
information?
Static:
Global:
• all routers have complete • routes change slowly over
topology, link cost info time
• “link state” algorithms Dynamic:
Decentralized: • routes change more
• router knows physically-
quickly
connected neighbors, link costs
to neighbors – periodic update
• iterative process of computation,
exchange of info with neighbors
– in response to link
• “distance vector” algorithms cost changes

Network Layer 110


A Link-State Routing Algorithm

Notation:algorithm
Dijkstra’s
•• net
c(x,y):
topology, link from
link cost costsnode
known toy;all=nodes
x to ∞ if not direct neighbors
– accomplished via “link state broadcast”
• D(v): current value of cost of path from source to dest. v
– all nodes have same info
• p(v): predecessor node along path from source to v
• computes least cost paths from one node (‘source”) to all other nodes
• N': set offorwarding
– gives nodes whose least
table forcost
thatpath
nodedefinitively known
• iterative: after k iterations, know least cost path to k dest.’s

Network Layer 111


Dijsktra’s Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
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) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'

Network Layer 112


Dijkstra’s algorithm: example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz

5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y

Network Layer 113


Dijkstra’s algorithm, discussion
Algorithm complexity: n nodes
• each iteration: need to check all nodes, w, not in N
• n(n+1)/2 comparisons: O(n2)
• more efficient implementations possible: O(nlogn)
Oscillations possible:
• e.g., link cost = amount of carried traffic

1 A A A A
1+e 2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0 0 1 1+e 0 e
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
Network Layer 114
Distance Vector Algorithm (1)
Bellman-Ford Equation (dynamic programming)
Define
dx(y) := cost of least-cost path from x to y

Then

dx(y) = min {c(x,v) + dv(y) }

where min is taken over all neighbors of x


Network Layer 115
Bellman-Ford example (2)
5
3
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v w 5
2
u 2 1 z B-F equation says:
3
1 du(z) = min { c(u,v) + dv(z),
2
1
x y
c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
Node that achieves minimum is next
hop in shortest path ➜ forwarding table
Network Layer 116
Distance Vector Routing Algorithm

distributed:
• each node communicates only with directly-attached
neighbors

iterative:
• continues until no nodes exchange info.
• self-terminating: no “signal” to stop

asynchronous:
• nodes need not exchange info/iterate in lock step!
Network Layer 117
Distance Vector Routing Algorithm

Distance Table data structures


• each node has its own routing table
• row for each possible destination
• column for each directly-attached neighbor to node
• e.g., in node X, for dest. Y via neighbor Z :

distance from X to
= Y, via Z as next hop
DX(Y,Z)
Z
= c(X,Z) + minw{D (Y,w)}

Network Layer 118


Distance Vector Algorithm:
At all nodes, X:
1 Initialization:
2 for all adjacent nodes v:
3 D X(*,v) = infty /* the * operator means "for all rows" */
X
4 D (v,v) = c(X,v)
5 for all destinations, y
X
6 send min D (y,w) to each neighbor /* w over all X's neighbors */
w

Network Layer 119


Distance Vector Algorithm (cont.):
8 loop
9 wait (until I see a link cost change to neighbor V
10 or until I receive update from neighbor V)
11
12 if (c(X,V) changes by d)
13 /* change cost to all dest's via neighbor v by d */
14 /* note: d could be positive or negative */
15 for all destinations y: D (y,V) = D (y,V) + d
X X
16
17 else if (update received from V wrt destination Y)
18 /* shortest path from V to some Y has changed */
19 /* V has sent a new value for its min DV(Y,w) */
20 /* call this received new value is "newval"
w */
21 for the single destination y: DX(Y,V) = c(X,V) + newval
22
23 if we have a new min DX (Y,w)for any destination Y
24 send new value of min w DX(Y,w) to all neighbors
25 w
26 forever
Network Layer 120
Distance Vector Routing: overview
each local iteration caused by: Each node:
• local link cost change
• message from neighbor: its
least cost path change from wait for (change in local link
neighbor cost of msg from neighbor)

recompute distance table


• each node notifies neighbors
only when its least cost path
to any destination changes if least cost path to any dest
– neighbors then notify their has changed, notify
neighbors if necessary neighbors

Network Layer 121


Distance Vector Algorithm: example

X
2 7
Y Z
1

Network Layer 122


Distance Vector Algorithm: example

X
2 7
Y Z X Z
1 D (Y,Z) = c(X,Z) + minw {D (Y,w)}
= 7+1 = 8

X Y
D (Z,Y) = c(X,Y) + minw {D (Z,w)}
= 2+1 = 3

Network Layer 123


Distance Vector Algorithm: example

X
2 7
Y Z
1

Network Layer 124


Distance Vector Algorithm: example

X
2 7
No improvement
Y Z
1

Network Layer 125


Distance Vector Algorithm: example

2 8
X 3 7
2 7
Y Z
1

2 4
5 1

7 3
9 1

Network Layer 126


Distance Table: example
1 cost to destination via
B C E
7 D () A B D
A 8 2
1 A 1 14 5
E D
2
B 7 8 5

destination
E D
D (C,D) = c(E,D) + minw {D (C,w)}
= 2+2 = 4 C 6 9 4
E D
D (A,D) = c(E,D) + min {D (A,w)}
w D 4 11 2
= 2+3 = 5 loop!
E B
D (A,B) = c(E,B) + minw{D (A,w)}
= 8+6 = 14
loop!
Network Layer 127
Distance table gives routing table

cost to destination via


E Outgoing link
D () A B D to use, cost

A 1 14 5 A A,1

B 7 8 5 B D,5
destination

destination
C 6 9 4 C D,4

D 4 11 2 D D,4

Distance table Routing table


Network Layer 128
Distance Vector: link cost changes

Link cost changes:


 node detects local link cost change 1
 updates distance table Y
4 1
 if cost change in least cost path, notify
neighbors X Z
50

algorithm
terminates
“good
news
travels
fast”

Network Layer 129


Distance Vector: link cost changes

Link cost changes:


 good news travels fast 60
 bad news travels slow - “count Y
to infinity” problem! 4 1
X Z
50

Y Y Y
algorithm
continues
on!

Network Layer 130


Distance Vector: poisoned reverse
If Z routes through Y to get to X :
 Z tells Y its (Z’s) distance to X is infinite (so Y 60
won’t route to X via Z) Y
4 1
 will this completely solve count to infinity problem?
X Z
50

algorithm
Y Y Y Y
terminates

Network Layer 131


Comparison of LS and DV algorithms
Message complexity Robustness: what happens if
• LS: with n nodes, E links, O(nE) router malfunctions?
msgs sent each
• DV: exchange between neighbors
LS:
only – node can advertise incorrect
– convergence time varies link cost
– each node computes only its
Speed of Convergence own table
• LS: O(n**2) algorithm requires DV:
O(nE) msgs – DV node can advertise
incorrect path cost
• DV: convergence time varies – each node’s table used by
– may be routing loops others
• error propagate thru
– count-to-infinity problem network

Network Layer 132


Scalable Routing
Our routing study thus far – idealization (e.g., all routers identical,
network “flat”, … NOT true in practice)

 Routing: more complex with more routers


 scale:
 takes more space to store routing tables; 300 m+ dest.!
 requires more time to compute routes
 uses more link bandwidth to update routes

 administrative autonomy:
 internet = network of networks
 each network administrator may want to control routing in its own
network

Network Layer 133


Scalable Routing
Solution:
 divide the world into several hierarchies
 Do I really care that router z at foo just went down?

 only store info about


 your local area
 how to get to higher up routers

 optimal # of levels for an N router network is


ln N

Network Layer 134


Hierarchical Routing
• aggregate routers gateway routers
into regions, • special routers in AS
“autonomous • run intra-AS routing
protocol in its AS
systems” (AS) • also responsible for
routing to destinations
outside AS
• routers in same AS – run inter-AS
run the same routing protocol
routing protocol with other
– “intra-AS” routing gateway routers
protocol
Network Layer 135
Intra-AS and Inter-AS routing

C.b Gateways:
B.a
• perform inter-AS
A.a
b c routing amongst
a A.c a
C b themselves
a B • perform intra-AS
d c routers with other
A b
routers in their
AS
network layer
inter-AS, intra-AS link layer
routing in physical layer
gateway A.c

Network Layer 136


Intra-AS and Inter-AS routing
Inter-AS
C.b routing
between B.a
A.a A and B Host
b A.c c h2
a C a
b
a B
Host d c Intra-AS routing
h1 b
A within AS B
Intra-AS routing
within AS A

Network Layer 137


Internet Routing
can use any of the standard routing algorithms:

– link-state
• OSPF (Open Shortest Path First)

– distance vector
• RIP (Routing Information Protocol) [RFC 1058] [RFC 1723]
• BGP (Border Gateway Protocol) (inter-AS routing)

Network Layer 138


Intra-AS Routing
• Also known as Interior Gateway Protocols (IGP)
• Most common Intra-AS routing protocols:

– RIP: Routing Information Protocol

– OSPF: Open Shortest Path First

– IGRP: Interior Gateway Routing Protocol (Cisco


proprietary)
Network Layer 139
RIP ( Routing Information Protocol)
• Distance vector algorithm
• Included in BSD-UNIX Distribution in 1982
• Distance metric: # of hops (max = 15 hops)
• Distance vectors: exchanged among neighbors every 30 sec
via Response Message (also called advertisement)
• Each advertisement: list of up to 25 destination nets within AS

Network Layer 140


RIP: Example
Dest Next hops
w - - Advertisement
x - - from A to D
z C 4
…. … ... z
w x y
A D B
C
Destination Network Next Router Num. of hops to dest.
w A 2
y B 2
z B A 7 5
x -- 1
…. …. ....
Routing table in D
Network Layer 141
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 142


RIP Table processing
• RIP routing tables managed by application-level process
called route-d (daemon)
• advertisements sent in UDP packets, periodically repeated

routed routed

Transprt Transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
Network Layer 143
RIP Table example (continued)
Router: giroflee.eurocom.fr
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ------ ---------
127.0.0.1 127.0.0.1 UH 0 26492 lo0
192.168.2. 192.168.2.5 U 2 13 fa0
193.55.114. 193.55.114.6 U 3 58503 le0
192.168.3. 192.168.3.5 U 2 25 qaa0
224.0.0.0 193.55.114.6 U 3 0 le0
default 193.55.114.129 UG 0 143454

 Three attached networks (LANs)


 Router only knows routes to attached LANs
 Default router used to “go up”
 Route multicast address: 224.0.0.0
 Loopback interface (for debugging)

Network Layer 144


OSPF (Open Shortest Path First)
• “open”: publicly available
• Uses Link State algorithm
– LS packet dissemination
– Topology map at each node
– Route computation using Dijkstra’s algorithm

• OSPF advertisement carries one entry per neighbor router


• Advertisements disseminated to entire AS (via flooding)
– Carried in OSPF messages directly over IP (rather than TCP or UDP

Network Layer 145


Inter-AS routing in the Internet: BGP

R4
R5 BGP
R3 AS3
(OSPF intra-AS
AS1 AS2 routing)
(RIP intra-AS (OSPF
routing) BGP intra-AS
routing)
R1 R2

Figure 4.5.2-new2: BGP use for inter-domain routing

Network Layer 146


Internet inter-AS routing: BGP
• BGP (Border Gateway Protocol): the de facto standard
• Path Vector protocol:
– similar to Distance Vector protocol
– each Border Gateway broadcast to neighbors (peers) entire
path (i.e., sequence of AS’s) to destination
– BGP routes to networks (ASs), not individual hosts
– E.g., Gateway X may send its path to dest. Z:
Path (X,Z) = X,Y1,Y2,Y3,…,Z

Network Layer 147


Internet inter-AS routing: BGP
• Suppose: gateway X send its path to peer gateway W
• W may or may not select path offered by X
– cost, policy (don’t route via competitors AS), loop
prevention reasons.
• If W selects path advertised by X, then:
• Path (W,Z) = w, Path (X,Z)
• Note: X can control incoming traffic by controlling it route
advertisements to peers:
– e.g., don’t want to route traffic to Z -> don’t advertise any
routes to Z

Network Layer 148


BGP: controlling who routes to you

legend: provider
B network
X
W A
customer
C network:

Figure 4.5-BGPnew: a simple BGP scenario

 A,B,C are provider networks


 X,W,Y are customer (of provider networks)
 X is dual-homed: attached to two networks
 X does not want to route from B via X to C
 .. so X will not advertise to B a route to C

Network Layer 149


BGP: controlling who routes to you

legend: provider
B network
X
W A
customer
C network:

Figure 4.5-BGPnew: a simple BGP scenario


 A advertises to B the path AW
 B advertises to X the path BAW
 Should B advertise to C the path BAW?
 No way! B gets no “revenue” for routing CBAW since neither

W nor C are B’s customers


 B wants to force C to route to w via A

 B wants to route only to/from its customers!

Network Layer 150


BGP operation
Q: What does a BGP router do?
• Receiving and filtering route advertisements from
directly attached neighbor(s).
• Route selection.
– To route to destination X, which path (of several
advertised) will be taken?
• Sending route advertisements to neighbors.

Network Layer 151


BGP messages
• BGP messages exchanged using TCP.
• BGP messages:
– OPEN: opens TCP connection to peer and authenticates
sender
– UPDATE: advertises new path (or withdraws old)
– KEEPALIVE keeps connection alive in absence of UPDATES;
also ACKs OPEN request
– NOTIFICATION: reports errors in previous msg; also used to
close connection

Network Layer 152


Why different Intra- and Inter-AS
routing ?
• Policy:
– Inter-AS: admin wants control over how its traffic routed, who routes
through its net.
– Intra-AS: single admin, so no policy decisions needed
• Scale:
– hierarchical routing saves table size, reduced update traffic
• Performance:
– Intra-AS: can focus on performance
– Inter-AS: policy may dominate over performance

Network Layer 153


Network Next Router Path

N01 R01 AS14, AS23, AS67

N02 R05 AS22, AS67, AS05, AS89

N03 R06 AS67, AS89, AS09, AS34

N04 R12 AS62, AS02, AS09

Network Layer 154


Path vector messages

Network Layer 155


Broadcast and Multicast Routing
Algorithms
duplicate
duplicate
R1 creation/transmission R1
duplicate
R2 R2

R3 R4 R3 R4

(a) (b)

Figure 4.39 Source-duplication versus in-network duplication.


(a) source duplication, (b) in-network duplication

Network Layer 157


A

B
c

D
F E

Figure 4.40: Reverse path forwarding

Network Layer 158


A A

B B
c c

D D
F E F E

G G
(a) Broadcast initiated at A (b) Broadcast initiated at D

Figure 4.41: Broadcast along a spanning tree

Network Layer 159


A A
3
B B
c c
4
2
D D
F E F E
1 5
G G
(a) Stepwise construction (b) Constructed spanning
of spanning tree tree

Figure 4.42: Center-based construction of a spanning tree

Network Layer 160


Multicast Routing: Problem Statement
• Goal: find a tree (or trees) connecting routers
having local mcast group members
– tree: not all paths between routers used
– source-based: different tree from each sender to rcvrs
– shared-tree: same tree used by all group members

Shared tree Source-based trees


Network Layer 161
Approaches for building mcast trees
Approaches:
• source-based tree: one tree per source
– shortest path trees
– reverse path forwarding
• group-shared tree: group uses one tree
– minimal spanning (Steiner)
– center-based trees

…we first look at basic approaches, then specific protocols


adopting these approaches

Network Layer 162


Shortest Path Tree
• mcast forwarding tree: tree of shortest path
routes from source to all receivers
– Dijkstra’s algorithm

S: source LEGEND
R1 2
1 R4 router with attached
group member
R2 5
router with no attached
3 4
R5 group member
R3 6 i link used for forwarding,
R6 R7 i indicates order link
added by algorithm
Network Layer 163
Reverse Path Forwarding

 rely on router’s knowledge of unicast shortest path


from it to sender
 each router has simple forwarding behavior:

if (mcast datagram received on incoming link on


shortest path back to center)
then flood datagram onto all outgoing links
else ignore datagram

Network Layer 164


Reverse Path Forwarding: example
S: source
LEGEND
R1
R4 router with attached
group member
R2
router with no attached
R5 group member
R3 datagram will be
R6 R7 forwarded
datagram will not be
forwarded

• result is a source-specific reverse SPT


– may be a bad choice with asymmetric links

Network Layer 165


Reverse Path Forwarding: pruning
• forwarding tree contains subtrees with no mcast group
members
– no need to forward datagrams down subtree
– “prune” msgs sent upstream by router with no
downstream group members
S: source LEGEND

R1 router with attached


R4
group member

R2 router with no attached


P group member
P
R5 prune message
R3 P links with multicast
R6 R7 forwarding

Network Layer 166


Shared-Tree: Steiner Tree

• Steiner Tree: minimum cost tree connecting all


routers with attached group members
• problem is NP-complete
• excellent heuristics exists
• not used in practice:
– computational complexity
– information about entire network needed
– monolithic: rerun whenever a router needs to
join/leave
Network Layer 167
Center-based trees
• single delivery tree shared by all
• one router identified as “center” of tree
• to join:
– edge router sends unicast join-msg addressed to center router
– join-msg “processed” by intermediate routers and forwarded
towards center
– join-msg either hits existing tree branch for this center, or
arrives at center
– path taken by join-msg becomes new branch of tree for this
router

Network Layer 168


Center-based trees: an example
Suppose R6 chosen as center:

LEGEND

R1 router with attached


R4
3 group member

R2 router with no attached


2 group member
1
R5 path order in which join
messages generated
R3
1 R6 R7

Network Layer 169


Internet Multicasting Routing: DVMRP

• DVMRP: distance vector multicast routing protocol,


RFC1075
• flood and prune: reverse path forwarding, source-
based tree
– RPF tree based on DVMRP’s own routing tables
constructed by communicating DVMRP routers
– no assumptions about underlying unicast
– initial datagram to mcast group flooded everywhere via
RPF
– routers not wanting group: send upstream prune msgs
Network Layer 170
DVMRP: continued…
• soft state: DVMRP router periodically (1 min.)
“forgets” branches are pruned:
– mcast data again flows down unpruned branch
– downstream router: reprune or else continue to receive
data
• routers can quickly regraft to tree
– following IGMP join at leaf
• odds and ends
– commonly implemented in commercial routers
– Mbone routing done using DVMRP

Network Layer 171


Tunneling
Q: How to connect “islands” of multicast routers in
a “sea” of unicast routers?

physical topology logical topology

 mcast datagram encapsulated inside “normal” (non-multicast-


addressed) datagram
 normal IP datagram sent thru “tunnel” via regular IP unicast to receiving
mcast router
 receiving mcast router unencapsulates to get mcast datagram

Network Layer 172


PIM: Protocol Independent Multicast
• not dependent on any specific underlying unicast routing
algorithm (works with all)
• two different multicast distribution scenarios :

Dense: Sparse:
 group members densely  # networks with group
packed, in “close” members small wrt #
proximity. interconnected networks
 bandwidth more plentiful  group members “widely
dispersed”
 bandwidth not plentiful

Network Layer 173


Consequences of Sparse-Dense Dichotomy:

Dense Sparse:
• group membership by • no membership until routers
routers assumed until explicitly join
routers explicitly prune • receiver- driven construction
• data-driven construction on of mcast tree (e.g., center-
mcast tree (e.g., RPF) based)
• bandwidth and non-group- • bandwidth and non-group-
router processing profligate router processing
conservative

Network Layer 174


PIM- Dense Mode

flood-and-prune RPF, similar to DVMRP but


 underlying unicast protocol provides RPF info for
incoming datagram
 less complicated (less efficient) downstream flood than
DVMRP reduces reliance on underlying routing
algorithm
 has protocol mechanism for router to detect it is a leaf-
node router

Network Layer 175


PIM - Sparse Mode
• center-based approach
• router sends join msg to
rendezvous point (RP) R1
R4
– intermediate routers join
update state and forward R2
join join

• after joining via RP, router R5


join
can switch to source- R3 R7
specific tree R6
– increased performance: all data multicast rendezvous
less concentration, shorter from rendezvous point
paths point

Network Layer 176


PIM - Sparse Mode
sender(s):
• unicast data to RP, which
distributes down RP- R1
R4
rooted tree join
• RP can extend mcast tree R2
join
upstream to source R5
• RP can send stop msg if no join
R3 R7
attached receivers R6
– “no one is listening!”
all data multicast rendezvous
from rendezvous point
point

Network Layer 177


Transport Layer
Transport services and protocols
• provide logical communication application
transport
between app processes running network
data link network
on different hosts physical data link
network physical

lo
• transport protocols run in end data link

gi
ca
physical
systems

l
network

en
data link

d-
– send side: breaks app physical network

en
data link

d
messages into segments, physical

tr
an
network
passes to network layer

s
data link

po
physical

rt
– rcv side: reassembles
segments into messages, application
transport
passes to app layer network
data link
• more than one transport protocol physical

available to apps
– Internet: TCP and UDP

Network Layer 179


Transport vs. Network Layer
• network layer: logical communication between
hosts
– PDU: Datagram
– Datagram’s may be lost, duplicated, reordered in
the Internet – “best effort” service
• transport layer: logical communication
between processes
– relies on, enhances, network layer services
– PDU: Segment
– extends “host-to-host” communication to “process-
to-process” communication
Network Layer 180
TCP/IP Transport Layer Protocols
• reliable, in-order delivery (TCP)
– congestion control
– flow control
– connection setup
• unreliable, unordered delivery: UDP
– no-frills extension of “best-effort” IP
– What does UDP provide in addition to IP?
• services not provided by IP (network layer):
– delay guarantees
– bandwidth guarantees
Network Layer 181
Multiplexing/Demultiplexing
HTTP
Transport FTP Transport
Layer Telnet Layer

Network Network
Layer Layer

• Use same communication channel between


hosts for several logical communication
processes
• How does Mux/DeMux work?
– Sockets: doors between process & host
– UDP socket: (dest. IP, dest. Port)
– TCP socket: (src. IP, src. port, dest. IP, dest. Port)
Network Layer 182
Connectionless demux
• UDP socket identified by two-tuple:
– (dest IP address, dest port number)
• When host receives UDP segment:
– checks destination port number in segment
– directs UDP segment to socket with that port number
• IP datagrams with different source IP addresses and/or source
port numbers directed to same socket

Network Layer 183


Connection-oriented demux
• TCP socket identified by 4- • Server host may support
tuple: many simultaneous TCP
– source IP address sockets:
– source port number – each socket identified by its
– dest IP address own 4-tuple
– dest port number • Web servers have different
• recv host uses all four sockets for each connecting
values to direct segment to client
appropriate socket – non-persistent HTTP will have
different socket for each
request

Network Layer 184


UDP: User Datagram Protocol [RFC 768]

• “no frills,” “bare bones” Internet transport protocol


• “best effort” service, UDP segments may be:
– lost
– delivered out of order to app
• Why use UDP?
– No connection establishment cost (critical for some
applications, e.g., DNS)
– No connection state
– Small segment headers (only 8 bytes)
– Finer application control over data transmission
Network Layer 185
UDP Segment Structure
• often used for streaming
32 bits
multimedia apps
– loss tolerant Length, in source port # dest port #
– rate sensitive bytes of UDP length checksum
segment,
• other UDP uses including
– DNS header
– SNMP
• reliable transfer over UDP: add Application
reliability at application layer data
– application-specific error (message)
recovery!

UDP segment format

Network Layer 186


TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
valid acknowledgement number (not segments!)
head not
PSH: push data now len used UAP R S F Receive window
(generally not used) # bytes
checksum Urg data pnter
rcvr willing
RST, SYN, FIN: to accept
Options (variable length)
connection estab
(setup, teardown
commands)
application
Internet data
checksum (variable length)
(as in UDP)

Network Layer 187


Sequence and Acknowledgement Number
• TCP views data as unstructured, but ordered
stream of bytes.
• Sequence numbers are over bytes, not
segments
• Initial sequence number is chosen randomly
• TCP is full duplex – numbering of data is
independent in each direction
• Acknowledgement number – sequence
number of the next byte expected from the
sender
• ACKs are cumulative
Network Layer 188
TCP seq. #’s and ACKs
Seq. #’s:
Host A Host B
– byte stream “number”
of first byte in 1000 byte Seq=4
2, ACK
segment’s data data =79, d
ata
ACKs: host ACKs
– seq # of next byte receipt of
, n o data
043 data
expected from other 9 , A CK=1
7
side Seq=

– cumulative ACK
Host sends
Q: how receiver handles out- another Seq=1
043, A
of-order segments 500 bytes CK=79
, data
– A: TCP spec doesn’t
a
say, - up to n o dat
K =1 544,
implementor C time
79, A
Seq=

Network Layer 189


TCP reliable data transfer
• Retransmissions
TCP creates rdt service
are triggered
on top by:
of IP’s unreliable service
• – timeoutsegments
Pipelined events
– duplicate acks
• Cumulative acks
•• Initially
TCP usesconsider simplified TCPtimer
single retransmission sender:
– ignore duplicate acks
– ignore flow control, congestion control

Network Layer 190


TCP sender events:
data rcvd from app: timeout:
• Create segment with seq # • retransmit segment that
• seq # is byte-stream caused timeout
number of first data byte • restart timer
in segment Ack rcvd:
• start timer if not already • If acknowledges
running (think of timer as previously unacked
for oldest unacked segments
segment) – update what is known to be
• expiration interval: acked
TimeOutInterval – start timer if there are
outstanding segments

Network Layer 191


NextSeqNum = InitialSeqNum
SendBase = InitialSeqNum

loop (forever) { TCP


switch(event) sender
(simplified)
event: data received from application above
create TCP segment with sequence number NextSeqNum
if (timer currently not running)
start timer Comment:
pass segment to IP • SendBase-1: last
NextSeqNum = NextSeqNum + length(data) cumulatively
ack’ed byte
event: timer timeout Example:
retransmit not-yet-acknowledged segment with • SendBase-1 = 71;
smallest sequence number y= 73, so the rcvr
start timer wants 73+ ;
y > SendBase, so
event: ACK received, with ACK field value of y that new data is
if (y > SendBase) { acked
SendBase = y
if (there are currently not-yet-acknowledged segments)
start timer
Network Layer 192
}
TCP Flow Control
flow control
sender won’t overflow
• receive side of TCP receiver’s buffer by
connection has a receive transmitting too much,
buffer: too fast

• speed-matching service:
matching the send rate to
the receiving app’s drain
rate
 app process may be slow
at reading from buffer

Network Layer 193


TCP Flow control: how it works
• Rcvr advertises spare room
by including value of
RcvWindow in segments
• Sender limits unACKed
data to RcvWindow
(Suppose TCP receiver discards – guarantees receive buffer
out-of-order segments) doesn’t overflow
• spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd -
LastByteRead]

Network Layer 194


Silly Window Syndrome
• Recall: TCP uses sliding window
• “Silly Window” occurs when small-sized
segments are transmitted, resulting in
inefficient use of the network pipe
• For e.g., suppose that TCP sender generates
data slowly, 1-byte at a time
• Solution: wait until sender has enough data to
transmit – “Nagle’s Algorithm”

Network Layer 195


Nagle’s Algorithm
1. TCP sender sends the first piece of data
obtained from the application (even if data is
only a few bytes).

2. Wait until enough bytes have accumulated in


the TCP send buffer or until an ACK is received.

3. Repeat step 2 for the remainder of the


transmission.

Network Layer 196


Silly Window Continued …
• Suppose that the receiver consumes data
slowly
– Receive Window opens slowly, and thus sender is
forced to send small-sized segments
• Solutions
– Delayed ACK
– Advertise Receive Window = 0, until reasonable
amount of space available in receiver’s buffer

Network Layer 197


TCP Connection Management
Recall: TCP sender, receiver Three way handshake:
establish “connection” before
exchanging data segments Step 1: client host sends TCP SYN
• initialize TCP variables: segment to server
– seq. #s – specifies initial seq #
– buffers, flow control info – no data
(e.g. RcvWindow) Step 2: server host receives SYN,
• client: connection initiator replies with SYNACK segment
Socket clientSocket = new – server allocates buffers
Socket("hostname","port
– specifies server initial seq. #
number");
Step 3: client receives SYNACK, replies
• server: contacted by client
with ACK segment, which may
Socket connectionSocket =
welcomeSocket.accept(); contain data

Network Layer 198


TCP Connection Establishment

CLOSED client server

Passive open Active open; SYN,


s eq=x
SYN
SYN/SYN+ACK LISTEN
= x +1
SYN_SENT q = y, ac k
SYN_RCVD s e
+ A CK,
SYN
SYN+ACK/ACK ACK,
ack=y
ACK + 1
Established

Solid line for client


Dashed line for server

Network Layer 199


Principles of Congestion Control
• Congestion: informally: “too many sources sending
too much data too fast for network to handle”
• Different from flow control!
• Manifestations:
– Packet loss (buffer overflow at routers)
– Increased end-to-end delays (queuing in router buffers)
• Results in unfairness and poor utilization of network
resources
– Resources used by dropped packets (before they were lost)
– Retransmissions
– Poor resource allocation at high load

Network Layer 200


Historical Perspective
• October 1986, Internet had its first congestion
collapse
• Link LBL to UC Berkeley
– 400 yards, 3 hops, 32 Kbps
– throughput dropped to 40 bps
– factor of ~1000 drop!
• Van Jacobson proposes TCP Congestion
Control:
– Achieve high utilization
– Avoid congestion
– Share bandwidth

Network Layer 201


Congestion Control: Approaches
• Goal: Throttle senders as needed to ensure
load on the network is “reasonable”
• End-end congestion control:
– no explicit feedback from network
– congestion inferred from end-system observed loss,
delay
– approach taken by TCP
• Network-assisted congestion control:
– routers provide feedback to end systems
– single bit indicating congestion (e.g., ECN)
– explicit rate sender should send at

Network Layer 202


TCP Congestion Control: Overview
• end-end control (no network assistance)
• Limit the number of packets in the network to
window W
• Roughly,
W
rate = Bytes/sec
RTT

• W is dynamic, function of perceived network


congestion
Network Layer 203
Slow Start
• “Slow Start” is used to reach sender receiver
the equilibrium state cwnd
• Initially: W = 1 (slow start) 1 data
segment
• On each successful ACK:
ACK
WW+1 2
• Exponential growth of W
each RTT: W  2 x W 3
4
• Enter CA when
W >= ssthresh 5
6
• ssthresh: window size after 7
8
which TCP cautiously probes
for bandwidth

Network Layer 204


Congestion Avoidance
• Starts when sender receiver
data
W  ssthresh 1
segment

• On each successful ACK


2
ACK:
W  W+ 1/W
3
• Linear growth of W
each RTT:
4
WW+1

Network Layer 205


CA: Additive Increase, Multiplicative
Decrease
• We have “additive increase” in the absence of
loss events
• After loss event, decrease congestion window
by half – “multiplicative decrease”
– ssthresh = W/2
– Enter Slow Start

Network Layer 206


Detecting Packet Loss
• Assumption: loss 10
11

indicates congestion 12
13
X

• Option 1: time-out
14
15
16

– Waiting for a time-out 10


17

can be long! 11
11

11

• Option 2: duplicate
11

ACKs
Sender Receiver
– How many? At least 3.
Network Layer 207
Fast Retransmit
• Wait for a timeout is quite long
• Immediately retransmits after 3 dupACKs
without waiting for timeout
• Adjusts ssthresh
ssthresh  W/2
• Enter Slow Start
W=1

Network Layer 208


How to Set TCP Timeout Value?
• longer than RTT
– but RTT varies
• too short: premature timeout
– unnecessary retransmissions
• too long: slow reaction to segment loss

Network Layer 209


How to Estimate RTT?

• SampleRTT: measured time from segment


transmission until ACK receipt
– ignore retransmissions
• SampleRTT will vary, want estimated RTT
“smoother”
– average several recent measurements, not just
current SampleRTT

Network Layer 210


Multiplicative decrease

Network Layer 211


Network Layer 212
Network Layer 213
Network Layer 214
Network Layer 215
Network Layer 216
Network Layer 217
Network Layer 218
Network Layer 219
Network Layer 220
Quality of Service

Flow Characteristics

Flow Classes

Network Layer 221


Techniques to Improve QoS

Scheduling

Traffic Shaping

Resource Reservation

Admission Control

Network Layer 222


Flow characteristics

Network Layer 223


FIFO queue

Network Layer 224


Priority queuing

Network Layer 225


Weighted fair queuing

Network Layer 226


Leaky bucket

Network Layer 227


Leaky bucket implementation

Network Layer 228


A leaky bucket algorithm shapes bursty
traffic into fixed-rate traffic by
averaging the data rate. It may drop the
packets if the bucket is full.

Network Layer 229


Token bucket

Network Layer 230


The token bucket allows bursty traffic at
a regulated maximum rate.

Network Layer 231


Integrated Services

Signaling

Flow Specification

Admission

Service Classes

RSVP
Network Layer 232
Integrated Services is a flow-based
QoS model designed for IP.

Network Layer 233


Path messages

Network Layer 234


Resv messages

Network Layer 235


Reservation merging

Network Layer 236


Reservation styles

Network Layer 237


Differentiated Services

An Alternative to
Integrated Services

Network Layer 238


Differentiated Services is a class-based
QoS model designed for IP.

Network Layer 239


DS field

Network Layer 240


Traffic conditioner

Network Layer 241

Das könnte Ihnen auch gefallen