5.2 Ip Addressing and Tcpip
5.2 Ip Addressing and Tcpip
5.2 Ip Addressing and Tcpip
Objectives:-
TCP/ IP Model Concept.
Defining/functioning of different Layers of TCP / IP suite.
Address Space:
IPv4 uses 32-bit addresses, which means that the address space is 232 or
4,294,967,296 (more than 4 billion).
This means that, theoretically, if there were no restrictions, more than 4 billion
devices could be connected to the Internet.
Notations
There are two prevalent notations to show an IPv4 address: Binary notation and Dotted
decimal notation.
Binary Notation:
o In binary notation, the IPv4 address is displayed as 32 bits.
o Each octet is often referred to as a byte.
1
o So it is common to hear an IPv4 address referred to as a 32-bit address or a
4-byte address.
o The following is an example of an IPv4 address in binary notation:
01110101 10010101 00011101 00000010
Dotted-Decimal Notation:
o To make the IPv4 address more compact and easier to read, Internet
addresses are usually written in decimal form with a decimal point (dot)
separating the bytes.
o Each byte is identified by a decimal number in the range [0..255].
o The following is the dotted decimal notation of the above address:
117.149.29.2
o Example:
Example: Change the following IPv4 addresses from binary notation to dotted-
decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
Solution:
We replace each group of 8 bits with its equivalent decimal number and add dots for
separation.
a. 129.11.11.239
b. 193.131.27.255
IP Address classes
IPv4 addressing, at its inception, used the concept of classes.
This architecture is called classful addressing.
In classful addressing, the address space is divided into five classes: A, B, C, D,
and E.
Each class occupies some part of the address space.
We can find the class of an address when given the address in binary notation or
dotted-decimal notation.
If the address is given in binary notation, the first few bits can immediately tell
us the class of the address.
2
Fig: Finding the class in binary notation.
If the address is given in decimal-dotted notation, the first byte defines the
class.
3
Class A:
• The high-order (First) bit in a class-A address is always set to zero.
• The next seven bits complete the network ID.
• The remaining 24 bits represent the host ID.
• This allows for 128 networks and 16,777,214 hosts per network.
• In this 7 bits are used for network field and 24 bits for host field.
• Class A IP address range includes 1.0.0.0 to 127.255.255.255
Class B:
• Class B addresses are assigned to medium-sized to large-sized networks.
• The two high-order bits in a class B address are always set to binary 1 0.
• The next 14 bits complete the network ID.
• The remaining 16 bits represent the host ID.
• This allows for 16,384 networks and 65,534 hosts per network.
• Class B IP address range includes 128.0.0.0 to 191.255.255.255
Class C:
• Class C addresses are used for small organizations with a small number of attached
hosts or routers.
• The three high-order bits in a class C address are always set to binary 1 1 0.
• The next 21 bits complete the network ID.
• The remaining 8 bits (last octet) represent the host ID.
• This allows for 2097152 networks and 256 hosts per network.
• Class C IP address range includes 192.0.0.0 to 223.255.255.255.
Class D:
• Class D addresses are reserved for IP multicast addresses.
• The four high-order bits in a class D address are always set to binary 1 1 1 0.
• The remaining bits recognize hosts.
• Class D IP address range includes 224.0.0.0 to 239.255.255.255
4
Class E:
• Class E is an experimental address that is reserved for future use.
• The high-order bits in a class E address are set to binary 1111.
• Class E IP address range includes 240.0.0.0 to 255.255.255.255
Mask
Although the length of the netid and hostid (in bits) is predetermined in classful
addressing, we can also use a mask (also called the default mask/natural masks), a 32-
bit number made of contiguous 1’s followed by contiguous 0’s.
The masks for classes A, B, and C are shown in Table.
The concept does not apply to classes D and E.
The mask can help us to find the netid and the hostid.
For example, the mask for a class-A address has eight 1s, which means the first 8 bits of
any address in class A define the netid; the next 24 bits define the hostid.
Subnetting
If an organization was granted a large block in class A or B, it could divide the addresses
into several contiguous groups and assign each group to smaller networks (called
subnets) or, in rare cases, share part of the addresses with neighbors.
Subnetting increases the number of 1’s in the mask.
To create multiple logical networks that exist within a single Class A, B, or C network.
If you do not subnet, you are only able to use one network from your Class A, B, or C
network, which is unrealistic.
5
The subnet mask follows two rules:
o If a binary bit is set to a 1 (or on) in a subnet mask, the corresponding bit in the
address identifies the network.
o If a binary bit is set to a 0 (or off) in a subnet mask, the corresponding bit in the
address identifies the host.
Finding The Subnet Address: We use binary notation for both the address and the mask
and then apply the AND operation to find the subnet address.
Example: What is the subnetwork address if the destination address is 200.45.34.56 and
the subnet mask is 255.255.240.0?
Solution :
Step 1: Convert given IP and Subnet mask to Binary
Step 2: Perform AND Operation on these two.
11001000 00101101 00100010 00111000 Binary 200.45.34.56
11111111 11111111 11110000 00000000 Subnet Mask 255.255.255.0
6
Subnet 1:
The bit combination is 001.
Taking last octet in binary:0 0 1 0 0 0 0 0 = 32 (10)
Hence the subnet address is, 201.70.64. 32
Subnet 2:
The bit combination is 01 0.
Taking last octet in binary:0 0 1 0 0 0 0 0 = 64(10)
Hence the subnet address is, 201.70.64. 64
Subnet 3:
The bit combination is 011.
Taking last octet in binary:0 1 1 0 0 0 0 0 = 96(10)
Hence the subnet address is, 201.70.64. 96
Subnet 4:
The bit combination is 100.
Taking last octet in binary :1 0 0 0 0 0 0 0 = 128(10)
Hence the subnet address is, 201.70.64. 128
Subnet 5:
The bit combination is 101.
Taking last octet in binary :1 0 1 0 0 0 0 0 = 160(10)
Hence the subnet address is, 201.70.64. 160
Subnet 6:
The bit combination is 110.
Taking last octet in binary :1 1 0 0 0 0 0 0 = 192 (10)
Hence the subnet address is, 201.70.64. 192
Example 3:
A company is granted the site address 181.56.0.0 (class B). The company needs 1000
subnets. Design the subnets.
Solution:
The number of 1s in the default mask is 16 (class B).
The company needs 1000 subnets.
This number is not a power of 2.
The next number that is a power of 2 is 1024 (210).
We need 10 more 1’s in the subnet mask.
The total number of 1’s in the subnet mask is 26 (16 + 10).
The total number of 0’s is 6 (32 - 26).
The mask is
11111111 11111111 11111111 11000000
or
255.255.255.192
7
The number of subnets is 1024.
The number of addresses in each subnet is 26 (6 is the number of 0s) or 64.
Supernetting
The most of the class A and class B addresses were exhausted; however, there was still
a huge demand for midsize blocks.
The size of a class C block with a maximum number of 256 addresses did not satisfy the
needs of most organizations.
One solution was supernetting.
In supernetting, an organization can combine several class C blocks to create a larger
range of addresses.
In other words, several networks are combined to create a supernetwork or a supernet.
An organization can apply for a set of class C blocks instead of just one.
For example, an organization that needs 1000 addresses can be granted four contiguous
class C blocks.
The organization can then use these addresses to create one supernetwork.
Supernetting decreases the number of 1’s in the mask.
For example,
o if an organization is given four class C addresses, the mask changes from 24 to 22.
Example:
We need to make a supernetwork out of 16 class C blocks. What is the supernet mask?
Solution:
We need 16 blocks.
For 16 blocks we need to change four 1s to 0s in the default mask. So the mask is
11111111 11111111 11110000 00000000
Or
8
255.255.240.0
Address Depletion
The flaws in classful addressing scheme combined with the fast growth of the
Internet lead to the near depletion of the available addresses.
Yet the number of devices on the Internet is much less than the 232 address space.
We have run out of class A and B addresses, and a class C block is too small for
most midsize organizations.
One solution that has alleviated the problem is the idea of classless addressing.
Classless Addressing
To overcome address depletion and give more organizations access to the
Internet, classless addressing was designed and implemented.
In this scheme, there are no classes, but the addresses are still granted in blocks.
Address Blocks
In classless addressing, when an entity, small or large, needs to be connected to
the Internet, it is granted a block (range) of addresses.
The size of the block (the number of addresses) varies based on the nature and
size of the entity.
For example, a household may be given only two addresses; a large organization
may be given thousands of addresses.
An ISP, as the Internet service provider, may be given thousands of addresses
based on the number of customers it may serve.
Restriction: To simplify the handling of addresses, the Internet authorities impose
three restrictions on classless address blocks:
1. The addresses in a block must be contiguous, one after another.
2. The number of addresses in a block must be a power of 2 (1, 2, 4, 8, ...).
3. The first address must be evenly divisible by the number of addresses.
Example:
A company needs 600 addresses. Which of the following set of class C blocks can be used to
form a supernet for this company?
1. 198.47.32.0 198.47.33.0 198.47.34.0
2. 198.47.32.0 198.47.42.0 198.47.52.0 198.47.62.0
3. 198.47.31.0 198.47.32.0 198.47.33.0 198.47.52.0
4. 198.47.32.0 198.47.33.0 198.47.34.0 198.47.35.0
Solution:
1: No, there are only three blocks.
2: No, the blocks are not contiguous.
3: No, 31 in the first block is not divisible by 4.
4: Yes, all three requirements are fulfilled.
9
5.3 Layered Structure of the TCP / IP Model – Host-to-Network, Internet,
Transport, Application Layer.
The TCP/IP protocol suite was developed prior to the OSI model.
Therefore, the layers in the TCP/IP protocol suite do not exactly match those in the
OSI model.
The original TCP/IP protocol suite was defined as having four layers: host-to-
network, internet, transport, and application.
10
This layer is concerned with the format of datagrams as defined in the internet
protocol(IP).
The protocols in this layer include Address Resolution Protocol (ARP),
Reverse Address Resolution Protocol (RARP) and
Internet Control Message Protocol (ICMP).
11
Fig: TCP/ IP Protocol Suite
Host-to-Network Layer Protocol
Host to network Layer Defines two protocols
SLIP
PPP
SLIP and PPP Protocols allow a user to dial into an ISP over Telephone Line.
12
Password Authentication Protocol(PAP):
The second is of authentication.
Password Authentication is used.
Network Control Protocol (NCP):
After authentication is done, PPP sends NCP packet.
This packet tells ISP server what kind of traffic is to be passed over PPP link.
IP Control Protocol (IPCP):
Finally the IP packets are exchanged.
IPCP Establishes and terminates the Network layer connection.
SLIP Vs PPP
SLIP PPP
Serial Line Internet Protocol does In PPP, LCP (Line Control Protocol) is
not establish or maintain connection responsible for establishing, maintaining and
between the client and ISP server. termination connection between two end
points.
Communication starts once the Communication begins only after
connection between two modems authentication and the types of traffic is sent
are established. by the client.
Type of traffic cannot be selected in Type of traffic can be selected by
SLIP. NCP( Network Control Protocol)
No protocol for termination. IPCP(IP Control Protocol) terminates a
network layer connection between the user
and ISP.
No addressing mechanism provided. Additional services for addressing mechanism
is provided
Doesn’t allow error control Allows error control
No provision for data compression Provides Data compression.
ARP takes the IP address of a host as input & gives its corresponding physical
address as the output.
The Internet is based on IP addresses
Data link protocols (Ethernet, FDDI, ATM) may have different (MAC)
addresses
The ARP and RARP protocols perform the translation between IP addresses and
MAC layer addresses.
ARP sends the IP broadcast message to all the computer on the network.
The computer whose IP address matches the broadcast IP address sends a reply and
along with, its physical address to the broadcasting computer.
All other computers ignore the broadcast message.
Address Translation with ARP
Example:
ARP request: Argon broadcasts an ARP request to all stations on the network: “What is
the hardware address of Router137?”
ARP Reply: Router137 responds with an ARP Reply which contains the hardware address
14
ARP Packet Format
E th e rn e t II h e a d e r
6 6 2 28 10 4
H a rd w a re typ e (2 b yte s ) P ro to co l ty p e (2 b y te s )
H a rd w a re a d d re s s P ro to co l a d d re ss
O p e ra tio n c o d e (2 b y te s)
le n g th (1 b y te ) le n g th (1 b yte )
S o u rce h a rd w a re a d d re s s *
S o u rc e p ro to c o l a d d re s s*
T a rg e t h a rd w a re a d d re s s*
T a rg e t p ro to co l a d d re ss *
IP Header Format
Fields Of IP Header:
Version (4 bits): current version is 4.
Header length (4 bits): length of IP header, in multiples of 4 bytes
DS/ECN field (1 byte): This field was previously called as Type-of-Service (TOS)
field.
Differentiated Service (DS) (6 bits): Used to specify service level (currently
not supported in the Internet)
Explicit Congestion Notification (ECN) (2 bits):New feedback mechanism
used by TCP.
Identification (16 bits): Unique identification of a datagram from a host.
Incremented whenever a datagram is transmitted.
Flags (3 bits):
First bit always set to 0
DF bit (Do not fragment)
MF bit (More fragments)
Time To Live (TTL) (1 byte): Specifies longest paths before datagram is dropped.
16
Role of TTL field: Ensure that packet is eventually dropped when a routing
loop occurs.
Used as follows:
Sender sets the value (e.g., 64)
Each router decrements the value by 1
When the value reaches 0, the datagram is dropped
Protocol (1 byte):
Specifies the higher-layer protocol.
Functions of the IP
1. Addressing:
In order to perform the job of delivering datagrams, IP must know where to
deliver them to. For this reason, IP includes a mechanism for host addressing.
2. Data Encapsulation and Formatting/ Packaging:
IP accepts data from the transport layer protocols UDP and TCP.
It then encapsulates this data into an IP datagram using a special format
prior to transmission.
17
IP fragment IP datagrams into pieces.
The receiving device uses the reassembly function to recreate the whole IP
datagram again.
4. Routing / Indirect Delivery:
When an IP datagram must be sent to a destination on the same local
network, this is done using direct delivery.
However, if the final destination is on a distant network not directly attached
to the source datagram must be delivered indirectly.
IPV6
IP version 6 (IPv6) is an advanced version of IPv4.
It takes all good features of IPv4 and adds new ones.
Larger address space: IPv6 uses 128 bit(16 Bytes) Address.
Better header format: This simplifies and speeds up the routing process.
New options. IPv6 has new options to allow for additional functionalities.
Allowance for extension: IPv6 is designed to allow the extension of the protocol if
required by new technologies or applications.
IPv6 major goals:
1. Support billions of hosts.
2. Reduce the size of the routing tables.
3. Simplify the protocol.
4. Provide better security (authentication and privacy).
5. More attention to the type of service
6. Aid multicasting by allowing scopes to be specified.
7. Make it possible for a host to roam without changing its address.
8. Allow the protocol to evolve in the future.
9. Permit the old and new protocols to coexist for years.
Header Fields:
Version (4-bit): Defines the version number of the IP. For IPv6, the value is 6.
Priority(4-bit): Defines the priority of the packet with respect to traffic congestion.
Flow label (3-byte /24-bit): It is designed to provide special handling flow of data.
Payload length(2-byte): Defines the length of the IP datagram excluding the base
header.
18
Hop limit (8-bit): Serves the same purpose as the TTL field in IPv4.
Next header (8-bit):
Defines the header that follows the base header in the datagram.
The next header is either one of the optional extension headers used by IP or
the header of an encapsulated packet such as UDP or TCP.
Note that this field in version 4 is called the protocol.
Source address.:
The source address field is a 16-byte (128-bit)
Internet address that identifies the original source of the datagram.
Destination address.
The destination address field is a 16-byte (128-bit)
Internet address that usually identifies the final destination of the datagram.
However, if source routing is used, this field contains the address of the next
router.
IPv4 IPv6
1. Source and destination addresses are 1. Source and destination addresses are 128
32 bits (4 bytes) in length. bits(16 bytes)in length.
2. Uses broadcast addresses to send 2. There are no IPv6 broadcast addresses.
traffic to all nodes on a subnet. Instead, multicast scoped addresses are
used.
3. Fragmentation is supported at 3. Fragmentation is not supported at routers.
Originating hosts and intermediate It is only supported at the
routers.
4. IP header include a checksum. 4. IP header does not include a checksum.
5.IP header includes options. 5. All optional data is moved toIPv6
extension headers.
6.IPsec support is optional 6.IPsec support is required in a full IPv6
implementation.
7. No identification of payload for QoS 7. Payload identification for QoS handling By
Handling by routers is present within routers is included in theIPv6 header using
the IPv4 header. the Flow Label field.
8. Address must be configured either 8. Addresses can be automatically assigned
manually or through DHCP. using stateless address auto configuration,
assigned using DHCPv6, or manually
configured.
9. IP address represented in decimal 9. IP address is represented in hexadecimal
number system number system
10. “.” used as seperator 10. ‘ : ‘ used as separator .
11. Uses host address (A) resource 11. Uses host address (AAAA) resource
records in the domain name system to records in the domain name system to map
map host names to IPv4 addresses. host names to IPv6 addresses.
4. ICMP
It is internet control message protocol.
19
It reports error and sends control messages.
Error reporting messages include – destination unreachable, source quench ,
time exceed, parameter problem, redirection etc.
Query message includes –echo request and reply, time stamp request and reply,
router solicitation and advertisement, etc.
TCP is Reliable-
Reliable means that every transmission of data is acknowledged by the receiver.
Reliable does not mean that things don't go wrong, it means that we find out when
things go wrong.
If the sender does not receive acknowledgement within a specified amount of time,
the sender retransmits the data.
2. UDP
UDP is user datagram protocol.
It is connectionless protocol because data is sent without establishing a connection
between sender and receiver before sending the data.
UDP is unreliable because data is delivered without acknowledgement.
UDP does not perform Auto retransmission.
UDP does not use flow control .
UDP has high transmission speed.
21
UDP Vs TCP
UDP TCP
Complexity UDP is less complex TCP is more complex
Connection UDP is connection less protocol TCP is connection oriented protocol
Reliability It provides unreliable delivery It provides reliable delivery of
of messages messages
Function By using this protocol one As a message makes its way across
program can send a load of the internet from one computer to
packets to another and that another. This is connection based.
would be the end of the
relationship.
layer they exist Transport layer Transport layer
Flow controlling UDP has no flow control TCP has flow control
Overhead Overhead is very low Overhead is low
Which is powerful UDP is less powerful TCP is more powerful.
SMTP
SMTP is simple mail transfer protocol.
It is connection oriented text based protocol.
Sender communicates with receiver using a command and supplying data over
reliable TCP connection.
SMTP is standard application layer protocol for delivery of email over TCP/IP
network.
SMTP establish a TCP connection between sender and port number 25 of receiver.
Electronic Mail
22
Three major components:
user agents
mail servers
simple mail transfer protocol: SMTP
User Agent
Also called as “mail reader”
composing, editing, reading mail messages e.g., Eudora, Outlook, Mozilla
Thunderbird
outgoing, incoming messages stored on server.
Mail Servers
mailbox contains incoming messages for user
message queue of outgoing (to be sent) mail messages
SMTP
protocol between mail servers to send email messages
client: sending mail server
“server”: receiving mail server
Scenario: Alice sends message to Bob
1) Alice uses UA to compose message and “to” bob@yahoo.com
2) Alice’s UA sends message to her mail server; message placed in message queue
3) Client side of SMTP opens TCP connection with Bob’s mail server
4) SMTP client sends Alice’s message over the TCP connection
5) Bob’s mail server places the message in Bob’s mailbox
6) Bob invokes his user agent to read message
23
Sample SMTP interaction
FTP
FTP is used for copying a file from one host to the other.
Some of the problem in transferring files :
Two systems may use different file name conventions.
Two systems may represent text data in different types.
The directory structure of the two systems may be different.
FTP provides a simple solution to all these problems.
FTP established two connections between the client and server.
One is for data transfer and the other is for the control information.
24
FTP: separate control, data connections
FTP client contacts FTP server at port 21
client authorized over control connection.
client browses remote directory by sending commands over control connection.
when server receives file transfer command, server opens 2nd TCP connection (for
file) to client after transferring one file, server closes data connection.
server opens another TCP data connection to transfer another file.
FTP server maintains “state”: current directory, earlier authentication.
Control connection:
Control connection remains alive during the entire process.
The IP uses minimize delay type services because this is an interactive
connection between a user and server.
Data Connection:
Data connection uses the port 20 at the site.
This connection is opened when data to be transferred is ready and it is
closed when transfer of data is over.
The service types used by IP is maximize throughput.
TELNET
TELNET is abbreviation for Terminal Network.
It is standard TCP/IP protocol for virtual terminal services proposed by ISO.
TELNET enables establishment of connection to a remote system in such a way that
a local terminal appears to be terminal at remote system.
TELNET is general purpose client server application program.
Remote login
When user wants to access the application or utility located at the remote
machine ,he or she performs remote login.
Here the telnet client and server program come into use.
25
The user sends the keystrokes to local operating system. local operating system
accept is, but do not interpret them.
The characters are send to TELNET client.
TELNET client transform the character to a universal character set called Network
Virtual Terminal Character and deliver them to the local TCP/IP stack.
Summery
Connectionless protocols:
IP
ICMP
UDP
Connection oriented protocol:
TCP
SLIP
PPP
SMTP
26
5.5 Comparison between OSI and TCP / IP Network Model.
OSI reference model TCP/IP network model
1)It has 7 layers 1)It has 4 layers
2)Transport layer guarantees delivery 2)Transport layer does not guarantees
of packets delivery of packets
3)Horizontal approach 3)Vertical approach
4)Separate presentation layer 4)No session layer, characteristics are
provided by transport layer
5)Separate session layer 5)No presentation layer, characteristics
are provided by application layer
6)Network layer provides both 6)Network layer provides only
connectionless and connection oriented connection less services
services
7)It defines the services, interfaces and 7)It does not clearly distinguishes
protocols very clearly and makes a clear between service interface and protocols
distinction between them
8)The protocol are better hidden and 8)It is not easy to replace the protocols
can be easily replaced as the technology
changes
9)OSI truly is a general model 9)TCP/IP cannot be used for any other
application
10)It has a problem of protocol filtering 10) The model does not fit any protocol
into a model stack.
27