0% found this document useful (0 votes)
2 views

Chapter_4 Network Layer-IP datagram and addressing.ppt

Chapter 4 covers the Network Layer, focusing on the Internet Protocol (IP), including datagram formats, fragmentation, and addressing methods such as IPv4 and IPv6. It discusses the structure of IP datagrams, the process of fragmentation and reassembly, and the concept of subnets and CIDR (Classless Inter-Domain Routing). The chapter also highlights the importance of IP addressing and the transition from classful to classless addressing.

Uploaded by

Osama Rashad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter_4 Network Layer-IP datagram and addressing.ppt

Chapter 4 covers the Network Layer, focusing on the Internet Protocol (IP), including datagram formats, fragmentation, and addressing methods such as IPv4 and IPv6. It discusses the structure of IP datagrams, the process of fragmentation and reassembly, and the concept of subnets and CIDR (Classless Inter-Domain Routing). The chapter also highlights the importance of IP addressing and the transition from classful to classless addressing.

Uploaded by

Osama Rashad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Chapter 4

Network Layer:
Datagram and
Addressing

Network Layer: Addressing 4-0


Chapter 4: outline
4.1 Overview of Network layer
4.2 IP: Internet Protocol
• Packets (Datagrams)
• IP datagram format
• fragmentation
• IPv4 addressing
• Dynamic Host Configuration
Protocol (DHCP)
• network address translation
(NAT)
• IPv6

Network Layer: Addressing 4-0


Network layer
application
● transport segment from transport
network
sending to receiving host data link
physical
network
network
● on sending side network data link
physical
data link
physical
encapsulates segments data link
physical network network

into datagrams data link


physical
data link
physical

● on receiving side, delivers network network

segments to transport
data link data link
physicalnetwork physical

layer data link


physical
application
● network layer protocols in network
data link network
transport
network
every host, router network
data link
physical data link
physical
data link
physical

● router examines header physical

fields in all IP datagrams


passing through it
Network Layer: Addressing 4-0
Packet (Datagram(
• no call setup at network layer
• routers: no state about end-to-end
connections
• no network-level concept of “connection”
• packets forwarded using destination host
address
application application
transport transport
network 1. send packets 2. receive packets network
data link data link
physical physical

Network Layer: Addressing 4-0


IP datagram format
IP protocol version 32
number total
bits datagram
header type of
ver head lengt length (bytes)
length . service for
“type” (bytes)
of data h
fragment
lenidentifier flgs
16-bit fragmentation
offset
max number time uppe /
header
remaining hops to r reassembly
checksum
(decremented at live layer
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload options (if e.g.
to any) timestamp,
data record route
how much overhead?
(variable length, taken, specify
● 20 bytes of TCP
typically a TCP list of routers
● 20 bytes of IP
or UDP to visit.
● = 40 bytes + app
layer overhead segment)

Network Layer: Addressing 4-0


IP fragmentation, reassembly
● network links have MTU
(max.transfer size) -
largest possible link-level fragmentation:
frame … in: one large datagram
• different link types, out: 3 smaller datagrams
different MTUs
● large IP datagram divided
(“fragmented”) within net reassembly
• one datagram becomes
several datagrams
• “reassembled” only at …
final destination
• IP header bits used to
identify, order related
fragments Network Layer: Addressing 4-0
IP fragmentation, reassembly
length ID fla offset
example: =4000 = x g =0
● 4000 byte datagram =0
one large datagram
● MTU = 1500 bytes becomes
several smaller datagrams
1480 bytes in length ID fla offset
data field =1500 = x g =0
+ 20 header = 1500 bytes
=1
offset = length ID fla offset
1480/8 =1500 = x g =185
=1
length ID fla offset
=1040 = x g =370
=0

Network Layer: Addressing 4-0


IP addressing: introduction
223.1.1.1

● IP address: 32-bit 223.1.2.1


identifier for host, router
interface 223.1.1.2
223.1.1.4 223.1.2.9
● interface: connection
between host/router and
physical link 223.1.1.3
223.1.3.27
223.1.2.2
• router’s typically have
multiple interfaces
• host typically has one or
two interfaces (e.g., wired 223.1.3.1 223.1.3.2

Ethernet, wireless 802.11)


● IP addresses associated
with each interface 223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 1 1

Network Layer: Addressing 4-0


IP addressing: introduction
223.1.1.1

Q: how are interfaces 223.1.2.1


actually connected?
A: we’ll learn about that223.1.1.2 223.1.1.4 223.1.2.9

in chapter 5, 6.
223.1.3.27
223.1.1.3
223.1.2.2

A: wired Ethernet interfaces


connected by Ethernet switches
223.1.3.1 223.1.3.2

A: wireless WiFi interfaces


connected by WiFi base station

Network Layer: Addressing 4-0


Notes

An IPv4 address is 32 bits long.

The IPv4 addresses are unique and


universal.

The address space of IPv4 is


23 or 4,294,967,296.
2

Network Layer: Addressing 4-0


Figure 4.1 Dotted-decimal notation and binary notation for an IPv4 address

IP : Internet protocol

Network Layer: Addressing 4-0


Example 4.1

Change the following IPv4 addresses from


binary notation to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent
decimal number (see Appendix B) and add dots for
separation.

Network Layer: Addressing 4-0


Example 4.2

Find the error, if any, in the following IPv4 addresses.

Solution
a.There must be no leading zero (045)
b.There can be no more than four numbers.
c.Each number needs to be less than or equal to 255
d.A mixture of binary notation and dotted-decimal
notation is not allowed.
Network Layer: Addressing 4-0
Note

In classful addressing, the address


space is divided into five classes: A,
B, C, D, and E.

Network Layer: Addressing 4.0


Figure 4.2 Finding the classes in binary and dotted-decimal notation

Network Layer: Addressing 4.0


Example 2.4

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

Solution
a.The first bit is 0 . This is a class A address.
b.The first 3 bits are 110; the class is C.
c.The first byte is 14; the class is A.
d.The first byte is 252 ; the class is E .

Network Layer: Addressing 2.0


Table 4.1 Number of blocks and block size in classful IPv4 addressing

Network Layer: Addressing 4.0


Example 4.4

Figure 4.3 shows a block of addresses, in both binary and


dotted-decimal notation, granted to a small business that
needs 16 addresses. IP 205.16.37.32

Figure 4.3 A block of 16 addresses granted to a small organization

Network Layer: Addressing 4.0


Table 4.2 Default masks for classful addressing

CIDR : Classless inter-domain routing

Network Layer: Addressing 4.0


Notes

In classful addressing, a large part of the


available addresses were wasted.

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.

Network Layer: Addressing 4-.0


Notes

In IPv4 addressing, a block of


addresses can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the addresses and
the /n defines the mask.

Network Layer: Addressing 4.0


Note

The first address in the block can be


found by setting the rightmost
32 − n bits to 0s.

The last address in the block can be


found by setting the rightmost
32 − n bits to 1s.
Network Layer: Addressing 4.0
Example 4.5

A block of addresses is granted to a small organization.


We know that one of the addresses is 205.16.37.39 /28
What is the first address in the block?

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 00100000
or 205.16.37.32.
This is actually the block shown in Figure 4.3.

Network Layer: Addressing 4.0


Example 4.6

Find the last address for the block in Example 4.5

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or 205.16.37.47
This is actually the block shown in Figure 43.

Network Layer: Addressing 4..0


Note

The number of addresses in the block


can be found by using the formula
232 - n.

Network Layer: Addressing 4. 0


Example 2.8

Find the number of addresses in Example 2.6.

Solution
The value of n is 28 , which means that
number of addresses is 232-28 = 16

Network Layer: Addressing 2.0


Figure 4.4 A network configuration for the block 205.16.37.32 /28

Network Layer: Addressing 4.0


Figure 4.5 Configuration and addresses in a subnetted network

Network Layer: Addressing 4.0


Subnets IP: 223.1.1.0

● IP address: 223.1.1.1
• subnet part - high order
bits 223.1.1.2 223.1.2.1
223.1.1.4 223.1.2.9
• host part - low order bits
● what’s a subnet ? 223.1.1.3 223.1.3.27
223.1.2.2

• device interfaces with


subne
same subnet part of IP t
address 223.1.3.1 223.1.3.2
• can physically reach
each other without
intervening router network consisting of 3
subnets

Network Layer: Addressing 4-0


Subnets IP: 223.1.1.0
Netmask: 11111111.11111111.11111111.00000000
SubNet Host

223.1.1.0/2
recipe 4 223.1.2.0/2
● to determine the 223.1.1.1 4
subnets, detach each 223.1.1.2 223.1.2.1
interface from its host 223.1.1.4 223.1.2.9
or router, creating
223.1.2.2
islands of isolated 223.1.1.3 223.1.3.27
networks subne
● each isolated network t
is called a subnet 223.1.3.1 223.1.3.2

223.1.3.0/2
4
Network Layer: Addressing 4-0
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: Addressing 4-0


IP addressing: CIDR
CIDR: Classless InterDomain Routing
• subnet portion of address of arbitrary length
• address format: a.b.c.d/x, where x is # bits in
subnet portion of address

subne hos
t t
11001000 00010111
part 00010000 part
00000000
200.23.16.0/2
3

Network Layer: Addressing 4-0


IP addressing: CIDR

Network size ______________________Net Mask ____________‫قناع الشبكة‬


22= 4 ( 11111111.11111111.11111111.11111100) 255.255.255.252 /30
23= 8 ( 11111111.11111111.11111111.11111000) 255.255.255.248 /29
24= 16 ( 11111111.11111111.11111111.11110000) 255.255.255.240 /28
25= 32 ( 11111111.11111111.11111111.11100000) 255.255.255.224 /27
26= 64 ( 11111111.11111111.11111111.11000000) 255.255.255.192 /26
27= 128 ( 11111111.11111111.11111111.10000000) 255.255.255.128 /25
28 =256 ( 11111111.11111111.11111111.00000000) 255.255.255.0 /24
29= 512 ( 11111111.11111111.11111110.00000000) 255.255.254.0 /23
210= 1024 ( 11111111.11111111.11111100.00000000) 255.255.252.0 /22
211= 2048 ( 11111111.11111111.11111000.00000000) 255.255.248.0 /21
212= 4096 ( 11111111.11111111.11110000.00000000) 255.255.240.0 /20
..
..
Network Layer: Addressing 4-0
IP addresses: how to get one?
Q: How does a host get IP address?

● hard-coded by system admin in a file


• Windows: 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”

Network Layer: Addressing 4-0


DHCP client-server scenario

223.1.1.0/24
DHCP
server
223.1.1.1 223.1.2.1

223.1.1.2 arriving DHCP


223.1.1.4 223.1.2.9
client needs
address in this
223.1.1.3 223.1.3.27
223.1.2.2 network

223.1.2.0/24

223.1.3.1 223.1.3.2

223.1.3.0/24

Network Layer: Addressing 4-0


DHCP client-server scenario
DHCP server: 223.1.2.5 DHCP discover arrivin
src : 0.0.0.0, 68
g
Broadcast: is there a DHCP
dest.: 255.255.255.255,67
client
server
yiaddr:out0.0.0.0
there?
transaction ID: 654

DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server! Here’s an IP address
yiaddrr: 223.1.2.4
transaction
you canID:use
654
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255,
Broadcast: 67
OK. I’ll take
yiaddrr: 223.1.2.4
that IP address!
transaction ID: 655
lifetime: 3600 secs

DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255,
Broadcast: OK. You’ve 68 got
yiaddrr: 223.1.2.4
that IP address!
transaction ID: 655
lifetime: 3600 secs
Network Layer: Addressing 4-0
IP addresses: how to get one?
Q: how does network get subnet part of IP addr?
A: gets allocated portion of its provider ISP’s address
space
11111111.11111111.11110000.10000000
Subnet Host

ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20

Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23


Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23
Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23
... ….. …. ….
Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23

Network Layer: Addressing 4-0


Hierarchical addressing: route aggregation
hierarchical addressing allows efficient advertisement of routing
information:

Organization
0
200.23.16.0/23
Organization
1 “Send me
200.23.18.0/23 anything
Organization with addresses
2 200.23.20.0/23 . Fly-By-Night- beginning
.. 200.23.16.0/20”
. ISP
Interne
Organization
.. t
7
200.23.30.0/23
“Send me
ISPs-R-
anything
Us
with addresses
beginning
199.31.0.0/16”

Network Layer: Addressing 4-0


Hierarchical addressing: more specific routes

ISPs-R-Us has a more specific route to Organization 1

Organization
0
200.23.16.0/23

“Send me
anything
Organization with addresses
2 200.23.20.0/23 . Fly-By-Night- beginning
.. 200.23.16.0/20”
..
ISP
Interne
Organization . t
7
200.23.30.0/23
“Send me anything
ISPs-R-
with addresses
Us
Organization beginning
1 199.31.0.0/16
200.23.18.0/23
or 200.23.18.0/23”

Network Layer: Addressing 4-0


IP addressing: the last word...

Q: how does an ISP get block of addresses?


A: ICANN: Internet Corporation for Assigned
Names and Numbers http://www.icann.org/
• allocates addresses
• manages DNS
• assigns domain names, resolves disputes

Network Layer: Addressing 4-0


Table 4.3 Addresses for private networks

16,777,216
1,048,576
65,536

Network Layer: Addressing 4.0


NAT: network address translation
rest of local network
Interne (e.g., home
t network) 10.0.0.1
10.0.0/24
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 destination in this network
source NAT IP address: have 10.0.0/24 address for
138.76.29.7,different source source, destination (as usual)
port numbers
Network Layer: Addressing 4-0
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: Addressing 4-0


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.186, 80
source addr from ……
10.0.0.1, 3345 to ……
138.76.29.7, S: 10.0.0.1, 3345
5001, D: 128.119.40.186, 80
10.0.0.1
updates table 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: Addressing 4-0


IPv6: motivation
● 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: Addressing 4-0


Note

An IPv6 address is 128 bits long.

Network Layer: Addressing 4.0


Figure 2.14 IPv6 address in binary and hexadecimal colon notation

Network Layer: Addressing 4.0


Figure 2.15 Abbreviated IPv6 addresses

Network Layer: Addressing 4.0


Example:

● Expand the address 0:15::1:12:1213 to its original.

Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find
how many 0s we need to replace the double colon.

This means that the original address is.

Network Layer: Addressing 4.0


IPv6 datagram format
priority: identify priority among datagrams in
flow
flow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
next header:veridentify
pri
upper layer protocol for data
flow
payload label
next hop
len hdr
source limit
address
(128 bits)
destination
address
(128 bits)
dat
a

32
Network Layer: Addressing 4-0
bits
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: Addressing 4-0


Transition from IPv4 to IPv6
● not all routers can be upgraded simultaneously
• no “flag days”
• how will network operate with mixed IPv4 and
IPv6 routers?
● tunneling: IPv6 datagram carried as payload in IPv4
datagram among IPv4 routers

IPv4 header fields IPv6 header


IPv4 payload
IPv4 source, dest addr fieldssource dest
IPv6
addr
UDP/TCP
payload

IPv6
IPv4 datagram
datagram
Network Layer: Addressing 4-0
Tunneling
A B IPv4 tunnel E F
connecting IPv6
logical
routers
view: IPv6 IPv6 IPv6 IPv6

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

Network Layer: Addressing 4-0


Tunneling
A B IPv4 tunnel E F
connecting IPv6
logical
routers
view: 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: src: A
dest:
dest: F dest: F
EFlow: X EFlow: 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 IPv6
inside Network Layer: Addressing 4-0
inside
IPv4 IPv4

You might also like