Chap 3 Network Layer
Chap 3 Network Layer
Chap 3 Network Layer
SWITCHING
• Circuit Switching: a physical circuit (or
channel) is established between the source
and destination of the message before the
delivery of the message
• Packet Switching: the message is first divided
into manageable packets at the source before
being transmitted, packets are assembled at
the destination
Packet Switching
• Packet at the source is divided into
manageable packets, normally called
datagrams
• Packet Switching services:
– Connectionless Service
– Connection-Oriented Service
Connectionless Service
• Treats each packet independently
• Packets in a message may or may not travel
the same path to their destination
• Network layer is only responsible for delivery
of packets from the source to the destination
Connectionless Service
Forwarding process in a router when used in
a connectionless network
Delay In Connectionless Network
In a connectionless packet-switched network, the
forwarding decision
is based on the destination address of the packet
Connection-Oriented Service
• There is a relation between all packets belonging
to a message
• Before all datagrams in a message can be sent, a
virtual connection should be set up to define the
path for the datagrams
• The datagrams follow the same path
• It must also contain a flow label, a virtual circuit
identifier that defines the virtual path the packet
should follow
Connection-Oriented Service
Virtual Path and Virtual Circuit
Virtual Path Identifier and Virtual Circuit
Identifier
Forwarding process in a router when used in
a connection-oriented network
Setup Phase: Request
Setup Phase: Acknowledgement
Data Transfer Phase
Teardown Phase
• Source A, after sending all packets to B, sends
a special packet called a teardown packet
• Destination B responds with a confirmation
packet
• Routers delete the corresponding entry from
their tables.
Delay In Connection-Oriented Network
Position of IP in TCP/IP protocol suite
DATAGRAM
01000010
Solution
There is an error in this packet. The 4 left-most bits (0100) show
the version, which is correct. The next 4 bits (0010) show the
header length; which means (2 × 4 = 8), which is wrong. The
minimum number of bytes in the header must be 20. The packet
has been corrupted in transmission.
Example 2
Solution
The HLEN value is 8, which means the total number of bytes in
the header is 8 × 4 or 32 bytes. The first 20 bytes are the base
header, the next 12 bytes are the options.
Example 3
Solution
The HLEN value is 5, which means the total number of bytes in
the header is 5 × 4 or 20 bytes (no options). The total length is
40 bytes, which means the packet is carrying 20 bytes of data
(40 − 20).
Example 4
45000028000100000102 . . .
How many hops can this packet travel before being dropped?
The data belong to what upper layer protocol?
Solution
To find the time-to-live field, we skip 8 bytes (16 hexadecimal
digits). The time-to-live field is the ninth byte, which is 01. This
means the packet can travel only one hop. The protocol field is
the next byte (02), which means that the upper layer protocol is
IGMP
FRAGMENTATION:
The format and size of a frame depend on the protocol used by the
physical network. A datagram may have to be fragmented to fit the
protocol regulations.
Solution
If the M bit is 0, it means that there are no more fragments; the
fragment is the last one. However, we cannot say if the original
packet was fragmented or not. A nonfragmented packet is
considered the last fragment.
Example 6
Solution
If the M bit is 1, it means that there is at least one more
fragment. This fragment can be the first one or a middle one, but
not the last one. We don’t know if it is the first one or a middle
one; we need more information (the value of the fragmentation
offset)
Example 7
Solution
Because the M bit is 1, it is either the first fragment or a middle
one. Because the offset value is 0, it is the first fragment.
Example 8
A packet has arrived in which the offset value is 100. What is the
number of the first byte? Do we know the number of the last
byte?
Solution
To find the number of the first byte, we multiply the offset value
by 8. This means that the first byte number is 800. We cannot
determine the number of the last byte unless we know the length
of the data.
Example 9
A packet has arrived in which the offset value is 100, the value of
HLEN is 5 and the value of the total length field is 100. What is
the number of the first byte and the last byte?
Solution
The first byte number is 100 × 8 = 800. The total length is 100
bytes and the header length is 20 bytes (5 × 4), which means that
there are 80 bytes in this datagram. If the first byte number is
800, the last byte number must be 879.
IP Addresses:
Classful Addressing
An IP address is a 32-bit address.
Solution
We replace each decimal number with its binary equivalent:
a. 01101111 00111000 00101101 01001110
b. 11011101 00100010 00000111 01010010
c. 11110001 00001000 00111000 00001100
d. 01001011 00101101 00100010 01001110
Example 3
Solution
a. There are no leading zeroes in dotted-decimal notation (045).
b. We may not have more than four numbers in an IP address.
c. In dotted-decimal notation, each number is less than or equal
to 255; 301 is outside this range.
d. A mixture of binary notation and dotted-decimal notation is not
allowed.
Example 4
Solution
We replace each group of 4 bits with its hexadecimal
equivalent Note that hexadecimal notation normally has no
added spaces or dots; however, 0X (or 0x) is added at the
beginning or the subscript 16 at the end to show that the
number is in hexadecimal.
a. 0X810B0BEF or 810B0BEF16
b. 0XC1831BFF or C1831BFF16
Finding the class in binary
notation
Example 6
Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C address.
c. The first bit is 0; the second bit is 1. This is a class B address.
d. The first 4 bits are 1s. This is a class E address..
Figure 4.5 Finding the class in decimal notation
Example 7
Solution
a. The first byte is 227 (between 224 and 239); the class is D.
b. The first byte is 193 (between 192 and 223); the class is C.
c. The first byte is 14 (between 0 and 127); the class is A.
d. The first byte is 252 (between 240 and 255); the class is E.
e. The first byte is 134 (between 128 and 191); the class is B.
Netid and hostid
Blocks in class A
Blocks in class B
Blocks in class C
Class D addresses are used for
multicasting; there is only one block in
this class.
Given the network address 17.0.0.0, find the class, the block,
and the range of the addresses.
Solution
The class is A because the first byte is between 0 and 127. The
block has a netid of 17. The addresses range from 17.0.0.0 to
17.255.255.255.
Example 10
Given the network address 132.21.0.0, find the class, the block,
and the range of the addresses.
Solution
The class is B because the first byte is between 128 and 191.
The block has a netid of 132.21. The addresses range from
132.21.0.0 to 132.21.255.255.
Example 11
Solution
The class is C because the first byte is between 192
and 223. The block has a netid of 220.34.76. The
addresses range from 220.34.76.0 to 220.34.76.255.
Example 12
Solution
We can subtract the first address from the last
address in base 256 . The result is 0.0.3.255 in this
base. To find the number of addresses in the range
(in decimal), we convert this number to base 10 and
add 1 to the result.
Example 13
Solution
We convert the number of addresses minus 1 to base
256, which is 0.0.0.31. We then add it to the
first address to get the last address
Extracting Information in a Block
• The number of addresses in the block, N, can
be found using N = 232−n.
• To find the first address, we keep the n
leftmost bits and set the (32− n) rightmost bits
all to 0s.
• To find the last address, we keep the n
leftmost bits and set the (32 − n) rightmost
bits all to 1s.
Extracting Information in a Block
Example
Solution
The default mask is 255.0.0.0, which means that only the first
byte is preserved and the other 3 bytes are set to 0s. The
network address is 23.0.0.0.
Example
Solution
The default mask is 255.255.0.0, which means that the first 2
bytes are preserved and the other 2 bytes are set to 0s. The
network address is 132.6.0.0.
Example
Solution
The default mask is 255.255.255.0, which means that the first 3
bytes are preserved and the last byte is set to 0. The network
address is 201.180.56.0.
Note:
Class A address
Example of loopback address
IP with first byte as 127 is used for the loopback address used
to test the software on a machine . Class A address.
Private Addresses