How IP address works

62
TCP/IP Addressing TCP/IP Addressing Demystified Demystified - Edited by Alien Coders Team Contributed by Souvik Official Website : http://www.aliencoders.com Facebook Page : https://www.facebook.com/aliencoders

description

The details of TCP/IP, how its working under the hood with minimal presentation. It was contributed by Souvik (One of my net friend). Thanks Souvik

Transcript of How IP address works

Page 1: How IP address works

TCP/IP Addressing DemystifiedTCP/IP Addressing Demystified - Edited by Alien Coders

Team

Contributed by Souvik

Official Website: http://www.aliencoders.com

Facebook Page: https://www.facebook.com/aliencoders

Page 2: How IP address works

What you will learn

• How internet addressing works

• Internet Addressing

• Role played by Routing and addressing

• ARP

• TCP/UDP

• IPv6 into the picture

Page 3: How IP address works

• The Internet Protocol (IP) enables communications across a vast and heterogeneous collection of networks.

• The Internet offers two basic communication services that operate on top of IP:

• TCP Transmission control protocol i.e reliable stream service.

• UDP User datagram Protocol.

Page 4: How IP address works

The TCP header contains the port number of the client process and the well known port 80 for the HTTP server process.

The IP network address are the logical address because they are defined in terms of logical topology of the routers and the end systems.

Ethernet LAN frames contains physical address that identify the physical endpoints for the sender and the receiver.

Page 5: How IP address works

• The network interface layer is particularly concerned with the protocols that are used to access the intermediate networks.

• At each gateway the network protocol is used to encapsulate the IP packet into a packet or frame of the underlying link.

• The router must determine the next hop in the route to the destination and then encapsulate the IP packet or frame of the type of the next network or link

Page 6: How IP address works

IP Packet

Page 7: How IP address works

• Total Length : With 16 bits , the max packet length = 65,535

• Protocol TCP =6 ; UDP =17 ; ICMP = 1

• Options : Security level , Route to be taken by the packet

• Padding : To make the header field a multiple of 32 bit word.

Page 8: How IP address works

Network

Internet AddressingHost

An IP address is divided into 2 parts: a) network part 2) host part .

The part of a public IP address that identifies the network is internationally controlled by the Network Information Center (NIC) located in the Stanford Research Institute in California.

The part that identifies the host is controlled locally at a network level.

Page 9: How IP address works

Internet Addressing

An Internet address is four octets (i.e. 32 bits) long.

The first few bits in the network part of the address helps interpret the address.These bits indicate the class of the address.

When a system wants to communicate over the internet they need to have a public address.

This public address has to be purchased from NIC in Stanford.

Page 10: How IP address works

Address classes

There are five Internet address classes. They are : Class A / B / C / D / E .

Class A addressing is used for very large networks, that is networks which will have a large number of hosts attached to them.

For class A the MSB is 0.

Each pure class A network can support (224-2) hosts. One address each being reserved for network address (all 0 ) and all one for broad cast.

Page 11: How IP address works

Class A

24 bits

Host ID

The first bit is 0 and next 7 bits called the Net ID identifies the network . The next field contains the host ID, which identifies the particular host within the specified network.

In a class A address it's 24 bits long and therefore allows for almost 17 million hosts on a network.

For example 10.200.20.5 is a class A address

Page 12: How IP address works

Class B

Class B addressing is used for medium-sized networks.

If the first two bits in the address are 10, it's a class B address. 14 bits for network Ids and 16 bits for host Ids allowing about 16,000 networks and 64,000 hosts for each network.

The range of first octet of class B address is 128 –191.i.e 128.0.0.0 to 191.255.0.0

Page 13: How IP address works

Class C

The next address class is class C, probably the most common network class. If the first 3 bits in the address are 110, the address is a class C address.

The net ID is 21 bits long and the host ID is 8 bits long, allowing about 21 million networks and 254 hosts per network.

The range of class C Network is 192.0.0.0 – 223.255.255.0

The 192.0.0.2555 is the broadcast address and 192.0.0.0 is the network address.

Page 14: How IP address works

Class D

Class D addressing is used for multicasting a number of hosts for applications like audio and video conferencing.

Class D networks have the first 4 bits in the network part = 1110.

The first octet ranges from 224 – 239.

All the addressees from 224.0.0.0 to 239.255.255.255 can be used as multicast address.

Page 15: How IP address works

All students in Internet Class!

Page 16: How IP address works

• A host ID that contains all 1s is meant to broadcast the packet to all hosts specified by the network.

• If the network ID also contains all 1s the packet is broadcast on the local network.

• A host ID that contains all 0s refers to the network specified by the network ID , rather than to a host.

• A source may send all 0s in the source address while trying to find out the correct IP address. The machine is then identified by its MAC address.

Page 17: How IP address works

• These are the IP address ranges reserved for private networks within organizations.

• These addresses will not be allocated by NIC as public IP address for the internet.

• There is no problem of clash because when a packet goes outside the organization the local IP address gets translated into into the public IP address purchased by the organizations.

Page 18: How IP address works

Private Addressing

– Class A:• 10.0.0.0 to 10.255.255.255---- 1 Class A network

– Class B:• 172.16.0.0 to 172.31.255.255 ---- 16 contiguous Class B networks

– Class C:• 192.168.0.0 to 192.168.255.255--- 255 contiguous Class C networks

Page 19: How IP address works

• These are IP address ranges reserved for private networks within organizations.

• These addresses will not be allocated by NIC as public IP addresses for the Internet.

• There is no problem of clash because when a packet goes outside the organization the local IP address gets translated into the public IP address purchased by the organization.

Page 20: How IP address works

Reserved and Available IP Addresses

Reserved and Available IP Addresses

Class Address or Range Status

A 0.0.0.01.0.0.0 through 126.0.0.0127.0.0.0

ReservedAvailableReserved

B 128.0.0.0128.1.0.0 through 191.254.0.0191.255.0.0

ReservedAvailableReserved

C 192.0.0.0192.0.1.0 through 223.255.254223.255.255.0

ReservedAvailableReserved

D 224.0.0.0 through 239.255.255.255

Multicast group addresses

E 240.0.0.0 through 255.255.255.254255.255.255.255

ReservedBroadcast

Page 21: How IP address works

• Subnet Addressing : To add another hierarchical level called the subnet .

• The beauty of the subnet addressing scheme is that it is oblivious to the network outside the organization.

Page 22: How IP address works
Page 23: How IP address works

• An organization has many LANs , each consisting of no more than 100 hosts.

• 7 bits for for host identification in a sub network and other 9 bits are used for identifying the subnetwork.

• Packet with destination IP 150.100. 12.176 arrives

• The subnet mask used is 11111111 11111111 11111111 10000000 = 255.255.255.128

• The router performs the AND between the subnet mask and the IP and the subnet number becomes 10010110 01100100 00001100 10000000 : 150.100.12.128

This number is used to forward the packet to the correct subnetwork.

Page 24: How IP address works

IP Address Classes ExerciseIP Address Classes Exercise

Address Class Network Host

10.2.1.1

128.63.2.100

201.222.5.64

192.6.141.2

130.113.64.16

256.241.201.10

Page 25: How IP address works

IP Address Classes Exercise Answers

IP Address Classes Exercise Answers

Address Class Network Host

10.2.1.1

128.63.2.100

201.222.5.64

192.6.141.2

130.113.64.16

256.241.201.10

A

B

C

C

B

Nonexistent

10.0.0.0

128.63.0.0

201.222.5.0

192.6.141.0

130.113.0.0

0.2.1.1

0.0.2.100

0.0.0.64

0.0.0.2

0.0.64.16

Page 26: How IP address works

Subnet MaskSubnet Mask

172172 1616 00 00

255255 255255 00 00

255255 255255 255255 00

IPAddress

DefaultSubnet

Mask

8-bitSubnet

Mask

Network Host

Network Host

Network Subnet Host

Also written as “/16” where 16 represents the number of 1s in the mask.

Also written as “/24” where 24 represents the number of 1s in the mask.

11111111 11111111 00000000 00000000

Page 27: How IP address works

Decimal Equivalents of Bit Decimal Equivalents of Bit PatternsPatterns

Decimal Equivalents of Bit Decimal Equivalents of Bit PatternsPatterns

1 0 0 0 0 0 0 0 = 128

1 1 0 0 0 0 0 0 = 192

1 1 1 0 0 0 0 0 = 224

1 1 1 1 0 0 0 0 = 240

1 1 1 1 1 0 0 0 = 248

1 1 1 1 1 1 0 0 = 252

1 1 1 1 1 1 1 0 = 254

1 1 1 1 1 1 1 1 = 255

128 64 32 16 8 4 2 1

Page 28: How IP address works

16

Network Host

172 0 0

10101100

11111111

10101100

00010000

11111111

00010000

00000000

00000000

10100000

00000000

00000000

•Subnets not in use—the default

00000010

Subnet Mask without SubnetsSubnet Mask without Subnets

172.16.2.160172.16.2.160

255.255.0.0 255.255.0.0

NetworkNumber

Page 29: How IP address works

•Network number is extended by eight bits

Subnet Mask with SubnetsSubnet Mask with Subnets

16

Network Host

172.16.2.160172.16.2.160

255.255.255.0 255.255.255.0

172 2 0

10101100

11111111

10101100

00010000

11111111

00010000

11111111

00000010

10100000

00000000

00000000

00000010

Subnet

Subnet Address

128

192

224

240

248

252

254

255

Page 30: How IP address works

Subnet Mask with Subnets (cont.)

Subnet Mask with Subnets (cont.)Network Host

172.16.2.160172.16.2.160

255.255.255.192 255.255.255.192

10101100

11111111

10101100

00010000

11111111

00010000

11111111

00000010

10100000

11000000

10000000

00000010

Subnet

•Network number extended by ten bits

16172 2 128

SubnetAddress

128

192

224

240

248

252

254

255

128

192

224

240

248

252

254

255

Page 31: How IP address works

Subnet Mask ExerciseSubnet Mask Exercise

Address Subnet Mask Class Subnet

172.16.2.10

10.6.24.20

10.30.36.12

255.255.255.0

255.255.240.0

255.255.255.0

Page 32: How IP address works

Subnet Mask Exercise AnswersSubnet Mask Exercise Answers

Address Subnet Mask Class Subnet

172.16.2.10

10.6.24.20

10.30.36.12

255.255.255.0

255.255.240.0

255.255.255.0

B

A

A

172.16.2.0

10.6.16.0

10.30.36.0

Page 33: How IP address works

Broadcast AddressesBroadcast Addresses

172.16.1.0

172.16.2.0

172.16.3.0

172.16.4.0

172.16.3.255(Directed broadcast)

255.255.255.255(Local network broadcast)

XX

172.16.255.255(All subnets broadcast)

Page 34: How IP address works

Addressing Summary ExampleAddressing Summary Example16172 2 160

10101100 00010000 1010000000000010 Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

4

1

Page 35: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

00010000

11111111 11111111

10100000

11000000

00000010 Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

16172 2 160

Page 36: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

00010000

11111111 11111111

10100000

11000000

00000010 Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

3

7

16172 2 160

Page 37: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

00010000

11111111 11111111

10100000

11000000

10000000

00000010 Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

3

4

16172 2 160

Page 38: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

00010000

11111111 11111111

10100000

11000000

10000000

00000010

10111111

Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

3

4

56

16172 2 160

Page 39: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

00010000

11111111 11111111

10100000

11000000

10000000

00000010

10111111

10000001

Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

3

4

56

16172 2 160

Page 40: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

00010000

11111111 11111111

10100000

11000000

10000000

00000010

10111111

10000001

10111110

Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

3

4

56

7

16172 2 160

Page 41: How IP address works

Addressing Summary ExampleAddressing Summary Example

10101100

11111111

10101100

00010000

11111111

00010000

11111111

00000010

10100000

11000000

10000000

00000010

10101100 00010000 00000010 10111111

10101100 00010000 00000010 10000001

10101100 00010000 00000010 10111110

Host

Mask

Subnet

Broadcast

Last

First

172.16.2.160

255.255.255.192

1

2

3

4

56

7

8

16172 2 160

Page 42: How IP address works

Routing Demonstration

ARP

192.168.89.20

192.168.89.40

192.168.88.20

192.168.88.40

192.168.89.2

192.168.88.2

192.168.90.2

192.168.90.3

192.168.91.3

192.168.91.4

Router BRouter C

Router A

Layer 2

Layer 2

Page 43: How IP address works

Routing done by HostNetwork Destination

Netmask Gateway Interface

0.0.0.0 0.0.0.0 192.168.88.2 192.168.88.40

192.168.88.0 255.255.255.0 192.168.88.40

192.168.88.40

192.168.88.40 255.255.255.255

127.0.0.1 127.0.0.1

Let assume IP packet received by network layer of

host have destination IP 192.168.88.20 and source IP: 192.168.88.40

192.168.88.20

AND

255.255.255.255

192.168.88.20

192.168.88.20

AND

255.255.255.0

192.168.88.0

Page 44: How IP address works

Routing done by HostNetwork Destination

Netmask Gateway Interface

0.0.0.0 0.0.0.0 192.168.88.2 192.168.88.40

192.168.88.0 255.255.255.0 192.168.88.40

192.168.88.40

192.168.88.40 255.255.255.255

127.0.0.1 127.0.0.1

Let assume IP packet received by network layer of

host have destination IP 192.168.89.4 and source IP: 192.168.88.40

192.168.89.4

AND

255.255.255.255

192.168.89.4

192.168.89.4

AND

255.255.255.0

192.168.89.0

192.168.89.4

AND

0.0.0.0

0.0.0.0

Page 45: How IP address works

Network Destination

Netmask Gateway Interface

0.0.0.0 0.0.0.0 192.168.90.3 192.168.90.2

192.168.88.0 255.255.255.0

192.168.88.2 192.168.88.2

192.168.89.0 255.255.255.0

192.168.89.2 192.168.89.2

192.168.90.0 255.255.255.0

192.168.90.2 192.168.90.2

192.168.91.0 255.255.255.0

192.168.90.3 192.168.90.2

Let assume IP packet received by layer 3

have destination IP 192.168.89.4 and source IP: 192.168.88.40

192.168.89.4

AND

255.255.255.0

192.168.89.0

Routing Done Router A

Page 46: How IP address works

Network Destination

Netmask Gateway Interface

0.0.0.0 0.0.0.0 192.168.91.4 192.168.91.3

192.168.88.0 255.255.255.0 192.168.90.2 192.168.90.3

192.168.89.0 255.255.255.0 192.168.90.2 192.168.90.3

192.168.90.0 255.255.255.0 192.168.90.3 192.168.90.3

192.168.91.0 255.255.255.0 192.168.91.3 192.168.91.3

Routing Done by Router B

Let assume IP packet received by Router A

have destination IP 192.168.92.5 and source IP: 192.168.88.40

192.168.92.5

AND

255.255.255.0

192.168.92.0

192.168.92.5

AND

0.0.0.0

0.0.0.0

Page 47: How IP address works

Dynamic Routing

Routing Protocol

Interior Gateway Protocol Exterior Gateway Protocol

Open Shortest Path First Routing Information Protocol

Border Gateway Protocol

Dijkstra Algorithm Bellman Ford Algorithm

Link State Protocol Distance Vector Protocol

Page 48: How IP address works

Address Resolution Protocol• The address resolution protocol (ARP) is used when

one host wants to get the physical address of

another host on the same network.

Page 49: How IP address works

Address Resolution Protocol

Ignored

Ignored

Page 50: How IP address works

Address Resolution Protocol

Page 51: How IP address works

Address Resolution

Page 52: How IP address works

Fragmentation and Reassembly

Page 53: How IP address works

IPv6

Page 54: How IP address works
Page 55: How IP address works
Page 56: How IP address works
Page 57: How IP address works
Page 58: How IP address works
Page 59: How IP address works
Page 60: How IP address works
Page 61: How IP address works

USER DATAGRAM PROTOCOL

Page 62: How IP address works