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

Cs3591 Cn Unit 1 Notes (1)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Cs3591 Cn Unit 1 Notes (1)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 37

UNIT I INTRODUCTION AND APPLICATION LAYER

Data Communication - Networks – Network Types – Protocol Layering – TCP/IP Protocol


suite –OSI Model – Introduction to Sockets - Application Layer protocols: HTTP – FTP –
Email protocols(SMTP - POP3 - IMAP - MIME) – DNS – SNMP

1.1 Data Communication


When we communicate, we are sharing information. This sharing can be local or
remote.
The term telecommunication, which includes telephony, telegraphy, and television,
means communication at a distance (tele is Greek for "far").
The word data refers to information presented in whatever form is agreed upon by
the parties creating and using the data.
“Data communications are the exchange of data between two devices via some
form of transmission medium such as a wire cable”.
For data communications to occur, the communicating devices must be part of a
communication system made up of a combination of hardware (physical equipment) and
software (programs).

The effectiveness of a data communications system depends on four fundamental


characteristics:

I. Delivery: The system must deliver data to the correct destination. Data must be received by
the intended device or user .

2. Accuracy: The system must deliver the data accurately. Data that have been altered in
transmission and left uncorrected are unusable.

3. Timeliness: The system must deliver data in a timely manner. Data delivered late are
useless.

4. Jitter: Jitter refers to the variation in the packet arrival time. It is the uneven delay in
the delivery of audio or video packets.

1.1.1Components

A data communications system has five components

1.Message: The message is the information (data) to be communicated. Popular forms of


information include text, numbers, pictures, audio, and video.
2.Sender: The sender is the device that sends the data message. It can be a computer,
workstation, telephone handset, video camera, and so on.

3. Receiver: The receiver is the device that receives the message. It can be a computer,
workstation, telephone handset, television, and so on.

4. Transmission medium: The transmission medium is the physical path by which a message
travels from sender to receiver. Some examples of transmission media include twisted-pair
wire, coaxial cable, fiber optic cable, and radio waves.

5. Protocol: A protocol is a set of rules that govern data communications. It represents an


agreement between the communicating devices. Without a protocol, two devices may be
connected but not communicating.

1.1.2Data Representation

Information today comes in different forms such as text, numbers, images, audio, and
video.
Text
In data communications, text is represented as a bit pattern, a sequence of bits (O s or 1 s).
Different sets of bit patterns have been designed to represent text symbols. Each set is called a
code, and the process of representing symbols is called coding.
Unicode, which uses 32 bits to represent a symbol or character used in any language in the
world. The American Standard Code for Information Interchange (ASCII), now constitutes
the first 127 characters in Unicode and is also referred to as Basic
Latin.

Numbers
Numbers are also represented by bit patterns. However, a code such as ASCII is not used
to represent numbers; the number is directly converted to a binary number to simplify
mathematical operations.

Images
Images are also represented by bit patterns. In its simplest form, an image is composed
of a matrix of pixels (picture elements), where each pixel is a small dot. The size of the
pixel depends on the resolution. The size and the value of the pattern depend on the image.

For an image made of only black-and-white dots (e.g., a chessboard), a I-bit pattern is enough
to represent a pixel. If an image is not made of pure white and pure black pixels, you can
increase the size of the bit pattern to include gray scale

There are several methods to represent color images. One method is called RGB, so called
because each color is made of a combination of three primary colors: red, green, and blue.
The intensity of each color is measured, and a bit pattern is assigned to it. Another method is
called YCM, in which a color is made of a combination of three other primary colors:
yellow, cyan, and magenta.

Audio
Audio refers to the recording or broadcasting of sound or music. Audio is by nature different
from text, numbers, or images.
Video
Video refers to the recording or broadcasting of a picture or movie. Video can either be produced
as a continuous entity (e.g., by a TV camera), or it can be a combination of images, each a
discrete entity, arranged to convey the idea of motion.

1.1.3Data Flow / transmission mode

Communication between two devices can be simplex, half-duplex, or full-duplex as shown in


Figure 1.2.

Disadvantage of Simplex mode:


o Communication is unidirectional, so it has no inter-communication between devices.

Half-Duplex
In half-duplex mode, each station can both transmit and receive, but not at the same time. When one
device is sending, the other can only receive, and vice versa (see Figure 1.2b)

Walkie-talkies and CB (citizens band) radios are both half-duplex systems. The half-
duplex mode is used in cases where there is no need for communication in both directions at
the same time.
Advantage of Half-duplex mode:
o In half-duplex mode, both the devices can send and receive the data and also can utilize the
entire bandwidth of the communication channel during the transmission of data.

Disadvantage of Half-Duplex mode:


o In half-duplex mode, when one device is sending the data, then another has towait, this
causes the delay in sending the data at the right time.

Full-Duplex
In full-duplex mode (also called duplex), both stations can transmit and receive simultaneously (see
Figure 1.2c).The full-duplex mode is like a two-way street with traffic flowing in both directions at
the same time. One common example of full-duplex communication is the telephone network.
When two people are communicating by a telephone line, both can talk and listen at the same time. The
full-duplex mode is used when communication in both directions is required all the time.

Advantage of Full-duplex mode:


o Both the stations can send and receive the data at the same time.

Disadvantage of Full-duplex mode:


o If there is no dedicated path exists between the devices, then the capacity of the
communication channel is divided into two parts.

1.2 NETWORKS
A network is a set of devices (often referred to as nodes) connected by communication links. A node
can be a computer, printer, or any other device capable of sending and/or receiving data generated by
other nodes on the network.

Distributed Processing
Most networks use distributed processing, in which a task is divided among multiple computers.
Instead of one single large machine being responsible for all aspects of a process, separate
computers (usually a personal computer or workstation) handle a subset.

1.2.1 Network Criteria


A network must be able to meet a certain number of criteria. The most important of these are
performance, reliability, and security.

Performance
Performance can be measured in many ways, including transit time and response time. Transit
time is the amount of time required for a message to travel from one device to another. Response time
is the elapsed time between an inquiry and a response. The performance of a network depends on
a number of factors, including the number of users,
the type of transmission medium, the capabilities of the connected hardware, and the efficiency of the
software. Performance is often evaluated by two networking metrics: throughput and delay.
Throughput is an actual measurement of how fast data can be transmitted. Latency/delay is time
required for a message to completely arrive at the destination from source. We often need more
throughput and less delay. However, these two criteria are often contradictory. If we try to send more
data to the network, we may increase throughput but we increase the delay because of traffic
congestion in the network.

Reliability
In addition to accuracy of delivery, network reliability is measured by the frequency of failure,
the time it takes a link to recover from a failure, and the network's robustness in a catastrophe.

Security
Network security issues include protecting data from unauthorized access, protecting data from
damage and development, and implementing policies and procedures for recovery from breaches
and data losses.

1.2.2 Physical Structures

Type of Connection / Line configuration

A network is two or more devices connected through links. A link is a communications pathway
that transfers data from one device to another. There are two possible types of connections: point-
to-point and multipoint.
Point-to-Point
A point-to-point connection provides a dedicated link between two devices. The entire capacity of the
link is reserved for transmission between those two devices. Most point-to-point connections use
an actual length of wire or cable to connect the two ends (see Figure 1.3a). When you change
television channels by infrared remote control, you are establishing a point- to-point connection
between the remote control and the television's control system.
Multipoint
A multipoint (also called multidrop) connection is one in which more than two specific devices share a
single link (see Figure 1.3b). In a multipoint environment, the capacity of the channel is shared, either
spatially or temporally. If several devices can use the link simultaneously, it is a spatially shared
connection. If users must take turns, it is a timeshared connection.

Physical Topology

The term physical topology refers to the way in which a network is laid out physically. Two or
more devices connect to a link; two or more links form a topology. The topology of a network is
the geometric representation of the relationship of all the links and linking devices (usually
called nodes) to one another. There are four basic topologies possible: mesh, star, bus, and ring
(see Figure 1.4).
Advantages of Mesh Disadvantages of
Topology Mesh Topology
Each connection can Installation and
Star Topology
carry its own data configuration is
o
load. In a star topology, each device has a dedicated point-to-point link o nly to a
difficult.
Mesh Topology
It is robust.central controller, usually
Cabling costcalled a hub.
is more.
o The
Fault is diagnosed devices are
3. not
Bulk wiring is to one another.
directly linked
In a mesh topology, every device
o The controller/hub
easily. acts as an exchange.
required.
has a dedicated point-to-point link
Provides o security
one and
Ifdevice.
device wants to send data to another, it sends the data to the
to everyother
privacy.controller/hub ,which then relays the data to the other connected device.
The term dedicated means that
the link carries traffic only
between the twodevices it
connects.
The number of physical links in a fully
connected mesh network with n
nodes is given by n (n – 1) / 2.
Advantages of Star Topology
Disadvantages of Star Topology
1. Fast performance with few nodes and
low network traffic. 1. Cost of installation is high.
2. Hub can be upgraded easily. 2. Expensive to use.
3. Easy to troubleshoot. 3. If the hub fails, then the wholenetwork
4. Easy to setup and modify. is stopped.
5. Only that node is affected which has 4. Performance is based on the hub thatis it
failed, rest of the nodes can work depends on its capacity
smoothly

Bus Topology

 Bus topology is a network type in which every computer and network


device isconnected to single cable.
 The long single cable acts as a backbone to link all the devices in a network.
 When it has exactly two endpoints, then it is called Linear Bus topology.
 It transmits data only in one direction.

Advantages of Bus Topology Disadvantages of Bus Topology


1. It is cost effective. 1. Cables fails then whole network fails.
2. Cable required is least compared to 2. If network traffic is heavy or nodes are
other network topology. more, the performance of the network
3. Used in small networks. decreases.
4. It is easy to understand.
3. Cable has a limited length.
5. Easy to expand joining two cables
4. It is slower than the ring topology.
together
Ring Topology

 In a ring topology, each device has a dedicated point-to-point


connection withonly the two devices on either side of it.
 A signal is passed along the ring in one direction, from device to device,
until itreaches its destination.
 Each device in the ring incorporates a repeater.
 When a device receives a signal intended for another device, its repeater
regenerates the bits and passes them along.

Advantages of Disadvantages of
Ring Topology Ring Topology
Transmitting network Troubleshootin
is not affected by g is difficult in
high traffic or by ring topology.
adding more nodes, as Adding or
only the nodes having deleting the
tokens can transmit computers
data. disturbs the
Cheap to install and network
expand activity.
Failure of one
computer disturbs
the
whole network
Hybrid Topology
Hybrid Topology is a combination of one or
more basic topologies.
For example if one department in an
office uses ring topology, the other
departments uses star and bus topology,
then connecting these topologies will
result in Hybrid Topology.
Hybrid Topology inherits the advantages
and disadvantages of the topologies
included.
Advantages of Disadvantages of
Hybrid Hybrid Topology
Topology
1. Complex in design.
Reliable as Error 2. Costly
detecting and
trouble shooting is
easy.
Effective.
Scalable as size can
be increased easily.
1.3 NETWORK TYPES
Flexible.
Different types of networks: LANs MANs and WANs.
Local Area Network

Local Area Network is a group of computers connected to each other in a small
area such as building, office.
LAN is used for connecting two or more personal computers through a
communication medium such as twisted pair, coaxial cable, etc.
It is less costly as it is built with inexpensive hardware such as hubs,
networkadapters, and ethernet cables.
The data is transferred at an extremely faster rate in Local Area Network.
LAN can be connected using a common cable or a Switch
Advanta Disadvant
ges of ages of
LAN LAN
Resource Sharing High Setup Cost
Software Applications Privacy Violations
Sharing. Data Security Threat
Easy and Cheap LAN Maintenance Job
Communication Covers Limited Area
1.3.2 Metropolitan Area Network (MAN)
Centralized Data.
Data Security
o A metropolitan area network is a network that covers a larger geographic area by
Internet Sharing
interconnecting a different LAN to form a larger network.
o It generally covers towns and cities (50 km)
o In MAN, various LANs are connected to each other through a telephone
exchange line.
o Communication medium used for MAN are optical fibers, cables etc.
o It has a higher range than Local Area Network(LAN).It is adequate for distributed
computing applications.

1.3.3 Wide Area Network (WAN)


o A Wide Area Network is a network that extends over a large
geographical areasuch as states or countries.
o A Wide Area Network is quite bigger network than the LAN.
o A Wide Area Network is not limited to a single location, but it spans over a
largegeographical area through a telephone line, fibre optic cable or satellite
links.
o The internet is one of the biggest WAN in the world.
o A Wide Area Network is widely used in the field of Business,
government, andeducation.
o WAN can be either a point-to-point WAN or Switched WAN.
Point-to-Point WAN
A point-to-point WAN is a network that connects two communicating devices through a
transmission medium (cable or air). Figure 1.9 shows an example of a point-to-point WAN.

Switched WAN
A switched WAN is a network with more than two ends. It is used in the backbone of a
global communications network today. Figure 1.10 shows an example of a switched WAN

Advantages of Wide Disadvantages of


Area Network: Wide Area
Network:
Large Geographical area
Centralized data Security issue
Exchange messages Needs Firewall &
Sharing of software and antivirus software
resources High Setup cost
High bandwidth Troubleshooting
problems
Internetwork
Today, it is very rare to see a LAN or a WAN in isolation; they are connected to one
another. When two or more networks are connected, they make an internetwork, or internet.
As an example, assume that an organization has two offices, one on the east coast and the
other on the west coast.
Each office has a LAN that allows all employees in the office to communicate with
each other. To make the communication between employees at different offices possible, the
management leases a point-to-point dedicated WAN from a service provider, such as a
telephone company, and connects the two LANs.
Now the company has an internetwork, or a private internet (with lowercase i).
Communication between offices is now possible. Figure 1.11 shows this internet.

Types of Internetwork

Extranet Intranet
An extranet is used for information sharing.
The access to the extranet is restricted to only An intranet belongs to an organization which
those users who have login credentials. An is only accessible by the
extranet is the lowest level of internetworking. organization's employee or members. The
It can becategorized as MAN, WAN or other main aim of the intranet is to share the
computer networks. An extranet cannot have a information and resources among the
single LAN, atleast it must haveone organization employees. An intranet provides
connection to the external network. the facility to work in groups and for
teleconferences.

1.3.4 The Internet


An internet (note the lowercase i) is two or more networks that can communicate with each
other. The most notable internet is called the Internet (uppercase I) and is composed of
thousands of interconnected networks. Figure 1.13 shows a conceptual (not geographical)
view of the Internet.
The figure shows the Internet as several backbones, provider networks, and customer
networks. At the top level, the backbones are large networks owned by some communication
companies. The backbone networks are connected through some complex switching
systems, called peering points.

At the second level, there are smaller networks, called provider networks, that use the services
of the backbones for a fee. The provider networks are connected to backbones and sometimes
to other provider networks. The customer networks are networks at the edge of the Internet
that actually use the services provided by the Internet. They pay fees to provider networks
for receiving services.

Backbones and provider networks are also called Internet Service Providers (ISPs). The
backbones are often referred to as international ISPs; the provider networks are often referred
to as national or regional ISPs.

1.3.5 Accessing the Internet


The Internet today is an internetwork that allows any user to become part of it. The user,
however, needs to be physically connected to an ISP. The physical connection is normally
done through a point-to-point WAN (such as a telephone network, a cable network, a
wireless network, or other types of networks).

Using Telephone Networks

Today most residences and small businesses have telephone service, which means they are
connected to a telephone network. Because most telephone networks have already connected
themselves to the Internet, one option for residences and small businesses to connect to the
Internet is to change the voice line between the residence or business and the telephone center
to a point-to-point WAN. This can be done in two ways.

❏ Dial-up service. The first solution is to add a modem that converts data to voice to the
telephone line. The software installed on the computer dials the ISP and imitates making a
telephone connection. Unfortunately, the dial-up service is very slow, and when the line is
used for an Internet connection, it cannot be used for a telephone (voice)connection. It is
only useful for small residences and businesses with occasional connection to the Internet.

❏ DSL Service. Since the advent of the Internet, some telephone companies have upgraded
their telephone lines to provide higher-speed Internet services to residences or small
businesses. The digital subscriber line (DSL) service also allows the line to be used
simultaneously for voice and data communications.

Using Cable Networks

More and more residents over the last two decades have begun using cable TV services
instead of antennas to receive TV broadcasting. The cable companies have been upgrading
their cable networks and connecting to the Internet. A residence or a small business can be
connected to the Internet by using this service. It provides a higher-speed connection, but
the speed varies depending on the number of neighbors that use the same cable.

Using Wireless Networks

Wireless connectivity has recently become increasingly popular. A household or a small


business can use a combination of wireless and wired connections to access the Internet. With
the growing wireless WAN access, a household or a small business can be connected to the
Internet through a wireless WAN.

Direct Connection to the Internet

A large organization or a large corporation can itself become a local ISP and be connected to
the Internet. This can be done if the organization or the corporation leases a high-speed WAN
from a carrier provider and connects itself to a regional ISP. For example, a large university
with several campuses can create an internetwork and then connect the internetwork to the
Internet.
1.4 PROTOCOL LAYERING
➢ In networking, a protocol defines the rules that both the sender and receiver andall
intermediate devices need to follow to be able to communicate effectively.
➢ A protocol provides a communication service that the process use to exchange
messages.
➢ When communication is simple, we may need only one simple protocol.
➢ When the communication is complex, we may need to divide the task between different
layers, in which case we need a protocol at each layer, or protocol layering.
➢ Protocol layering is that it allows us to separate the services from the implementation.
➢ A layer needs to be able to receive a set of services from the lower layer and to give the
services to the upper layer.
➢ Any modification in one layer will not affect the other layers.
Basic Elements of Layered Architecture
➢ Service: It is a set of actions that a layer provides to the higher layer.
➢ Protocol: It defines a set of rules that a layer uses to exchange the information with
peer entity. These rules mainly concern about both the contents and order of the
messages used.
➢ Interface: It is a way through which the message is transferred from one layer to
another layer.
Features of Protocol Layering
1. It decomposes the problem of building a network into more manageable
components.
2. It provides a more modular design.

1.4.2 Principles of Protocol Layering

1. The first principle dictates that if we want bidirectional communication, we need to


make each layer so that it is able to perform two opposite tasks, one in each
direction.
2. The second principle that we need to follow in protocol layering is that the two
objects under each layer at both sites should be identical.

1.5 TCP/IP PROTOCOL SUITE (INTERNET ARCHITECTURE)

The TCP/IP architecture is also called as Internet architecture.


It is developed by the US Defense Advanced Research Project Agency (DARPA)for its
packet switched network (ARPANET).
TCP/IP is a protocol suite used in the Internet today.
It is a 5-layer model. The layers of TCP/IP are

1. Application layer
2. Transport Layer (TCP/UDP)
3. Network Layer
4. Datalink Layer
5. Physical Layer
1.5.1 Layered Architecture

To show how the layers in the TCP/IP protocol suite are involved in communication
between two hosts, we assume that we want to use the suite in a small internet made up of
three LANs (links), each with a link-layer switch. We also assume that the links are
connected by one router, as shown in Figure 1.18 (on next page). Let us assume that
computer A communicates with computer B.
As Figure 1.18 shows, we have five communicating devices in this communication:
source host (computer A), the link-layer switch in link 1, the router, the link-layer switch in
link 2, and the destination host (computer B). Each device is involved with a set of layers
depending on the role of the device in the internet. The two hosts are involved in all five
layers.

1.5.2 Description of Each Layer

After understanding the concept of logical communication, we are ready to briefly discuss
the duty of each layer.

Application Layer
An application layer incorporates the function of top three OSI layers.
Anapplication layer is the topmost layer in the TCP/IP model.
It is responsible for handling high-level protocols, issues of representation.
This layer allows the user to interact with the application.
When one application layer protocol wants to communicate with another
application layer, it forwards its data to the transport layer.
Protocols such as FTP, HTTP, SMTP, POP3, etc running in the application layer
provides service to other program running on top of application layer

Transport Layer
The transport layer is responsible for the reliability, flow control, and correction
of data which is being sent over the network.
The two protocols used in the transport layer are User Datagram protocol and
Transmission control protocol.
o UDP – UDP provides connectionless service and end-to-end delivery of
transmission. It is an unreliable protocol as it discovers the errors but not
specify the error.
o TCP – TCP provides a full transport layer services to applications. TCP is
a reliable protocol as it detects the error and retransmits the damaged
frames.
Network Layer
The network layer is the third layer of the TCP/IP model.
The main responsibility of the network layer is to send the packets from any
network, and they arrive at the destination irrespective of the route they take.
Network layer handle the transfer of information across multiple networks
through router and gateway .
IP protocol is used in this layer, and it is the most significant part of the entire
TCP/IP suite.
Data Link Layer
We have seen that an internet is made up of several links (LANs and WANs)
connected by routers. When the next link to travel is determined by the router, the
data-link layer is responsible for taking the datagram and moving it across the link.
Physical Layer
The physical layer is responsible for carrying individual bits in a frame across the
link.
The physical layer is the lowest level in the TCP/IP protocol suite.
The communication between two devices at the physical layer is still a logical
communication because there is another hidden layer, the transmission media, under
the physical layer.

1.6 THE OSI MODEL


An ISO standard that covers all aspects of network communications is the Open
Systems Interconnection (OSI) model. It was first introduced in the late 1970s.
An open system is a set of protocols that allows any two different systems to
communicate regardless of their underlying architecture. The purpose of the OSI model is to
show how to facilitate communication between different systems without requiring changes to
the logic of the underlying hardware and software.
The OSI model is not a protocol; it is a model for understanding and designing a
network architecture that is flexible, robust, and interoperable. The OSI model is a layered
framework for the design of network systems that allows communication between all types of
computer systems. It consists of seven separate but related layers, each of which defines a part
of the process of moving information across a network (see Figure 1.21).
1.6.1 Application Layer

This is the only layer that directly interacts with data from the user. Software
applications like web browsers and email clients rely on the application layer to initiate
communications. But it should be made clear that client software applications are not part of
the application layer; rather the application layer is responsible for the protocols and data
manipulation that the software relies on to present meaningful data to the user. Application
layer protocols include HTTP as well as SMTP (Simple Mail Transfer Protocol is one of the
protocols that enables email communications).

1.6.2 Presentation Layer

This layer is primarily responsible for preparing data so that it can be used by the
application layer; in other words, layer 6 makes the data presentable for applications to
consume. The presentation layer is responsible for translation, encryption, and compression of
data.

Two communicating devices communicating may be using different encoding


methods, so layer 6 is responsible for translating incoming data into a syntax that the
application layer of the receiving device can understand.

If the devices are communicating over an encrypted connection, layer 6 is responsible


for adding the encryption on the sender’s end as well as decoding the encryption on the
receiver's end so that it can present the application layer with unencrypted, readable data.

Finally the presentation layer is also responsible for compressing data it receives from
the application layer before delivering it to layer 5. This helps improve the speed and
efficiency of communication by minimizing the amount of data that will be transferred.
1.6.3 Session Layer

This is the layer responsible for opening and closing communication between the two
devices. The time between when the communication is opened and closed is known as the
session. The session layer ensures that the session stays open long enough to transfer all the
data being exchanged, and then promptly closes the session in order to avoid wasting
resources.

This layer is responsible for the establishment of connection, maintenance of sessions,


authentication, and also ensures security.

1.6.4 Transport Layer

Layer 4 is responsible for end-to-end communication between the two devices. This
includes taking data from the session layer and breaking it up into chunks called segments
before sending it to layer 3. The transport layer on the receiving device is responsible for
reassembling the segments into data the session layer can consume.

The transport layer is also responsible for flow control and error control. Flow
control determines an optimal speed of transmission to ensure that a sender with a fast
connection does not overwhelm a receiver with a slow connection. The transport layer
performs error control on the receiving end by ensuring that the data received is complete,
and requesting a retransmission if it isn’t.
1.6.5 Network Layer

The network layer works for the transmission of data from one host to the other
located in different networks. It also takes care of packet routing i.e. selection of the
shortest path to transmit the packet, from the number of routes available. The sender &
receiver’s IP addresses are placed in the header by the network layer.

The functions of the Network layer are :

1. Routing: The network layer protocols determine which route is suitable from source
to destination. This function of the network layer is known as routing.
2. Logical Addressing: In order to identify each device on internetwork uniquely, the
network layer defines an addressing scheme. The sender & receiver’s IP addresses are
placed in the header by the network layer. Such an address distinguishes each device
uniquely and universally.

1.6.6 Data Link Layer

The data link layer is responsible for the node-to-node delivery of the message. The main
function of this layer is to make sure data transfer is error-free from one node to another,
over the physical layer. When a packet arrives in a network, it is the responsibility of DLL
to transmit it to the Host using its MAC address.
Data Link Layer is divided into two sublayers:

1. Logical Link Control (LLC)


2. Media Access Control (MAC)

The packet received from the Network layer is further divided into frames depending on
the frame size of NIC(Network Interface Card). DLL also encapsulates Sender and
Receiver’s MAC address in the header.

The Receiver’s MAC address is obtained by placing an ARP(Address Resolution


Protocol) request onto the wire asking “Who has that IP address?” and the destination host
will reply with its MAC address.
1.6.7 Physical Layer

This layer includes the physical equipment involved in the data transfer, such as the
cables and switches. This is also the layer where the data gets converted into a bit stream,
which is a string of 1s and 0s. The physical layer of both devices must also agree on a signal
convention so that the 1s can be distinguished from the 0s on both devices.

Summary of Layers
COMPARISON - OSI MODEL AND TCP/IP MODEL

S.No OSI MODEL TCP/IP MODEL


1 Defined before advent of internet Defined after the advent of Internet.
2 Service interface and protocols Service interface and protocols were
are clearly distinguished before notclearly distinguished before

3 Internetworking not supported TCP/IP supports Internet working

4 Strict layering Loosely layered

5 Protocol independent standard Protocol Dependant standard

6 Less Credible More Credible

7 All packets are reliably delivered TCP reliably delivers packets, IP


doesnot reliably deliver packets
1.7 Introduction to Sockets

A socket is one endpoint of a two way communication link between two programs
running on the network. The socket mechanism provides a means of inter-process
communication (IPC) by establishing named contact points between which the
communication take place.

Like ‘Pipe’ is used to create pipes and sockets is created using ‘socket’ system call.
The socket provides bidirectional FIFO Communication facility over the network. A socket
connecting to the network is created at each end of the communication. Each socket has a
specific address. This address is composed of an IP address and a port number.

Socket are generally employed in client server applications. The server creates a
socket, attaches it to a network port addresses then waits for the client to contact it. The client
creates a socket and then attempts to connect to the server socket. When the connection is
established, transfer of data takes place.

1.7.1 Socket Addresses

The interaction between a client and a server is two-way communication. In a two-way


communication, we need a pair of addresses:
local (sender) and remote (receiver).
The local address in one direction is the remote address in the other direction, and vice versa.
Because communication in the client/server paradigm is between two sockets, we need a pair
of socket addresses for communication:
a local socket address and a remote socket address.
A socket address should first define the computer on which a client or a server is running. A
computer in the Internet is uniquely defined by its IP address, a 32-bit integer in the current
Internet version. An application program can be defined by a port number, a 16-bit integer.
This means that a socket address should be a combination of an IP address and a port number
as shown in Figure 10.7.
Because a socket defines the end-point of the communication, we can say that a socket is
identified by a pair of socket addresses, a local and a remote.

1.7.2 Finding Socket Addresses

How can a client or a server find a pair of socket addresses for communication? The situation
is different for each site.

Server Site

The server needs a local (server) and a remote (client) socket address for communication.

Local Socket Address The local (server) socket address is provided by the operating system.
The operating system knows the IP address of the computer on which the server process is
running. The port number of a server process, however, needs to be assigned. If the server
process is a standard one defined by the Internet authority, a port number is already assigned
to it. When a server starts running, it knows the local socket address.

Remote Socket Address The remote socket address for a server is the socket address of the
client that makes the connection. Because the server can serve many clients, it does not know
beforehand the remote socket address for communication. The server can find this socket
address when a client tries to connect to the server. The client socket address, which is
contained in the request packet sent to the server, becomes the remote socket address that is
used for responding to the client.

Client Site

The client also needs a local (client) and a remote (server) socket address for communication.

Local Socket Address The local (client) socket address is also provided by the operating
system. The operating system knows the IP address of the computer on which the client is
running. The port number, however, is a 16- bit temporary integer that is assigned to a client
process each time the process needs to start the communication. The port number, however,
needs to be assigned from a set of integers defined by the Internet authority and called the
ephemeral (temporary) port numbers. The operating system, however, needs to guarantee that
the new port number is not used by any other running client process.

Remote Socket Address Finding the remote (server) socket address for a client, however,
needs more work. When a client process starts, it should know the socket address of the
server it wants to connect to. We will have two situations in this
case.
Sometimes, the user who starts the client process knows both the server port number
and IP address of the computer on which the server is running. This usually occurs in
situations when we have written client and server applications and we want to test them
Although each standard application has a well-known port number, most of the time,
we do not know the IP address. This happens in situations such as when we need to contact a
web page, send an e-mail to a friend, or copy a file from a remote site. In these situations, the
server has a name, an identifier that uniquely defines the server process. Examples of these
identifiers are URLs, such as www.xxx.yyy, or e-mail addresses, such as [email protected].
The client process should now change this identifier (name) to the corresponding server
socket address.

1.8 Application Layer

 The application layer is the highest layer in the protocol suite.


 The application layer provides services to the user.
 Communication is provided using a logical connection, which means that the two
application layers assume that there is an imaginary direct connection through which
they can send and receive messages.
 The application layer is the only layer that provides services to the Internet user
 The application layer exchange messages with their peers on other machines
 Applications need their own protocols. These applications are part of network
protocol.

Types of Application Protocols:


Standard and Nonstandard Protocols

Standard Application-Layer Protocols

o There are several application-layer protocols that have been standardized


and documented by the Internet authority.

o Each standard protocol is a pair of computer programs that interact with the
user and the transport layer to provide a specific service to the user.

o Two very widely-used standardized application protocols:

SMTP: Simple Mail Transfer Protocol is used to exchange electronic


mail.

HTTP : Hyper Text Transport Protocol is used to communicate


between Web browsers and Web servers.

Nonstandard Application-Layer Protocols


o A programmer can create a nonstandard application-layer program if they can write two
programs that provide service to the user by interacting with the transport layer.
Application-Layer Paradigms

Two paradigms have been developed for Application Layer


1. Traditional Paradigm : Client-Server
2. New Paradigm : Peer-to-Peer

Client-Server Paradigm
o The traditional paradigm is called the client-server paradigm.
o It was the most popular Paradigm.
o In this paradigm, the service provider is an application program, called the server process; it
runs continuously, waiting for another application program, called the client process, to make
a connection through the Internet and ask for service.
o The server process must be running all the time; the client process is started when the
client needs to receive service.
o There are normally some server processes that can provide a specific type of service, but
there are many clients that request service from any of these server processes.

Peer-to-Peer(P2P) Paradigm
o A new paradigm, called the peer-to-peer paradigm has emerged to respond to the needs of
some new applications.
o In this paradigm, there is no need for a server process to be running all the time and
waiting for the client processes to connect.
o The responsibility is shared between peers.
o A computer connected to the Internet can provide service at one time and receive service at
another time.
o A computer can even provide and receive services at the same time.
Mixed Paradigm
o An application may choose to use a mixture of the two paradigms by combining the
advantages of both.
o For example, a light-load client-server communication can be used to find the address of
the peer that can offer a service.
o When the address of the peer is found, the actual service can be received from the peer by
using the peer-to-peer paradigm.

1.8.1 The HyperText Transfer Protocol (HTTP)

 The HyperText Transfer Protocol (HTTP) is used to define how the client- server programs
can be written to retrieve web pages from the Web.
 It is a protocol used to access the data on the World Wide Web (WWW).
 The HTTP protocol can be used to transfer the data in the form of plain text, hypertext,
audio, video, and so on.
 HTTP is a stateless request/response protocol that governs client/server communication.
 An HTTP client sends a request; an HTTP server returns a response.
 The server uses the port number 80; the client uses a temporary port number.
 HTTP uses the services of TCP , a connection-oriented and reliable protocol.
 HTTP is a text-oriented protocol. It contains embedded URL known as links.
 When hypertext is clicked, browser opens a new connection, retrieves file from
the server and displays the file.
 Each HTTP message has the general form

START_LINE <CRLF>
MESSAGE_HEADER <CRLF>
<CRLF> MESSAGE_BODY <CRLF>
where <CRLF> stands for carriage-return-line-feed.
Features of HTTP

o Connectionless protocol:
HTTP is a connectionless protocol. HTTP client initiates a request and waits for a response
from the server. When the server receives the request, the server processes the request and
sends back the response to the HTTP client after which the client disconnects the connection.
The connection between client and server exist only during the current request and response
time only.

o Media independent:
HTTP protocol is a media independent as data can be sent as long as both the client and
server know how to handle the data content. It is required for both the client and server to
specify the content type in MIME-type header.

o Stateless:
HTTP is a stateless protocol as both the client and server know each other only during the
current request. Due to this nature of the protocol, both the client and server do not retain the
information between various requests of the web pages.
HTTP Request And Response Messages
 The HTTP protocol defines the format of the request and response messages.

Request Message: The request message is sent by the client that consists of a request line,
headers, and sometimes a body.
Response Message: The response message is sent by the server to the client that consists of
a status line, headers, and sometimes a body.

HTTP Request Message

The first line in a request message is called a request line.


After the request line, we can have zero or more request header lines.
The body is an optional one. It contains the comment to be sent or the file to be published
on the website when the method is PUT or POST.

Request Line
There are three fields in this request line - Method, URL and Version.
The Method field defines the request types.
The URL field defines the address and name of the corresponding web page.
The Version field gives the version of the protocol; the most current version of
HTTP is 1.1.
Some of the Method types are:
Request Header
 Each request header line sends additional information from the client to the server.
 Each header line has a header name, a colon, a space, and a header value.
 The value field defines the values associated with each header name.
 Headers defined for request message include:

Body
The body can be present in a request message. It is optional.
Usually, it contains the comment to be sent or the file to be published on the website when
the method is PUT or POST.

Conditional Request
A client can add a condition in its request.
In this case, the server will send the requested web page if the condition is met or inform
the client otherwise.
One of the most common conditions imposed by the client is the time and date the web
page is modified.
The client can send the header line If-Modified-Since with the request to tell the server that
it needs the page only if it is modified after a certain point in time.

HTTP Response Message

 The first line in a request message is called a status line.


 After the request line, we can have zero or more response header lines.
 The body is an optional one. The body is present unless the response is an error
message.
Status Line
 The Status line contains three fields - HTTP version , Status code, Status
phrase
 The first field defines the version of HTTP protocol, currently 1.1.
 The status code field defines the status of the request. It classifies the HTTP
result. It consists of three digits.
1xx–Informational, 2xx– Success, 3xx–Redirection, 4xx–
Client error, 5xx–Server error
 The Status phrase field gives brief description about status code in text form.
 Some of the Status codes are

Response Header
 Each header provides additional information to the client.
 Each header line has a header name, a colon, a space, and a header value.
 Some of the response headers are:

Body
 The body contains the document to be sent from the server to the client.
 The body is present unless the response is an error message.

HTTP CONNECTIONS

 HTTP Clients and Servers exchange multiple messages over the same TCP connection.
 If some of the objects are located on the same server, we have two choices: to retrieve each
object using a new TCP connection or to make a TCP connection and retrieve them all.
 The first method is referred to as a non-persistent connection, the second as a persistent
connection.
 HTTP 1.0 uses non-persistent connections and HTTP 1.1 uses persistent connections .

Non-Persistent Connections
 In a non-persistent connection, one TCP connection is made for each request/response.
 Only one object can be sent over a single TCP connection
 The client opens a TCP connection and sends a request.
 The server sends the response and closes the connection.
 The client reads the data until it encounters an end-of-file marker.
 It then closes the connection.

Persistent Connections
 HTTP version 1.1 specifies a persistent connection by default.
 Multiple objects can be sent over a single TCP connection.
 In a persistent connection, the server leaves the connection open for more requests after
sending a response.
 The server can close the connection at the request of a client or if a time-out has been
reached.
 Time and resources are saved using persistent connections. Only one set of buffers and
variables needs to be set for the connection at each site.
 The round trip time for connection establishment and connection termination is saved.

Http Cookies

 An HTTP cookie (also called web cookie, Internet cookie, browser cookie, or simply cookie)
is a small piece of data sent from a website and stored on the user's computer by the user's web
browser while the user is browsing.

 HTTP is stateless , Cookies are used to add State.

 Cookies were designed to be a reliable mechanism for websites to remember stateful


information (such as items added in the shopping cart in an online store) or to record the user's
browsing activity (including clicking particular buttons, logging in, or recording which pages
were visited in the past).

 They can also be used to remember arbitrary pieces of information that the user previously
entered into form fields such as names, addresses, passwords, and credit card numbers.
Components of Cookie
A cookie consists of the following components:

1. Name
2. Value
3. Zero or more attributes (name/value pairs). Attributes store information such
as the cookie's expiration, domain, and flags.

Creating and Storing Cookies


The creation and storing of cookies depend on the implementation; however, the principle is
the same.
1. When a server receives a request from a client, it stores information about the client in a
file or a string. The information may include the domain name of the client, the contents of
the cookie (information the server has gathered about the client such as name, registration
number, and so on), a timestamp, and other information depending on the implementation.
2. The server includes the cookie in the response that it sends to the client.
3. When the client receives the response, the browser stores the cookie in the cookie
directory, which is sorted by the server domain name.

Using Cookies
 When a client sends a request to a server, the browser looks in the cookie directory to see
if it can find a cookie sent by that server.
 If found, the cookie is included in the request.
 When the server receives the request, it knows that this is an old client, not a new one.
 The contents of the cookie are never read by the browser or disclosed to the user. It is
a cookie made by the server and eaten by the server.

Types of Cookies

1.Authentication cookies
These are the most common method used by web servers to know whether the user is logged
in or not, and which account they are logged in with. Without such a mechanism, the site
would not know whether to send a page containing sensitive information, or require the user
to authenticate themselves by logging in.

2.Tracking cookies
These are commonly used as ways to compile individuals browsing histories.
3.Session cookie
A session cookie exists only in temporary memory while the user navigates the website. Web
browsers normally delete session cookies when the user closes the browser.

4.Persistent cookie
Instead of expiring when the web browser is closed as session cookies do, a persistent cookie
expires at a specific date or after a specific length of time. This means that, for the cookie's
entire lifespan , its information will be transmitted to the server every time the user visits the
website that it belongs to, or every time the user views a resource belonging to that website
from another website

Http Caching
HTTP Caching enables the client to retrieve document faster and reduces load on the
server.
HTTP Caching is implemented at Proxy server, ISP router and Browser.
Server sets expiration date (Expires header) for each page, beyond which it is not cached.
HTTP Cache document is returned to client only if it is an updated copy by checking
against If-Modified-Since header.
If cache document is out-of-date, then request is forwarded to the server and response is
cached along the way.
A web page will not be cached if no-cache directive is specified.

HTTP SECURITY
HTTP does not provide security.
However HTTP can be run over the Secure Socket Layer (SSL).
In this case, HTTP is referred to as HTTPS.
HTTPS provides confidentiality, client and server authentication, and data
integrity.

1.8.2 FTP (FILE TRANSFER PROTOCOL)

FTP stands for File transfer protocol.


FTP is a standard internet protocol provided by TCP/IP used for transmitting the files from
one host to another.
It is mainly used for transferring the web page files from their creator to the computer that
acts as a server for other computers on the internet.
It is also used for downloading the files to computer from other servers.
Although we can transfer files using HTTP, FTP is a better choice to transfer large files
or to transfer files using different formats.

FTP OBJECTIVES
It provides the sharing of files.
It is used to encourage the use of remote computers.
It transfers the data more reliably and efficiently.
FTP MECHANISM

The above figure shows the basic model of the FTP.


The FTP client has three components:
o user interface, control process, and data transfer process.
The server has two components:
o server control process and server data transfer process.

FTP CONNECTIONS
There are two types of connections in FTP - Control Connection and Data Connection.

The two connections in FTP have different lifetimes.

The control connection remains connected during the entire interactive FTP session.

The data connection is opened and then closed for each file transfer activity. When a user
starts an FTP session, the control connection opens.

While the control connection is open, the data connection can be opened and
closed multiple times if several files are transferred.

FTP uses two well-known TCP ports:

o Port 21 is used for the control connection


o Port 20 is used for the data connection.
Control Connection:
o The control connection uses very simple rules for communication.
o Through control connection, we can transfer a line of command or line of response at a
time.
o The control connection is made between the control processes.
o The control connection remains connected during the entire interactive FTP session.
Data Connection:
o The Data Connection uses very complex rules as data types may vary.
o The data connection is made between data transfer processes.
o The data connection opens when a command comes for transferring the files and closes
when the file is transferred.

FTP COMMUNICATION
FTP Communication is achieved through commands and responses.
FTP Commands are sent from the client to the server
FTP responses are sent from the server to the client.
FTP Commands are in the form of ASCII uppercase, which may or may not be followed
by an argument.
Some of the most common commands are:
Every FTP command generates at least one response.
A response has two parts: a three-digit number followed by text.
The numeric part defines the code; the text part defines needed parameter.

FTP FILE TYPE


FTP can transfer one of the following file types across the data
connection: ASCII file, EBCDIC file, or image file
FTP DATA STRUCTURE
FTP can transfer a file across the data connection using one of the following data structure
: file structure, record structure, or page structure.
The file structure format is the default one and has no structure. It is a continuous stream
of bytes.
In the record structure, the file is divided into records. This can be used only with text files.
In the page structure, the file is divided into pages, with each page having a page number
and a page header. The pages can be stored and accessed randomly or sequentially.

FTP TRANSMISSION MODE


FTP can transfer a file across the data connection using one of the following three
transmission modes: stream mode, block mode, or compressed mode.
The stream mode is the default mode; data are delivered from FTP to TCP as a continuous
stream of bytes.
In the block mode, data can be delivered from FTP to TCP in blocks.
In the compressed mode, data can be compressed and delivered from FTP to TCP.

FTP FILE TRANSFER


File transfer occurs over the data connection under the control of the commands sent over
the control connection.
File transfer in FTP means one of three things:
o retrieving a file (server to client)
o storing a file (client to server)
o directory listing (server to client).

FTP SECURITY
FTP requires a password, the password is sent in plaintext which is unencrypted. This
means it can be intercepted and used by an attacker.
The data transfer connection also transfers data in plaintext, which is insecure.
To be secure, one can add a Secure Socket Layer between the FTP application layer and
the TCP layer.
In this case FTP is called SSL-FTP.

You might also like