Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Chapter 5, 6, 7

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 135

Chapter:5

DHCP

_________________________,________. ._________,__________________,________

--------------------------------------------------------------------- ,------------------------,----------------------------------_--------------------_---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1----------------------,--------------------------.

Syllabus:
Host Configuration:

DHCP
Domain Name System (DNS)
Remote Login:
o
TELNET and
o
SSH

File Transfer:
o
FTP and o
TFTP

5.1 DHCP (Dynamic Host Configuration Protocol)


_______________________________________________________________
5.1.1

Introduction
DHCP (Dynamic Host Configuration Protocol) is a protocol which helps to do the
automatic assignment of IP (Internet Protocol) configurations on a computer network
and can be manage centrally by network administrators.

We use protocols like TCP/IP for communication in the computer network.

In the computer network for communicating with each other; computer system requires
the systems must have unique IP address. In the present scenario computers are
frequently moved and new systems ge (t added to a network. Without DHCP, the IP
address must be entered manually at each computer system.

DHCP helps network administrator to control and distribute IP addresses from a central
point.
i.

The purpose of DHCP is to provide the dynamic allocation of IP client configurations


for a specific time period (called a lease period) which reduces burden from adminis:eto handle whole network manually.

Client-Server model is useful for working of DHCP.


Client: A host requesting initialization parameters from a DHCP server.
Server : The host providing initialization parameters through DHCP

5.1.2

DHCP server hosts all located network addresses and deliver required configuratics
parameters to dynamically configured hosts.
DHCP Packet Format

The fields of DHCP packages are as follows:

Operation code : 8bits


Defines two types; "request" by 1 and "reply" by 2

Hardware type : 8 bits


It defines the type of physical network like Ethernet value is 1.

Hardware Length: 8bits


It defines the length of physical address in bytes like Ethernet value is 6.

Hop count: 8bits


The number of hops the packet travel while travelling from source to destination.

Transaction ID: 4bytes


It is given by client to each packet by which it can match to the reply send from the
server.

Number of seconds: 16 bits


The time passed from when the client boot in.

Flags: 16 bits
from the flag first bit is mentioned with 0 or 1 and other 15 bits are zero bits.
0 means "Unicast" and 1 means "broadcast"

Client IP address : 4 byte It


gives client IP address.
Your IP address : 4 byte
It gives client IP address. It is filled by server in the reply at the clients request.

Server IP address : 4 byte


It gives server IP address. Filled by server.

Gateway IP address : 4 byte

It gives routers IP address. Filled by server.


Client hard ware address : 16 byte It
gives physical address of client.
Server Name : 64 bytes
It is optional field. Gives domain name of server.
Boot filename: 128 bytes

It is

optional field, Client can get extra information about booting.


Options : 64 bytes
It specifies the additional information. It
specifies three fields:
1 byte for tag , 1 byte length ''and other is variable for length field.

5.1.3

Working

Client broadcasts a request for the address information from systems while starting with
TCP connection

DHCP server receives a request from systems(client) then it assigns a new address for a
specific time period to a system called as Lease Time meaning no wasted numbers.

DHCP server sends this dynamic addresses to the client together with the other required
configuration information.
To set up its configuration this information is acknowledged by the client system.

5.1.4

The DHCP server will not restructure the address during the lease period and will
attempt to return the same address every time the client requests an address.
The client may extend its lease with successive requests, and may send a message to the
server before the lease expires telling it that it no longer needs the address so it can be
released and assigned to another client on the network.
DHCP Message Passing:
The DHCP connection states are as shown below;

The message passing between client and server takes place by using the following
various message types which are explained in state transition diagram

5.1.5

DHCP Transition Diaaram

Fig. 5.1.3: DHCP Transition Diagram


The client and server sends dynamic configuration messages by using following states:
LNIT State:
It is called as initialization state. Client sends broadcast message DHCPDISCOVER
using port 67.
SELECTING State:
The server than response with DHCPOFFER message and blocks own IP address to be
unavailable for other users. If there is no reply from any server than client goes for sleep and sends
DHCPDISCOVER again.
REQUESTING State :
Client sends DHCP REQUEST message to the selected server and gets connected with
the server using IP address.
Bound State:
Client uses IP address of server until the lease time does not become half. If it goes
delow 50% then again client sendsDHCPDISCOVER to renew the connection.

RENEWING State:
When client gets DHCACK (acknowledgement) back from server the connection get
renewed. If client does not get the DHCACK then It goes to rebinding state.
REBINDING State:
If client gets DHCPACK then it goes to the rebind state and connection is establishes
again. Else the client broadcast the DHCPDISCOVER to search new server,

5.1.6

Manual configuration requires the careful input of a unique IP address, subnet mask
default router address and a Domain Name Server address.

Computer network is a growing web where it is really difficult for a system


administrator to manually add all the IP and the configurations to an individual system
where many systems are getting added in the network at every second. For a network
administrator this process can be lengthy, monotonous and error prone.

DHCP offers flexibility and ease-of-use.

Advantages of DHCP over Manual Configuration Methods

From a "set" of existing addresses DHCP server automatically assigned dynamic


configuration to each client for a specific time period .

When a client has finished with the operations, it is released for another computer to

5.1.7 Mobile Computing:

DHCP is advantageous to provide dynamic addressing in environments where users


frequently change locations.

Mobile users simply plug-in their systems to the network and receive their required
configuration dynamically.
The configuration will be supplied by the network's server when moving to a differem
network using a DHCP server.

Manual reconfiguration is not required.

5.1.8 DHCP Servers Set-up and Administer

TCP/IP client configurations, including IP address, gateway -address and DNS address
are centrally managed by DHCP Servers

DHCP servers can be easily set-up and are easy to manage

Client addresses are assigned dynamically which requires the manual input of client
addresses which can be a time consuming and tedious task.
\,,

5.1.9 Limitations

Some fixed addresses machines on network for example servers and routers. The DHCP
server should be capable of assigning pre-allocated addresses to these specific machines.

Users should be prevented from reconfiguring their own IP addresses to avoid conflicts
between addresses assigned by the DHCP server and those assigned manually

We are able to upgrade the system which is having older operating systems because older
operating systems do not support DHCP.
If upgradation is not possible then systems may support the older BOOTP protocol.

____________________________________________________________________________________

5.2 The Domain Name System


_______________________________________________________________

The Internet users are not able to remember the IP addresses of all the web sites that
users wanted to visit

The Domain Name System acts as a bridge between domain names and IP addresses of
devices connected in the Internet
o A domain name (a part of the URL) is a unique alphanumeric name such as

gmail.com o Here the top level domain name is "com" o the secondary level domain
name is "gmail".

A huge amount of data related to various sites is divided among the number of systems
to avoid the burden on single system.
DNS uses services of UDP or TCP on the well-known port 53.
The working mechanism of DNS is also Client-Server Model.

5.2.1 Name Space:


To avoid the risk of remembering IP addresses now users need to remember the unique
names assigned to machines which maps each others.

there are are two types :


Flat name space - where the names are directly assigned to an address. It is just a

sequence of characters.
Hirerarchical name space - In this kind of name space the names are organized as per

the hierarchies in the organization.


For example; first part defines Mumbai University i.e. Nature of organization.
Second part defines Engineering College i.e. Part from organization
Thired part defines ABC college i.e. Name of college.
Fourth part defines IT department i.e. Name of department etc.

5.2.2 Domain Name Space :


The domain name space is defined using the inverted tree structure starts from the root
Lable : Each node in the tree has name called as label. Each node has an unique name

to avoid an ambiguities. The lables are used as key in domain name searching.
Domain Name : Each node has a unique domain name.the domain names are read

from bottom to root node.Root node is having null name string.


For example; As shown in the Fig. 5.2.1 the lables and domain names are mentioned

from bottom node to the root node.

Root

Types of Domain Name:


a)

Fully Qualified Domain Name :

If the lables are terminated with the root node i.e. Null string then it is known as

fullyQualified Domain Name (FQDN).


For example; as shown in the above figure FQDN is "challenger.atc.fhda.edu."

b)

Partially Qualified Domain Name :

If the lables are not terminated with the root node i.e. Null string then it is known

Partially Qualified Domain Name (PQDN).

Fig. 5.2.2

5.2.3 Distribution of Domain Names :

Many servers are connected to root server like arpa server, edu server, com server, us
server etc.
Then further many users are connected to individual servers;
1. To edu server; fhda and bk clients are connected
2. To com server ; mcgraw and Irwin clients are connected
The root node is classified into various domain servers and further the individual domain
server are divided into sub-domain servers.
There is hierarchies of domain server as it is in the Name space.

5.2.4 Domains:

IP address and domain name allocation requires central administration to avoid


ambiquities.
This allocation process was previously administered by U.S. government contract (N 5
In 1998, technical coordination assigned to ICANN (Internet Corporation for Assigned
Names and Numbers).

a)

Inverse Domain :

In the inverse domain the address is written from index to names.

For example : 121.45.34.132.in-addr.arpa

5.2.5 Zone and Domains :

Root server having authority of whole tree and also it keeps track of all the servers under
each servers.

A primary server loads all information about servers which are sub parts of it on the
local disk file.

The primary server has all the authority about the sub severs under it and also able to
perform the operations like updation, modification, deletion etc.

The secondary server loads all information from the primary server. It dose not have any
authority to do any modifications in the information related with the server.
When the primary downloads information from the secondary, it is called zone transfer.

5.2.6

DNS In the Internet:

Examples of top level domains :

Generic top level domains :

The generic domains are nothing but the register

ed hosts. It allows almost 14

possible labels which describes the organization types as listed below:

.com - It defines commercial organization

.org - Shows non profit organization

.biz - Describes business or any commercial firm

.gov - Explains government institutes

.info - Defines information service provider

.int - shows international organization

.edu - Describes educational institutes

.aero - airlines and aerospace companies are defined

.mil - describes about military group

.name - personal names are described

.net - network support system is explained

.coop - shows cooperative business organization

.pro - explain about professional organization

.museum - museums and other non-profit organizations are mentioned etc. For
Example : chal.atc.fhda.edu

2.

Fig. 5.2.7

Country codes (2 character codes):

It uses two characters from the name of the country.


3.

.jp, .in, .us, etc

For Example: anza.cup.ca.us


*

5.2.7

How DNS works ?

The user adds URL in the address bar.


From the URL client browser tries to get the domain name server where list of all the

domain names along with their respective IP addresses are maintained.


The domain name gives details like the IP address related with the particular domain
name.
Then name server sends reply to the client brouser along with the requsted web page's
IP address.
Then client brouser retrieves the required page from the specific IP address.
5.2.8 Resolution :

The Resolutions which we use to trace the path from client to required server.lt may
map address to name or name to address by using the help of resolver.

Resolver:

A host or DNS Client which helps to map an address to name or names to an address.

There are two types of resolutions :


:

Recursive resolution :

In this type of client starts searching for required server by following the
listed
domains.
>

The client wants to send data over the internet to the destination mcgraw.com ;
where .com is domain and mcgraw is a name of receiver's mail box.

Client first ask to its neighbour about intended destination. If the system is the
destination then it answers with the positive reply email by following the
neighbours in the path; till it reaches to thelse it ask tio next parential neighboring
node about required destination.

When a particular system found the destination; the server sends positive response
to the client by reward back on the same path.

Finally client can connect to the respective server via following the same path.

In this process client searches the destination by following the path in a sequence
which reaches to the required destination.

--------- -0

c)

Interactive Resolution :

Client start searching the respective server but client sends one-to-one message to
check whether the current place is required server.

The client ask for intended system if the receiver is required machine then search
is completed and sends positive relpy.

If client does not get positive reply from system then it sends ip address c: another
neighbor which can complete the search of client client.

When it founds the required destination; the server sends positive reply the:
finally mail transfer takes place between client and server.

"-

A-

if. > '

'

5.2.10 5.2.9

Fig.

DNS Messages :

There are two types of DNS messages :

1. Query
2. Response

a) Query and Response Messages :

Query message contains Header and Question Section

Response message contains% various sections like Header, Question section.


Answer section, Authoritative section, Additional section.

5.2.12 b)

Fig.

Header Format:
The Identification part maintains :

1. Number of question records


2. Number of authoritative records The
Flags maintains :

1. Number of ans wer records


2. Number of ?dditional records.

c)

Flags Field:
The fields of flags are mentioned below :

QR :

Query/Response

OpCode

AA:

Authoritative

TC :

Truncated

RD

0 standard, 1 inverse, 2 server status

Recursion Desired
.|

R
A
:
R
e
c
u
r
s
i
o
n
A
v
a
i
l
a
b
l
e
r
C
o
d
e
:
S
t
a
t
u

s
o
f
t
h
e
e
r
r
o
r
d
)
T
y
p
e
s
o
f
R
e
c
o
r
d
s
:
1.

Question Record format:

It maintains the details about Query Name, Query type, Query class etc.

2.
Query name
Format:

5.3 Remote Login :


__________________________________________________________
5.3.1 TELNET (TErmial

NETwork) (a)

Introduction:

TELNET is general purpose client-server type application protocol useful in TCPIP model for remote system communication.

Communicate by transferring data and control characters (ASCII) format over the
connection.

TELNET client works on ephemeral ( any available port) and TELNET server
works on port 23.

Remote login is useful for remote process access. It means it helps for
communication with two remote systems.

Remote login works as TCP-IP protocol follows client - server architecture on port
513

TELNET was innovated when operating systems where following time - sharing
environment.

In time sharing scenario user feels like it is working on dedicated system for
accessing a resources, running application programs for other systems etc.

(b)

Login:

Since many users are related with each other via central server the security must
be included via authenticated login.

User can access information from the server by using individuals authenticated
login id.

User can login to the system using "username",

"password".
Types of Login:
a)

Local Login:

To connect with any system in a network users have to provide his/her details to a
local server.

When users enters data using keyboard or any input device it is given to
terminal: driver of operating system.
Then termin?! drivers passes the accepted characters to the operating system and
then finally given to the desired application program as shown in the figure.

b)

Remote LOGIN:

In the above case the user able to use the local applications.

To connect with the applications running on the remote system can be done with
the 2.help of remote login as shown in the figure.

Client side:

The client sends data through input devices tothe terminal driver.

Then local operating system access it without interpreting it.

The input characters are sent to the TELNET client to convert it into universal
character set called as Network Virtual Terminal(NVT) Because of this the
character set can be considered in standard format.

This NVT set than given to TCP-IP stack at the client side.
Server side:

Than this set is forwarded over the internet and added to the TCP-IP stack at the
remote side.

This set is forwarded to operating system of remote machine but since it cannot
interpret directly it is given to the TELNET server

From TELNET server it is given to pseudo terminal driver which gives proper
interpretation and then forwarded via server side operating system to an
appropriate application program.

(c)

Network Virtual Terminal:

Since in the network many heterogeneous systems are connected with each other
individual system has its own operating system, terminal drivers etc.

When client TELNET transfers the data over the internet to remote TELNET the
character set considered by client machine is translated in Universal character set
called as "Network Virtual Terminal" (NVT).

Server TELNET than consider this NVT and transfer that into the format which is
acceptable by remote machine.

'

'

'

'

'

"

'

'

'

'

'.'- ...

.___ .,- .

-- --.__

5.3.3 (d)

Fig.

TELNET Character Set:

The NVT character considers two different character set:

a) Data character set (8 bits)


b) Control character set (8 bits) a)
Data character set:
In data character set from 8 bits; lower seven bits are the ASCII values and the highest j
bit is represented as "0".
This is decided among client and server using option negotiation.

b)

Control character set:

In control character set from 8 bits; lower seven bits are the ASCII values and the
highest bit is represented as "1"( just replacing 1 on place of 0 in above fig)

Some examples of NVT control characters along with their binary representation
EOF (End Of File): 11101100

EOR ( End Of Record): 11101111 NOP

(No Operation): 11110001 BRK (Break):


1111011 IP (Interrupt process): 11110100 (e)
Embedding:

The TELNET works on single connection ofTCP.

As mentioned earlier TELNET Client uses ephemeral port and TELNET Server
uses port 23.
Since TELNET contains data and control character sets for distinguish between
them special control characters are used like I AC (Interrupt As Control).

For example as given below:

Client sends: cat filel

the "cat" is unix command which helps to display the content.


Client sends: cat filea <backspace> 1
It means the file name is wrongly printed as " filea" istead of "filel" by using
backspace in the command this correction can be done at server side it is not
possible to do st client side.
The two control characters are added (embedded) in message instead of backspace
the characters are "LAC" and "EC".

5.3.5 (f)

Fig.

Options:

To connect with the remote server and transfer data over it requires proper
connection between client and server TELNET.
Before the transmission of data both the ends negotiate options available and also
the features available.
Some examples of options are listed below;
0 - binary

useful for interpreting 8 bit data

1 - echo

display the data from one side to


other. 5 - status

represents status of

TELNET 24 - terminal type


he

lps to represent Terminal type


34 - terminal speed >

helps to represent Terminal speed

-s

gi

Option Negotiation :

Option negotiation plays an important in TELNET option setting.

Four control characters along with their code and meanings are considered as
follows;

Will - 251

helps for offering to enable the options

Wont -252 represents that the enable of the options not

possible

Do -253

It request for enabling the options

Dont -254

It rejects the

selected option.
1.

Offer to enable :

2.

Request to enable :

3.

Offer to disable :

Echo option example:

By using IAC, Do and ECHO commands client ask for the considering the data
transferred at sever side

The echo option is available on server side is stated using Echo, Will and IAC

Fig. 5.3.7

Example of interrupting an application program :

On local system applications aborted by user.

But on remote system this should be done by using special control character i.e. IP
(Interrupt Process).
As we are able to see in the figure the interrupt is occurred using IP and then server
sends aborted status to the application on server's side

5.3.8 h)

Fig.

Modes of Operation :

The modes of TELNET are as listed below;

a)

Default Mode:
This mode is used if no other mode is selected from the option negotiation.

b) Character mode:

The client sends a character till full line is completed and sends echo signal to
server for displaying the data.
The client waits for go ahead command from server .It works as half duplex mode.

In this mode the client sends each character to the server.


Server sends an acknowledgement of received character and echo's the sent I
character.
Then finally client also sends an acknowledgement to the server about the receiver
of echoed character.
c) Line mode:

In this mode merits of both default mode and character mode combined together.

In the line mode the whole line is sent by client to server only after editing.

It is not as default mode because it does not wait for go ahead from server side

It works as full duplex

mode.
(i)

The Rules of Negotiation :


The rules of negotiation are explained below;

At the time of mode change the requests must be issued.

The parties should acknowledge the mode as they receive a mode change request j

A request must be inserted properly after the completion.

It should be added at the place where it takes effect.


5.3.2 SSH (Secure

SHell) (a)

Introduction:

Internet access has became a vital and available, it has become an essential replacement
for traditional couriers, telephone, and fax, as well as remote dial-up access to a companys
internal computer resources.
One of the biggest challenge in using the Internet is security.
Secure Shell is a protocol helps to provide authentication for secure users login
encryption for data security and data integrity to communicate with "several users in the
network.
Secure Shell provides following facilities :

It
provides file transfer which is secure, secure access of remote
machines and also having own commands which provides secure
programming

In the most popular operating systems secure Shell client


and server applications are widely available.
Securing data sent over a public networ is offed by Secure Shell.
(b)

What is SSH ?
SSH is a protocol for secure remote login and other secure network/services over
an insecure network.
/
I

Developed by SSH Communications Security Corp., Finland


I
It is useful as a standard for unencrypted unix utilities such as telnet, rlogin, and
rsh.

Agent which allows arbitrary TCP/IP to be forwarded over a secure channel.

It is useful for entrusted hosts on insecure networks mostly when work from home
facility is available.

Commercial version

Free ware (www.openssh.com): Specified in a set of Internet drafts

(c)

Working of SSH :

For the security purpose many algorithms are available.

e)

If user uses protocols that can not be routed over SSH e.g. UDP based services or
user's client machines don't support SSH; then no need of using SSH.

Otherwise, SSH will benefit user's network.


(d)

Need of SSH :

If user trust local users/ISP/Script; then there is no requirement of SSH.

Two distributions are available :

The RSA public key cryptography algorithm is useful while connection


establishment i.e. during handshake between client side and server side.
SSH security features :

It uses various algorithms for security purpose

Due to security algorithms; we are able to get,

authenticated login

secure connection between client - server

various encryption methods

secure access of remote data.


f)SSH Connection :
The data exchange in SSH takes place between client and server using TCP connection

First we go for TCP connection setup.

The client initiates the connection. The server listens on port 22.

Exchange of SSH version string between client and server

SSH version string exchange between client and server must end with "
\CR\LF".

It is used to indicate the capabilities of an implementation triggers, compatibility


extensions and current protocol version.
Between client and server the exchange of SSH key takes place with the help of
various algorithms after negotiation.

All packets that follow the version string exchange is sent using the Binary Packet
Protocol. The exchange of data takes place between client and server.

After the fulfilment of requirement the TCP connection gets terminated between
the client and sever.

5.4

File Transfer Protocols___________________________________

5.4.1 FTP (File Transfer

Protocol) (a)

Introduction

FTP is a widely accepted Internet Standard.


FTP follows standard client-server model. For successful FTP connection, therr
needs to exist both FTP client side program and FTP server side program.

FTP Server: Store the files accessed during t he file transfer

FTP Client: It send files or retrieve files by connecting to the FTP server.

In the FTP when client sent request to server for particular file server sends
response to client hence it is called as "request and response model"

There are two mandatory two ways transmission connections in FTP

(b)

Control connection (Command Control):

It keeps control between Client Control Processes and Server Control Processes
during the communication

Using Client side command for establishing the connection with the FTP server,
sending FTP commands, receiving responses from the SERVER.

Control Processes also known as Process Interpreter (PI).

It is also called as primary connection.

The FTP uses the Telnet protocol on the control connection.

By using this FTP client-server model; FTP client can transfer commands, which
describe the functions to be performed, and the FTP Server replies to these
commands.

(c)

(d)

Data Connection :
It helps to transfer require data between Client Processes and Server Processes
during the communication.
It is supportive for listening commands coming from a Client over the control
channel on a data port, establishing the connection for the control channel
Receiving FTP commands from the Client and responding them and running the
SERVER commands.
Data Transfer Process (DTP)

Fig. 5.4.2 : Data Connection between Client-Server

FTP works on TCP connection. It needs two TCP connections between client and
server.

The well-known port 2i is used for the control connection and the well-known
port 20 for the data connection.

Every FTP implementation must support the use of the default data ports,
and only the USER-PI can initiate a change to non-default ports.

Both the Client-server Data Transfer Processes have a default data port.

The transferring of data consists of setting up the data connection to the


appropriate ports and choosing the parameters for transfer.

(e) Working of FTP


Introduction

The client sends FTP commands to the server, the server interprets them, runs is
DTP, then sends a standard response.

Once the connection is established between Client and Server, the server-Pi gives
the port on which data will be sent to the Client DTP.

The client DTP then listens on the specified port for data coming from the server
After the data transmission is over the connection between Client and Se: :
terminated.

1.

Control Connection between Client - Server

By using control commands the connection establishment takes place between Client

and server.
Passive Open by Server :
As shown in the figure firstly the Server will Passive opens the Control connection

default port 21.

Active Open by Client: i

Then as shown in the figure the Client actively opens the connection on port 62010

2.

(b) Active open by


client Fig. 5.4.4

Data Connection between Client - Server

Passive Open by Client:


As shown in the figure firstly the DTP passively opens port number 63000 for

transferring the require data.


Active Open by Server :
As shown in the figure by using port 63000 Client sends ephemeral (temporary) port

number to server for data transfer process.


On default port 20 client starts sending data to server using data connection.

(f)

(c) Active open


by server Fig.
5,4,5

FTP Commands:

FTP commands specify:

Used Port numbers


. data transfer methods.

Data structure

The nature of the action to be conducted like Retrieve, List, Store, etc.
There are three different types of FTP commands with some examples are listed below;

a) Access control commands :


1. USER Character string useful for the user's identification. User
identification is necessary to establish communication between Client and
Server over the data channel.
2. PASS ( Password) Character string gives user's password. This command
followed by the USER command. We hide the display of this command for
security reasons.
3. CWD (Change Working Directory) it allows the current directory to be
changed.

The directory's access path can be given as an argument in the command.

4. QUIT Command helps to terminate the current session, The server


waits
to
finish the transfer but before closing the connection server checks for the
need of client and response for the need.

b) Transfer parameter commands :


1. PORT the port number can be specified using Character string.
2. TYPE Specifies the type of format in which the data will be sent is
specified,
3. STRU It indicates the character indicating the file structure
F for File, R for Record, P for Page

4.

MODE It gives data transfer method

Compressed c)

S for Stream, B for Block, C for


FTP service commands :

1. RETR It helps for retrieving copy of the file whose access path is given in
the parameters from the server DTP
2. STOR It helps to accept the data sent over the data channel and store them
in a file having the name given in the parameters.
If the file does not exist with the mentioned name, the server creates
it else overwrites, it,

3. DELE (delete) It helps to delete a file. The name is given in the parameters.
4. RMD (remove directory) It enables a directory to be deleted whose name is
indicated in the parameters.
5. MKD (make directory) It helps to create a directory . The name of the
directory to be created is mentioned in the parameters.
6. PWD (print working directory) It is useful to resend the complete current
directory path.
7. NOOP (no operations) It is only used, when there is a idle time between
client and server in order not to be disconnect the connection.
(g)

FTP Response
Introduction :

As we have seen FTP is request-response model; when server gets any request
command it reply using FTP response mechanism.

For each command from client; server try to answer it using appropriate response.
The responses are made up of using 3 digit code,
These 3 digit codes are difficult to remember by humans, hence it is accompanied
by a text.
The response codes are made up of 3 numbers the meanings of which are as follows;

1. The first digit: It recognize the status of the response (success or fail)
2. The second digit: It specifies what the response refers to.
3. The third digit: It provides a more specific meaning relative to each second digit
First Digit:

lyz Preliminary positive response

It helps to mention the action requested is in progress

2yz Positive fulfillment response

It shows the status of action requested has been fulfilled, a new command
can be sent.

3yz Intermediary positive response

It helps to show an action request is temporarily suspended. Addition^

information is awaited from the client.

4yz Negative fulfillment response


By using this response the client is requested to try again later. The previous
action requested has not taken place because the command has temporarily net
been accepted.

5yz Permanent negative response

This command helps to the client to formulate a different request. The command

has not been accepted since the action requested has not taken place.
Second Digit:

xOz Syntax

It helps to give response like;


The action has a syntax error or the command not understood by the server.

xlz Information
This response sends back an information for example a response to a STAT
command.

x2z Connections

' It shows the response related to the data channel.


x3z Authentication and accounts

It helps to show the response related to the login or the request to change
the account.
x4z File-transfer-protocol does not use this response.
x5z File system

system. (h)

This is the response related to the remote file


FTP Code examples

FTP reply codes are listed below:

FTP Reply Codes

5.4.2 TFTP (Trivial File Transfer

protocol) (a)

Introduction

TFTP is the Trivial File Transfer Protocol.


TFTP uses UDP which is connectionless approach to make it simple and small while
File Transfer Protocol (FTP), which uses TCP.

TFTP does not require authentication means no need of LOGIN while dealing with
it; hence we can say TFTP is less secure protocol.

Implementation of TFTP requires UDP, IP, and a device driver can fit on readonly
memory.

TFTP is also useful enough for diskless workstations but only for few Kbyte code.

It helps to download boot code from diskless workstations.

The exchange between client-server takes place from the server only because the
server can read or write a file for client.

(b)

Message Types

There are five types of messages;

1. Read Request (RRQ)


2. Write Request (WRQ)
3. Data
4. ACK (acknowledgment)
5. Error messages
Some error codes are as follows :

- not defined

- File not found

- Access violation

- Disk full

- Illegal TFTP operation

- Unknown port

- File already exists

- No such user

Each and every message format has 2 bytes reserved for OpCode ( Operation
Code)

The filename specifies the file on the server that the client wants to read from or
write to.

The Modes are netascii or octet

netascii: It is useful for transferring text files. All lines


end with \r\n (CR, LF). Provides standard format for
transferring text files. octet: It is useful for transferring
binary files.

(c)

TFTP Packet Formats


TFTP has

only positive

acknowledge

correctly received packets

are

acknowledged with an ACK packet. Hence we can call it as request-reply


protocol.

If sender does not receive ACK packet in appropriate time it re-sends the last
DATA packet.

TFTP uses port 69 as default port for sharing data within client and server.

Format (d)

Fig. 5.4.7 : TFTP packet

Read Request and Write Request Connections

Fig. 5.4.8 : TFTP Read Request Connection and TFTP rite Request

Connection e) TFTP Example

As shown in the Fig. 5.4.9 the connection can be established between client and I
server for data sharing.

By using main message formats this communication takes place.

The ERROR message can be due to lost packets, checksum errors.

Lost Data Packets :

Sender uses a timeout with retransmission.

Sender could be client or server.

Duplicate data packets must be recognized and ACK retransmitted.

Review Questions

Q. 1

Write a short note on WWW.

Q. 2

In electronic mail, what is MIME ?

Q. 3

Write a short note on proxy server.

Q. 4

What do mean by HTTP transactions.

Q. 5

Explain various functions of network management systems.

Q. 6

Explain the simple network management protocol (SNMP).

Q. 7

Write a short note on voice over IP.

Q. 8

Explain IMAP in details.

Q. 9

Explain how actually electronic mail transferred.

Q. 10

Explain role of POP and SMTP in electronic mail transfer.

Q. 12

Q. 11

Write a short note on multimedia internet technologies.

i
Explain various multimedia compression techniques.

Q. 13

Describe multiple multimedia services in details.

Q. 14

Explain architecture of world wide web.

Q. 15

Write a short note on DNS.

Q. 16

Explain various domains of name system.

Q. 17

Describe DNS header message.

Q. 18

Give DNS distribution of name space.

Q. 19

Explain name to address mapping using DNS.

Q. 20

Give E mail architecture and various protocols used in

process.

Q. 21

What are two categories of DNS messages ?

Q. 22

Write a short note on FTP.

Q. 23

Explain various FTP transmission modes.

Q. 24

Give functions of two FTP connections.

Q. 25

In electronic mail, what is MIME ?

Q. 26

How we can use DHCP.

Q. 27

What is need of DHCP protocol.

Q. 28

Explain working of DHCP server.

Q. 29

How TELNET works.

Q. 30

Write a short note on SSH.

Q. 31

Write a short note on TFTP.

____________________________________________________________________________

f?a

Application Layer Protocol

________________________________________________________________________________
y

Syllabus:

World Wide Web


HTTP

Electronic Mail:

SMTP, POP, IMAP and MIME

Network Management:

SNMIP, Multimedia

____________________________________________
i

6.1 World Wide Web (WWW)


___________________________________________________________
World Wide Web is system of interlinked hypertext documents accessed via Internet.

Web is collection of useful information and related resources interconnected via hyper
links.

World Wide Web is vast collection of information available on the Internet, which gives
data about any point at any moment.
For example some famous websites are:

www.google.com

www.wikipedia.com

www.yahoo.com

www.facebook.com

www.irtc.com

www.w3school.com etd

;
: :1

Web pages contains : o

Text: Number of simple or

complex documents.
o

images, o

Images : The information also contains the various types of related


Videos : The documents may also includes the videos which are related to

the

topic. o

Multimedia : The documents also contains flash,

sounds etc.
The Internet is really helpful for getting related information at only on a single click
and
without any hard work. The information can be used for a many of applications.

For example r
o

WWW

Email

Instant messaging

WWW provides information accesses in many ways are listed below;

Hyper linked i.e. Hypertext: the related web pages are linked with each other.
Graphical user interface : The front screen of any application.
Pictorial and non-text information : the images, videos, sound files are included in the
web pages for better clarity about the particular data.

Information that changes rapidly : the news flash, the weather forecast etc are updated
instantly on web.
Immediate access : The WWW provides immediate access of any web site on a click.

Anyone can author a web site : As some one ready with new application he/she can
launched it via launching the web site.

Multi-user access to the same information (try that with a book)


Easily search able information : Since information of particular point as well as the
other related data we are able to search with the help of web pages over the Internet
*

The functionality of the WWW is based on 3 main

standards: o

URL (Universal Resource Locater) o

HTML (Hypertext Mark-up Language) o

HTTP (Hypertext

transfer Protocol)

6.1.1

a)

The Major parts of WWW


Web Pages:

Large numbers of documents which are part of WWW are called as Web Pages.

Most of the documents are constructed,, designed and written using spec:a
languages called as "HTML" i.e. Hyper Text Mark up Language.

b)

Web Browser:

Users can view the information available on the web through the software
programs called "Web Browsers"

Some examples of web browsers are as follows; o


Netscape Navigator

Internet

Explorer o

Opera o

Chrome

c)

Hyperlink:

The WWW content can be navigated by clicking the hyper links i.e. the Underlined or

Boldfaced words, icons or images on the web pages.


d)

URL (Uniform Resource Locator):

Each page of information on the web has a unique address called the URL by
which it can be found.

It is also known as web address.


It is useful by browsers to locate a particular website form the large number of
data available

There is difference between URL and Email address.

Example of URL: http://google.com

URL provides address of website which user wants to access .

Example of Email Address: xyzl2@gmail.com

The email address is related with an individual and it helpful for storing emails.

Sample Examples of URL or Internet Addresses are as follows :

6.1.2 Categories of Web Documents :


On the web we get large information accommodated in the web pages. These documents
are information providers. These web documents provides lots of vital information abou;
intended topic.

These web pages or documents are classified based on their working as follows:

a)

Static Document

The static categories of web document are shown in the given figure.

The client sends a request of required web document to server.

Server searches the required web document in the databases.

Server sends the requested web page as a response to the client.

The contents remains same on the web server, each request for a static docume*
results in exactly the same response.

It is simple but inflexible.


____________________________________________________________For example home

page of any website like www.gmail.com. Whenever we will requtJ


the login page the user interface remains as it is._________________k

The HTML is basic example of static web document which is helpful over the internet

for transferring any kind of document. It is basically useful for static documents which
contains useful information's.
1)

Introduction to HTML

HTML is a universal, simple language for formatting text called as "Hyper Text
Mark-up Language".

HTML useful for embedding of graphics like images, videos, charts etc and
linking of documents via 'hyperlinks'.

'Hypertext' documents help readers to freely move around the document,


following the links which are added in the document related to the subjects of
interest.

HTML is a language which provides the response documents to the client from
the server. It is used to specify the document retrieval across the Internet using
browsers.

Mostly all the responses for any request of client on the web are in HTML
documents.

1.

Creating an HTML document is very simple.

To begin coding in HTML we need only two things: o


simple-text editor : Notepad is basic, simple-text editors o Web

browser: to display web pages on the screen.


2. Web Pages are nothing but they are simple HTML files having some related
content which can be forwarded using Web Browsers.
3. There are various tags used to generate web pages using HTML language.
The tags are of two type "single tags" and "paired tags".

For example <br> is single tag

.....................................................................................<html>....</html>,

<b>.. .</b>, <h>....</h> etc are paired tags we have to


mention the start tag " <....> " and end tag " </.....> " in the paired tag.

HTML file can be save with the extension as .htm or .html anywhere in the
system.


HTML tags are non case sensitive. It means we can write using "Upper case or
Lower case".

2)

Tag format:
Tas format of naked tag with start and end tag is shown below :

Example of Basic HTML document is as follows :

We start and end with <html > paired tag to notify the browser that the web page is

of

HTML format.

Two main parts of HTML document;

1.

Head:
It gives information related with the document like name of document etc

..
In the example the <title> tag can be used in <head> tag to mention
the Name of the document

2.

Example:

Body:

It gives the main content of document along with the formatting provided on
content.

In the example the heading using <hl> tag and paragraph using <p> tag
included in the paired <body> tag.

Out
put:

For example:
Bold Faced Tag:

It is useful to format the text between the tags with the bold format. When
the text is displayed on screen it shows the data with bold letters.

document.

b)

Dynamic Document

In the static document; server responses with

the saved static document to the client.

A dynamic web document does not

exist in a predefined form.

The dynamic categories of web document are

shown in the given figure.

The client sends a request of required document

to server.

The web server runs an application program that creates the

document. Server (executes the requested'program and generates the output

The document generated by server mostly in HTML format forwarded to client


system as a response for the display.

The contents of a dynamic document can vary from one request to another.

Dynamic web page covers any web page generated differently for each user like
the online shopping site.

The user browse through the site and ask for his/her required, items then server
replies with the specific and related information via a web documents. These
documents various from user to user.

The dynamic documents includes pages produced by client-side scripting, and


created by server-side scripting such as ASP,JSP,ASP. NET,PHP etc where the
web server generates content before responding it to the client.

It gives current information to the client but once the documents retrieved the
content cannot be changed.

c)

Active Documents

The Microsoft Office is an example of an active document container.


For example, a Microsoft Office contains Word documents, Power Point files,
Excel spreadsheets, and so on.
An active document can access sources of information directly and update the
display continuously.
Active documents require more sophisticated browser along with a powerful
computer system to run the browser.
For example In the case of Java programs the source code is translated in the byte
code format and then sent to the browser and locally executed by the Java
interpreter (JVM).
Active categories of web document are shown in the given figure.
The client sends a request of required program to server.
The web server searches the requested program in the repository and sends back
the copy to the client.
The client runs an application program and generates the required document and
displays it.

(c) Running the program and creating the


document Fig. 6.1.4 : Active Document

6.2 HTTP
__________________________________________________________

For transmission of the web pages over the Internet HTTP protocol is very helpful
which gives some rules to be followed while doing the flawless transmission of the web
documents.

The standard Web transfer protocol is HTTP (Hyper Text Transfer Protocols). It is used
for document exchange between servers and clients on the web
It follows Client-Server model in the HTTP Request- HTTP Response pattern.

6.2.1

How it Works :

HTTP Request: To retrieve a document, the client first sends a request to the web
server and waits for a reply. It contains main parts like;

Request line uses two main methods: GET, POST

Header lines

Request body (empty here)

HTTP Response: An HTTP daemon/service i.e. a program which waits for Http

requests on the server then handles the request and the document is sent to the client over a
connection established using TCP/IP - Transmission Control Protocol / Internet Protocol.
It contains main parts like;

Status line

Header lines

Response body
Protocol is nothing but the set of rules/standards which we follow for communicating
over the Internet.

The Client sends a HTTP request using GET/Post method.

The Server replies with a HTML document related with the users requirement.

6.2.2 Difference between GET and

POST : GET Method :

In this method URL specifies all the name value pairs are submitted as a query string
with the help of special characters.

The name-value is not protected as it is visible in plain text format in the Location bar of
the web browser.

We have to take special care for encoding data if special characters like ampersand (&)
etc are present in the GET method since already the name-value displayed using the
special characters.
i

Length of the string is restricted in the GET method. We are not able to pass the data
with large memory.
GET is the default method; if method is not mentioned in the Form tag.
Data is always submitted in the form of text over the Internet using GET method.

POST Method :

All the name-value pairs are submitted in the Message Body of the request not
considered in the location bar of the URL.

Post Method is secured because Name-Value pairs cannot be seen in location bar of the
web browser.

If the service associated with the processing of a form has side effects for example,
modification of a database or subscription to a service; then the method should be POST.

Length of the string i.e. the amount of data submitted isnot restricted.

Data is submitted in the form as specified in encryption type attribute of form tag.

Limitations :
Stateless : HTTP is stateless protocol means it does not keep any information for future
use.

Security : No built-in security mechanisms is added in the HTTP protocol.


It has built-in support for tracking clients session for the management
____________________________________________________________________________________6

.3

Electronic Mail________________________________________________

By using HTML we are able to generate web pages. With the help of HTTP protocol
we are able to send an electronic-mail. These e-mails are send between client and server over
the world wide web via some protocols. These protocols helps to transfer the messages from
client to server and also by using some protocols servers are able to retrieve an e-mails.

Some major protocols are explained in this point along with their working. Electronic

mail requires several applications and services like Application layer protocols to transfer
over the Internet;
1. Simple Mail Transfer Protocol (SMTP) - sending email
2. Post Office Protocol (POP/POP3) - retrieving email
3. Hyper Text Transfer Protocol (HTTP) - world wide web

6.3.1 SMTP

Electronic mail requires several applications and services like Application layer

protocols to transfer over the Internet;


Simple Mail Transfer Protocol (SMTP) - sending email

Post Office Protocol (POP/POP3) - retrieving email

Hyper Text Transfer Protocol (HTTP) - world wide web

1. SMTP stands for Simple Mail Transfer Protocol. The SMTP designed to be a very
simple process to connect and read mail.
2. Simple Mail Transfer Protocol it is a standard application layer protocol for Electronic
mail transfer.
3. This process designed to be used over the Internet; when the Internet was young and
when the primary purpose of the Internet was to provide a way to share documents and
information.
(i)

It works on well known port 25 by using Transmission Control Protocol (TCP),


(ii) It uses Commands and responses encoded in ASCII in the form of Client-Server
model.

(a)

SMTP Components :

The major components :


----------------------------------,
User agents

(b) Fig. 6.3.1: Simple mail transfer


protocol

Mail servers

User Agent:

User Agents ( UA) are also called as "mail reader".

The User Agent handles composing, editing, reading, saving mail messages e.g.
Outlook, Mozilla

On the mail server the outgoing, incoming messages are stored on mail

server
Mail Servers :

Servers mailbox contains incoming messages for the user from the remote machine.
j

Outgoing message queue of mail messages are also maintained on the mail server.

SMTP protocol works as Client- Server model to send email messages (i)
Client helps for sending mail to server.

(ii)

Server helps for receiving mail from

client. (b) SMTP Services :


The e-mail server operates two separate processes:

1.

Mail Transfer Agent (MTA) process is used to forward e-mail from client MTA to I
Server MTA on the local server

2. The Mail Deliver Agent (MDA) can resolve final delivery issues, such as vinu
scanning, Spam filtering, and return-receipt handling
As shown in the Fig. :

Mail User Agent i.e. Client sends an email to server recipient@domain.com

First it will confirm from server that whether the needed servers mail box
exist or
not.

If the needed servers mailbox does not exist then client will search on other
servers till getting the needed server.

After getting the server client will transfer the mail via TCP connection to the
servers mail box.

(d) SMTP
Architectures: i)
First Scenario:

The sender and receiver of the email are users on the same mail server

They are directly connected to shared mail server i.e. Both the sender and
receiver are having the same mailbox on the same system.

ii)

Second Scenario:

The sender and receiver of the email are users on two different mail servers.
The message is need to be send over internet on the individuals Mailbox. User
A

User B

6.3.4 iii)

Fig.

Third Scenario:

One user is directly connected to mail server and the other one is
separate: from mail server and connected vis LAN / WAN.

6.3.5 iv)

Fig.

Fourth Scenario:

Both the Sender and receiver are separated from mail server and
connected via LAN/VAN

(e)

SMTP Working :

As shown in the figure;

At the Client side; SMTP Client sends mail to the SMTP Server's mail box

Then the mail is transferred over the internet to found the required Destination's
mailbox.

The mail reaches to required destination.

The mail is kept at server side SMTP server's mail box.


Then through the mail access protocol the mail is transferred in the respective
servers SMTP Client mail box.

Fig. 6.3.6

(f)

Address Format:

To send any message; receivers address as well as to know who is sender we need
to specify the respective address of client and server. The message format is as shown in
the figure;

First part contains the name of a client/server mail box on its local site.

Second part specifies domain name of destination. For


example xyz@gmail.com

(g)

EMAIL System :
Following figure explain the email transmission over internet:

Client i.e. User A generates mail into its Spool by using interface through
User Agent.

Then the Client Mail Transfer Agent transfer it over the internet.

The server Mail Transfer Agent receives the mail and saves it into the Server's
mailbox.

Then Server i.e. User B able to read the mails from its own mail box through User
Agent over the communication channel using interface.

And same process steps are followed when User B wants to send mail to User

A.
(h)

Connections in SMTP :
Three major steps of SMTP connection between Client and Server are :

1. Connection Establishment
2. Message Transfer
3. Connection Termination
1.

Connection establishment:

As shown in the figure the MTA Server sends ready message to MTA Client
If MTA Client wants to accepts this message then replies with HELO
message

Then MTA Server gives response by sending OK message

2.

Message transfer:

After connection establishment between MTA Client and MTA Server me


message transfer takes place with the help of SMTP commands and
responses.

Example of message transfer is as follows :


As per the figure message is transfer using three main parts:
(i)

Envelope : It specifies the sender and receiver of a mail; whether

the

connection between them possible or not. (ii)

Header : It

specifies the sender and receiver of a mail along with

extra information like Date etc. (iii)

information content of a mail i.e. the data


part of message.

Body : It specifies the core

3.

Connection Termination:

After the successful transfer of message MTA Client sends Quit message to
MTA Server.

Then MTA Server replies with response that Service is closed.

Fig. 6.3.11 : Connection Termination

(i)

Commands and Responses :

As we have discussed earlier SMTP is command-Response model between Client


and Server.

The commands are given by client to server and the response related with that
commands are passed from server to client.

Fig. 6.3.12 : Commands and

Responses a) Command Format:


Keyword : argument (S) Some

commands and their functions in the SMTP are listed down:

SMTP
command

ATRN

SIZE

ETRN

PIPELININ

It helps to send a stream of commands dose not wait for response.

DATA

To initiate transfer of message content through client.

DSN

An ESMTP command for enabling delivery status notifications,

RSET

VRFY

HELP

QUIT

The command and response are forwarded between client and server in the form of a three

The ATRN (Authenticated TURN) command optionally


considers one or more domains as a parameter. The ATRN command not
considered if the unauthenticated session is considered.
Indicates the maximum message size supported by the SMTP
server. The message should not be send by the clients that are larger than
the size indicated by the server.
It is an extension of SMTP.SMTP server sends request to another
server that "send any e-mail messages that it has" using this command.

Resets the buffer and clear the entire message transferred till that
time.

Helps to verifies that a mailbox of particular receiver is available


for message delivery

list of commands that are supported by the SMTP service are


given by this command

Helpful for termination of the session.

digit number and it is followed by text which explain about the reply from the server. For example :
220 Server Ready 500 Syntax error, command unrecognized. The list of reply codes are shown
below: Most of them will not occur if mail server programmed correctly.

2
Indicates a system status or help reply.
11

2
Describes the help Message.
14

2
Indicates that server is ready.

20

Shows that server is ending the conversation.

21

Indicates that the requested action was completed.

50

51

The server will forward the mail message but the specified receiver is not
local.
It indicates that sender can start sending the main part of message.

54

4
Save the mail messages and then the mail server will be shut down.
2

4
The mailbox is busy wait and try again.
5

4
Error occurred : The requested action not completed.
54
Mail server ran out : The requested action not completed due to the lack
5 of system storage.
25

Syntax error/ Long sentence: The last command not completed .

00

Syntax error: parameters or arguments not ale to proceed.

01

The mail server not implemented the last command given by


client.
Last command given by client was out of sequence.

02

03

04

5
The parameters of the last command not implemented by the server given
by client.

50

51

53

Mailbox not found or not having access rights of particular


mailbox.
Forwarding address: The specified user is not local; hence

5
message will a receivers address.

5
Syntactical error : The specified mail address not syntactically
correct.
5
The mail transaction has failed due to unknown causes.

c
o
n

54

6.3.2 IMAP:
For retrieving the e-mail programs or messages from various systems over the network we are
able to use two mail access protocols:

Internet Message Access Protocol (IMAP) or Post Office Protocol (POP).

In a POP, client system stores e-mail messages in user's mailboxes on users system and keeps
record of operations on messages like user have been read, replied to etc.

POP client able to delete old messages from the server's system without users nermissinns.

In the IMAP e-mail account, the original messages will remain on the
server, along with
operations performed on it like user read, replied to, or forwarded a
message.

IMAP stores folder structure in a main folder called "imap.hyperoffice.com".

(a)

Introduction:

Internet Mail Access Protocol is known as email access protocol of an application


Layer.

It helps client to access an e-mail from remote mail server.

IMAP is useful to access messages from more than one computer in the network.

IMAP protocol based on a TCP connection and works on default port 143.

IMAP supports both on-line and off-line modes of operation.

IMAP generally leave messages on the server until the user commands for deleting
them.

It support for concurrent access to shared mailboxes in the network.

It is not necessary that; client should know the details about server's file format.

Fig. 6.3.14 : Internet Mail Access Protocol Connection

As shown in the Fig. 6.3.14 the client able to interact with many servers at the same
time.

Client can access own mail from anywhere.

Client can decide where to store the mails like on server's mail fo,lder or on local J
mail folders.
*

The mails are not deleted until client explicitly deletes them.

(b)

Procedure of the IMAP protocol:

In IMAP all emails are kept on a mail server

Functionality:
1. IMAP Server's directory is considered as local directory hence work directly on
server.
1. It performs operations on different folders like copy, delete, modify etc.

3
4

Using IMAP users are able to download message headers and later on the full
messages.

IMAP's communication procedure :

Connection initialization

Interaction between client and server

Connection termination

(c)

Interaction between client and server:

Client sends data and server receives :

The Client-command begins with alphanumeric string called as "tag"

(d)

For example "A001" is generated for every new command then the command
with corresponding arguments followed.

(i)

Server sends data and client receives.

(ii)

Server receives and works with the command given by client.

(iii)

Server response with the same tag with a state like "OK/NO/BAD"

(iv) The additional information begin with '*' called as untagged

(iv)

Untagged information can be sent at any time between client and server.

Different states of an IMAP session :

Most commands of IMAP are only valid in special states otherwise: protocol error

States are;
1. Initialization : In this state the session using IMAP Server and IMAP Client is
started.
2. Non-Authenticated : After connecting with IMAP server If Client's Status is
Unauthenticated then the Client's session is terminated and Logout state takes
place.
3. Authenticated : If the client is already having authentication then Client will
Login and starts the session with IMAP Server.

4. Selected : After the session has started the Client will work on the selected data as
per the requirement.
5. Logout, Closed : At the end after the completion of work the termination of
connection takes place i.e. the Logout state.

4.

5. Fig. 6.3.15 : State diagram of IMAP

(e)

Flags message attributes :

1. It consists of the list of token related with the message and sent by the server
2. A flag indicates permanent or session-only
Types of Flag:
6. System flag:
7. (i)

(ii)

This flag name is predefined in the IMAP specification


All system flags are begin with 'V Keywords:

8. (i)

(ii)

A keyword in the IMAP message is defined by the server implementation


The keywords in IMAP dose not begin with 'V Some System Flags are

listed below :

\Seen - indicates that Message has been read

VAnswered - indicates that Message has been answered

\Flagged - informs that message is "flagged" for attention

9.

VDeleted - informs that message is "deleted" for removal by laas


EXPUNGE
\Draft - describes that message has not completed composition and :
marked as a draft

\Recent - It explain that message is "recently" arrived in this

mailbox.
This session is the first session related with this message.

10. (f)

LOGIN - It helps to add username and password to do login.

SELECT - It indicates mailbox-name.

CREATE - It indicates new-mailbox-name for generation.

DELETE - It describes mailbox-name to delete.

RENAME - It indicates new-name to replace old-name of mailbox.

AUTHENTICATE - It is useful for authentication of users mailbox

CLOSE - It indicates that the mailbox is closed.

SEARCH - It denote the mailbox-name which user want to search.

COPY - It indicates the mailbox-name from which user wants to copy some data
11. (g)
12.

Login:
We login using user's account and password, not "abc" and "xyz"!

INPUT: aOl login abc xyz

RESPONSE: aOl OK User logged in (h) Logout:


13.

Commands:

Just by typing following statements we are able to do the Logout;

a071ogout

* BYE LOGOUT received

a07 OK Completed Advantages


over POP:
14.

IMAP works in Connected and disconnected modes of operation i. e. in online and


offline modes of operations.

Header-helps to do message retrieval

Multiple clients at the same instance connected to the same mailbox using IMAP.

IMAP helps to provide message state information

There exists multiple mailboxes on the IMAP server

IMAP helps to provide Server-side searches facility.

IMAP can create e-mail folders on the server; these folders are accessible from
anywhere. If POP is used and create e-mail folders, they are stored locally then user
cannot access these folders from anywhere except the computer on which user created
them.
15.

16.

6.3.3

POP 3 :

Post Office Protocol3 (POP3) is other mail access protocol which is widely
used but it has some drawbacks as compared to the IMAP.
17.
18.

Why IMAP a better protocol for mailing comparison with POP3?

It works with Connected and Disconnected modes of operations.

Multiple clients at the same time can be connect to the same mail box.

It helps to access a MIME message parts.

It provides Message State information.

At the same time it maintains Multiple Mailboxes on the same server.

It helps for searches at Server Side.

It downloads all emails from remote machine to client's machine mailbox into 1 mail
folder which is known as "Inbox".

19.

20.

Fig. 6.3.16: Post Office Protocol (POP)

Due to many facilities and features IMAP has some additional complexity and overhead
but still it is considered as best because for the purpose it is invented it gives best
outcome.

POP just shows you what is in your inbox on the Users mail server, it checks the server
for new messages, downloads all the new messages in your inbox onto your computer,
and then deletes them from the server.
21.

The working of POP3 is as shown in the figure :

The POP3 Client first log in to the POP3 server using user name and password After
the successful reply from server side client ask for the detail information about his mail box on
server.
22.

23.

Server displays the list of emails along with other required information.

Then client starts retrieving/reading the emails from the server's mail
box.

24.

6.3.4

Fig. 6.3.17

Multi-purpose Internet Mail Extensions (MIME)


MIME helps to add non textual ;data to be sent in email like

25.

Graphics image

Voice files

Video clips etc.


It also work in Client-Server

26.

model. Sender:

It encodes binary item into printable characters

It helps to add printable characters in email message for transfer Receiver:

It receives email message containing encoded item


27.

After receiving the encoded mail it decodes message to extract original binary
value.

28.
As shown in the figure users i.e. Client / Server able to ad non ASCII code like
Graph:. in the mail using MIME ; which converts that data in ASCII code and easily transferable
using SMTP over the internet.
29.

30.

(a)

Message Format:

(b)

Header:

31.

32.

33.

Email header:

It contains data about sender and receivers address along with the specification
of , subject.
34.
35.

MIME header:

36.

Header in email message describes

37.

Version:

38.

It specifies the version of MIME used.

39.

Content type along with sub type :

It specifies the type of data used in the main information. Content type and sub
types are separated by the " / " (slash) Seven Basic MIME Tvoes :
40.

41.

42.

encoding used:
43.

It explain about which type of encoding techniques are

used message ID:


It specifies a particular number for identification of a mail and it is used in every
fragment of message.
44.

45.

Content explanation:
46.

It gives description about the content in the body of a message.

47.

Example:

48.

Email Header : From : abc@acollege.ac.in

To: xyz@example.edu MIME Header: MIMEVersion: 1.0 Content-Type: image/jpeg ContentTransfer-Encoding : base64 Body:
49.

The body contains the main information/data from the mail/message.

50._________________________________________________________________________ 6

.4 Network Management______________________________________
51.

Network management deals with;

1. Network Positioning
2. Network operations
3. Network Maintenance
52.

The above three classifications are.further divided into the sub parts as shown

in the figure

Fig. 6.4.1: Network management functional


groupings

Common Network Problems are as follows :

53.

Loss of connectivity

Duplicate IP address

Intermittent problems

Network configuration issues

Performance problems

54.

55.

Fig. 6.4.2 : Network management components

The network management plays an important role to avoid all the problems
associated with the network related issues.
56.

57.

The network management system has components like:

58.

(i)

Network Agent

59.

(ii)

Network objects

60.

Both the components are related with each others.

To avoid this network related issues we use SNMP i.e Simple Network
Management Protocol.
61.
62.
63.

6.4.1
64. (a)
65.

How SNMP works for managing the network nw we will see.


SNMP
Introduction:
SNMP is Simple Network Management protocol useful over the network

management. SNMP uses the concept of manager and agent.

A manager: It is usually a host that controls and monitors a set of agents

Agents: It is mostly routers or servers


66.

SNMP works as Client (SNMP Manager) - Server (Agent) model.

67.

68. Fig.
6.4.3 (b)

Client Pull and Server Push :

In SNMP Client is known as " Pull Model'

It means Client system i.e. System Manager "pulls' data from the server i.e. ago*

The SNMP Server is known as'Tush Model"


The Server (agent) "pushes" out the mail messages to a Client (managemen
system).
SNMP uses Structure of Management Information (SMI) and Managerren
Information Base (MIB) in Internet network management.
69.
70.

These are an application programs that helps:


1. A manager
71.

It useful to retrieve the value of an object defined in

an agent. It supports to store a value in an object defined in an


agent.
72.

2. An agent
73.

Sends an abnormal situation message to the manager.

(c)

74.

SNMP

Components : Agent:

The agent collects data from various the network device and store it in MIB.

Agent executes all the MIB objects that are relevant to each other.

The agent provides the information through the MIB for management usages.

(d)

To do management tasks, SNMP uses two protocols :

Structure of Management Information (SMI) and Management Information Base


(MIB).

The network management on the Internet is done by using three protocols like
SNMP, SMI, and MIB.

(e)

Fig. 6.4.5

SNMP(Simple Network Management Protocol) defines the packet formats


which are shared between a manager and an agent.

SNMP packet values that is status can be read and changed using SNMP.

SMI (Structure of Management Information):

SMI specifies the general rules for naming objects, defining object types
including range and length and also showing how to encode objects and values.

The SMI helps to define the data types that are allowed in the MIB.

It sets a unique naming structure for each managed object.

The SMI is major component for network management.

The functions of SMI are as follows;

To name objects in the network.


To define the type of data that can be stored in an object which are connected in the
network.

It shows how to encode data for transmission over the network.


SMI help for SNMP. It has main three attributes to handle an object: name, data
type, and encoding method.
(f)

MIB (Management of Information Base):

It helps to create a collection of named objects, their types, and their relationships to
each other.

The MIB is nothing but a collection of network information from various network
devices.

This information is stored in databases fro the management related work and the
information is retrieved with the help of protocols like SNMP.

Six main attributes of MIB objects are;


a name, an object identifier, a syntax field, an access field, a status field, and a text
description.
The MIB object may store;
Number of packets:
A value which specifies the number of packets that have come in since the last system

reset.
Number of clock ticks :

It help to get a number of clock ticks since the last reset of a system.

These values are stored in scalar and tabular formats;

Scalar objects shows a singular object instance.

(g)

A tabular object describes a group of object instances that are found in MIB I
tables.
Comparing computer programming and network management:
As shown in the Fig.6.4.6 the SNMP in network managementworks for coding in
computer programming

The SMI useful for language syntax specification.

The MIB works for objects declaration and definition in computer programming.

(h)

Management overview:
(i)

As shown in the Fig. 6.4.7 manager receives the UDP user datagrams

(ii) Then the datagrams are send over the network to check the details from various
protocols like SNMP,SMI and MIB.

(iii) The group of three protocols sends response of particular datagram that acts as
packet to the manager in the network.

(iv) Then SNMP packet is sent from manager to agent with the help of GetRequest
command (v) The Agent sends SNMP packet as response to manager's request for

particular
packet.

(vi) Manager sends reply to a management question about particular packet over the
network.

(i)
Ports and UDP :
SNMP uses UDP i.e. User Datagram Protocol as a transport mechanism for
transmission of SNMP messages over the network

SNMP uses two well known ports; (i)

UDP
UDP port 162

Port 161 for SNMP Message (ii)


for SNMP Trap Message.

As it go upwards in the OSI layers the datagrams are added with SNMP messages like
udp datagram, IP packet and Ethernet frame along with CRC i.e. Cyclic Redundancy code. (j)
Object Identifier:

All objects managed by SNMP are given by an object identifier.


The object identifier always starts with root and followed by neighbouring
connections till the destination
For example as shown in the Fig.6.4.9 root followed by other connection is
iso.org.dod.ibnternet.mgmt.mib-2 and also stated as 1.3.6.1.2.1.

(k)

The Management Information Base, version 2 (MIB2) is the second component


used in network management.

Each agent has its own MIB2, which is a collection of all the objects that the
manager can manage.

MIB-2:

The objects in MIB2 are categorized under 10 different groups:


System, interface, address translation, ip, icmp, tcp, udp, egp, transmission, and
snmp.

These groups are under the mib-2 object in the object identifier tree as shown in the
figure. Each group has defined variables and/or tables.

As shown in the above MIB-2 is identified as 1.3.6.1.2.1.and and the other 10


objects of MIB-2 are mentioned by numbers from 1 to 12.
For example udp port can be recognized as 1.3.6.1.2.1.7

Fig. 6.4.10

UDP ports:

As mentioned in above MIB-2 objects we will consider udp port. UDP port further
classified into 5 sub-objects groups are listed along with their object identification code as
follows:

1. udpln Datagrams : 1.3.6.1.2.1.7.1


2. udpNo Ports: 1.3.6.1.2.1.7.2
3. udpln Errors: 1.3.6.1.2.1.7.3
4. udpOut Dtagrams: 1.3.6.1.2.1.7.4
5. udp Tables: 1.3.6.1.2.1.7.5

The following example has the object udpLocal Port is mentioned as

follows; 1.3.6.1.2.1.7.5 adds the udp Table 1.3.6.1.2.1.7.5.1 adds udpEntry


1.3.6.1.2.1.7.5.1.2 adds udpLocal Port

Fig. 6.4.11

UDP variables and tables :


As shown in the Fig.6.4.12 the 5 objects are shown with their object identification

codes.

Indexes for UDP tables :


In the given fig. 6.4.13 the left side indicates udpLocal addresses with the IP addresses of

systems. Right side indicates the udpLocal Port numbers.

For example
UdpLocal Address : 181.23.45.14 and'the udpLocal Port No: 23 etc.

Fig. 6.4.13

Lexicographic ordering :

In the Lexicographic ordering first we consider the udpLocal address then the udpLocal

Port numbers as shown in the figure.

SNMP Operations :
Four basic operations of SNMP are as follows :

1. Get : It retrieves the value of MIB variable


stored on the agent machine
2. GetNext: It helps to retrieve the next value
of next lexical MIB variable
3. Set : It helps to change the value of MIB
variables.
4. Trap : It helps for an unrequested
notification sent by an agent to a
management application.

The SNMP manager and SNMP agent connection takes place on UDP connection.

The message transfer between Client and Server uses SNMP operations. As shown in the
figure the client - Server Connection is done using operations like; SNMP Manager to
SNMP Agent Operations :
GetRequest, GetNextRequest, GetBulkRequest, SetRequest

InformRequest and Report are two messages which are transfer between managers

onl> SNMP agent to SNMP Manager Operations : Response and Trap

SNMP PDU :
It has fields

like; PDU Type:


The packet type can be request or response.

Request ID:
It gives a sequence number of particular request of SNMP message.

Error Status and Error Index :


Error status and error Index values are for all the SNMP messages except the

GETBulk Request.

(i)

Request, (ii)

Error status field is replaced by non- repeater field in GetBulk


Error field is replaced by mac-repetitions field in GetBulk

Request. VarBind list:


It contains various variable and their respective values.

Fig. 6.4.17
Some PDU types along with the tags in Binary and Hex are listed down in the
following table:

Some SNMP PDU errors are listed down below along with the meaning

in the table:

Languages of SNMP :

SMI (Structure of Management Information):


As name suggests It specifies the format or the structure used for defining network

managed objects that are accessed by SNMP protocol.

ASN.l (Abstract Syntax Notation One):


It is useful for notifying the format of SNMP messages and management objects (MIB

Modules) using data description format.

BER (Basic Encoding Rules):


It is useful for encoding the SNMP messages which users want to transmit over the

network for better security purpose.

SNMP Messages:
In the figure GetRequest PDU is shown along with the various variables and their

Fig.

6.4.18 SNMP Ports:


As we have already seen SNMP message uses UDP Port

161 And SNMP Trap Message uses UDP port 162

Ras

As given in the figure:

Passive open by both Client and Server by using Port 162 and 161 respectively.

After the passive open, the client active opens the application on respective port
(i.e. 68000).

Then server active opens the application on respective port (i.e. 61150, sending a
trap message.

SNMP

Security :
Security :
By using SNMP version-3 managers are able to choose the different levels of securit)

according to the requirement of the network and also depends upon the data which user ( an
agent) wants to forward.
While considering the security levels different aspects of security configurations

shou.c be considered like confidentiality , authentication and many more. Remote


administration:
SNMP Version-3 helps for remote administration also by configuring the remote

administration policies where without administrator also the the security of devices can :
maintained.
6.4.2 Multimedia

1.

Introduction

Multimedia is now a days very popular on internet for advertising, entertainment


and to access various information from world.

People access internet not only for text but for audio video search as well.
2.

Multimedia Services

The audio video services on internet are generally divided in three categories.

Streaming Stored Multimedia


Introduction

Multimedia file are compressed and then stored on to multimedia server.

These file can be accessed by various internet users by downloading it from the

network,

Working

End user sends GET request to server machine to which web server sends
response.

Then audio file can be played by using media player services.

Example

o On demand Audio video o

Streaming Live Multirr ?dia


Introduction

In this type of multimedia user accesses the broadcasted audio and video

from online broadcast server.

Fig.

6.4.21 Example
o Live Cricket matches broadcasted on internet

o Interactive Multimedia Introduction

Multimedia can be used to communicate with people over the world and attached
by internet.

Only required multimedia file will be sent to receiver.

Works on basis of RTP (Real time audio video protocol)

Fig. 6.4.22

Example

o Skype internet video calling 3.

Multimedia Compression techniques

The different multimedia files can be compressed in various available technique,

Audio Compression : MP3

To produce CD quality audio compression based on perceptual encoding


technique we make use of MP3 coding.

MP3 uses frequency and temporal masking for compressing audio signal.

MP3 can produces data rates 96 kbps,128 kbps and 160 kbps.

It is a part of MPEG coding.

Image Compression : JPEG

JPEG is a common image format used in World Wide Web.

JPEG compressed images can be used to hide data for secret internei
communication.

It makes use of DCT and binary coding.

Video Compression : MPEG

A compression encoder works by identifying the useful part of a signal which is


called the entropy and sending this to the decoder.

The remainder of the signal is called the redundancy because it can be worked out
at the decoder from what is sent.

In MPEG the two-dimensional spatial frequency analysis is performed using the


Discrete Cosine Transform (DCT).

An array of pixels, typically 8 x 8, is converted into an array of coefficients.

Fig. 6.4.24

The magnitude of each coefficient represents the amount of a particular spatial


frequency which is present.

Review Questions

Q. 1

Write a short note on multimedia internet technologies.

Q. 2

Explain various multimedia compression techniques.

Q. 3

Describe multiple multimedia services in details.

Q. 4

Write a short note on application layer protocol.

Q. 5

Explain IMAP in detail.

Q. 6

Explain use of SMTP and its architectures.

Q. 7

Write a short note on SNMP.

Q. 8

Explain different type of web documents .

Q. 9

Describe WWW and how email system works.

Q. 10

Write a short note on HTTP .

Q. 11

Explain difference between SMTP POP3 and IMAP.

Q. 12

Explain MIB and SMI.

Q. 13

Explain connections in SMTP

Q. 14

Working of SMTP POP3 and IMAP.

Client Server Programming

Syllabus
Concurrent Connection Oriented (TCP) programming
Concurrent Connectionless (UDP) programming
Iterative connection oriented (TCP) servers programming
Iterative connectionless (UDP) servers programming

____________________________________________________________________________________

7.1 Sockets
___________________________________________________________
1.

Introduction

A socket is fundamental technology of computer networking used to create a


connection between two computers.
Socket mechanism allows applications to communicate using standard
mechanisms with help of network hardware and operating systems.
The Sockets Application Program Interface (API) provides a library of functions
which are used to develop network applications.
Sockets are identified by Internet address, end-to-end protocol, and port number.
A socket pair identifies all four components like source address and port number
as well as destination address and port number.
Sockets are acting like end point to communicate with each other.
2.

Point to point communication

A socket generally represented as a single connection between exactly two pieces


of software or computers.
Software based on sockets runs on two separate computers which are in the
network.
Sockets can also be used for inter process communication on a single computer.

The Sockets are bidirectional that means any of two sockets is capable of both
sending and receiving data.
Client

3.

A client is a system that accesses the remote service on another computer using
network.
The application that initiates communication is generally called as client socket
4.
Server

Server is a computer program that provides services to other computer programs


in the same or other computers on network.

The application that answers the client socket as generally called as server socket.

7.2

Socket Interface_____________________________________

1.

Introduction

The socket interface is made using kernel which contains 3 layers as

below,
i.

Socket layer
ii.

Protocol layer

iii. Device layer.


Socket layer : This interface is exists between the subroutines and lower layers
Protocol layer: It will have the protocol used for communication
Device layer : It has the device drivers which control the network devices.
2.
Relationship

Fig. 7.2.1: Socket interface layers

In above diagram client process on the left with the socket layer under it and the
protocol layer and device layer adjusted below it.

The protocol layer lies between the other two layers.

Corresponding layers are exists below the Server process on the right.

A line showing the network runs through all layers and connects the server
with client processes (in above diagram U shape line).

Fig. 7.2.2

The Internet does not follows entire OSI model but rather merges several of the
protocols layers together.

It is possible for two network applications to begin simultaneously, but generally


it is not required hence we will do network operations in sequence, rather than
simultaneously.
The server executes first and waits to receive request from clients; the client
afterwards and sends the first network packet to the server.

After initial connection phase anyone the client or the server is capable of
sending
or receiving data.

Fig. 7.2.3

7.3 Types of Socket


_________________________________________________________
__
1.

Datagram sockets

The User Datagram Protocol (UDP) transports packets in a connectionless


manner.

In such communication, each data packet which is also called as a datagram is


addressed and routed individually and may arrive at the receiver in random order.

2.

Datagram socket is designed to use with connectionless


protocols.
Stream
Socket

The Transmission Control Protocol (TCP) is connection oriented protocol and h


transports a stream of data over a logical connection established across the sender
computer and the receiver computer.

In such communication data sent from a sender is guaranteed to be received by


recipient in the order it is sent from sender.

Stream sockets are designed to use with connection oriented protocols.

3.

Raw Socket

Sometime protocols like ICMP and OSPF uses services direct from IP.

Raw sockets are designed for applications based on such protocols.

____________________________________________________________________________________7

.4 Ports____________________________________________________
1.

Introduction

A port is a 16-bit number which is used by the host-to-host protocol to identify to


which higher-level protocol or process it must deliver incoming messages coming
from other host.

Whenever any process wants to communicate with another process, it identifies


itself to the TCP/IP protocol suite by one or more ports.

Problem arises when different applications trying to use the same port numbers on
one host is which should be avoided by writing applications to request an
available port from TCP/IP.
Because this port number is dynamically assigned, it may differ from one
invocation of an application to the next.

2.

Categories

Port numbers are divided into three different categories as given below:

Ports 0 through 1023

i.

They are called as well known ports.

ii.

They are associated with services in a static manner.

iii.

E.g. HTTP servers would accept requests at port 80.

iv.

The "well-known" ports are controlled and assigned by the Internet


Assigned Numbers Authority (IANA) and most systems can only be used

Port numbers 1024 - 49151

i.

ii.

They are called as registered port numbers,


They generally used for multiple purposes.
iii. These port numbers are not controlled by the IANA and systems can
be used by ordinary user-developed programs.

by system programs run by privileged users.

Port 49152-65535

i.

ii.

They are Dynamic and private port numbers


No services associated with them.

7.5 Socket Programming Using Java


__________________________________________________________
1.

IPC
Socket programming is used for implementing IPC (Interprocess communication)
with Java programming.

IPC used for separate, independent processes to communicate among themselves


to work together on any task.

A process can be a sender of the communication or it can be a receiver of the data


at another instant.

Unicast
In this transfer data is sent from one process to another single process.
Multicast
In this transfer data is sent from one process to more than one process at the same point

of time.
Broadcast
In this transfer data is sent from one process to all other available processes at the same

time.

Fig. 7.5.2

____________________________________________________________________________________

7.6 Connection oriented (Stream mode / TCP) socket


_______________________________________________________________
1.

Introduction

The Connection-Oriented Sockets are generally depends on the stream-mode I/O


model of the LINIX Operating System that we have learn in last semester in
which data is transferred with help of a continuous flow of data stream from a
source to a destination.

Data is added into the stream by a sender process which is also called as the
server

Data is extracted from the stream with help of receiver process which is also
called the client.

2.

Working

The server process first creates a connection socket and then listens for
connection requests from other processes.

Server will accept only one connection request at a time.

Whenever the connection request is accepted by server, a data socket is created


with help of which the server process can write or read from or to the data stream.

Socket is closed when the communication session between the two processes is
over.

The data and the server process is now free to accept another connection request.
3.

Problems

Server process is blocked when it is waiting for other incoming connection


requests.

This problem can be solved by spawning threads, one for each incoming client
connection request and each thread will individually handle the particular client
from a source to a destination.

4.

Methods used in stream mode socket API

The common key Methods of the Stream-Mode Socket API are explained given
below;

These sockets are typically used for connection-oriented communication during.


which a sequence of bytes is transferred in one or both directions.

The connection listener program (Server program) should be started before


executing the client program.

5.

Simple TCP server programming

a. Locate or find IP address and protocol number of server.

b. Open the Server Socket


E.g.

ServerSocket connectionSocket = new

ServerSocket(serverPortNumber):

c. Wait and accept the Client Request

Specify that the connection needs an arbitrary, unused port on local machine

and

allow TCP to select one

E.g.

Socket dataSocket = connectionSocket.acceptQ;

d. Create I/O streams for communicating to the client


Specify the server to which messages is needs to be sent

E.g.
PrintStream socketOutput = new PrintStream(dataSockct.gctOutputStream());

Or otherwise

DatalnputStream is = new DataInputStream(dataSocket.gefInputStream());

DataOutputStream os = new

DataOutputStream(dataSocket.getOutputStream()>:

e. Perform communication with client using application-level

protocol
E.g.

socketOutput.println(message);

Or otherwise

To Receive from client: String line = is.readLine();


For Sending to client: os.writeBytes("Hello Client");

f. Close the socket

E.g.

6.

connectionSocket.close();

Simple TCP Client programming

a.

Locate or find IP address and protocol number of server.

b. Create a Socket
Object
E.g.

Socket clientSocket = new Socket(acceptorHost, serverPortNum);

c. Create I/O streams for communicating with the


server
E.g.

BufferedReader br =

new BufferedReader(new

InputStreamReader(clientSocket.getInputStream()));

Or otherwise

is = new DataInputStream(clientSocket.getInputStream());

os = new DataOutputStream(clientSocket.getOutputStream());

d. Perform communication with the server

Specify the server to which messages is needs to be sent

E.g.

System.out.println(br.readLineO);

Or otherwise

Receive data from the server: String line = is.readLine();

Send data to the server: os.writeBytes("Hello Server..");

e. Close the socket

E.g.

clientSocket.close();

>
Program 1 : Socket program to send sample message from
server to client when it connects to server using TCP.

Output:

Output

Out
put
7.7

1.

Connectionless (Datagram / UDP) socket__________________


Introduction

In case of connectionless socket we use the datagram socket for delivery of


datagram packets.

UDP is unreliable and does not guarantee the delivery of packets in same order as
they sent from server.

Java have two classes for the datagram socket API:

(a) The DatagramSocket class : Used for the sockets


(b) The DatagramPacket class : Used for the packets exchange

2.

Working
Any process that wishes to send or receive data using the datagram socket API
must instantiate a DatagramSocket object, which will be bound to a UDP port of
the machine and it is local to the process.

Fig. 7.7.1: Program flow in the sender and receiver process (adapted from [2])

a.

Sending Process

To send a datagram to another process, the sender process must instantiate a


DatagramPacket object.

DatagramPacket has information as given below,


(1)

b.

Reference to a byte array which have all pay load data


(2)
Destination address: It is combination of host ID and port
number:to
which the receiver process DatagramSocket object is bound.

Receiving Process

The receiving process must instantiate DatagramSocket object and bound to a


local port

This local port corresponds to the port number carried in the datagram packet
of the sender.

To receive datagrams sent to the socket, the receiving process must:


instantiate a DatagramPacket object that references a byte array and call the
receive method of the DatagramSocket object, specifying as argument,a
reference to the DatagramPacket object.

c.

Process

The program flow in the sender and


receiver process is as shown in above

Figure

3.

Methods used in stream mode socket API

explained

The common key Methods of the Stream-Mode Socket API are


as given below;

4.

Algorithm of UDP client socket programming


a.

Find IP address and protocol number of host server

InetAddress receiverHost = InetAddress.getByName(args[0]);


int receiverPort = Integer.parselnt(args[l]);

Create a Socket Object

E.g. : DatagramSocket mySocket = new DatagramSocket();

c.
Specify that the connection needs
an
arbitrary,
unused
protocol
port
on
local
machine and allow UDP to select one and Specify the server to which messages
must be sent.

b.

E.g.

DatagramPacket packet =
new DatagramPacket(buffer, buffer.length, receiverHost, receiverPort);

my Socket, send(packet);

d.

Communicate with the server using application-level

protocol
E.g.

mySocket.send(packet);

e.

Close the

socket
E.g.
mySocket.close();

>

Program 2 : Connectionless (UDP) socket programming

Running above code :

Output:

Output:

Out
put

Out
put

In above example, tagramSocket is a binding call. Once a datagram packet arrives at the
receiver at the specified local port number where socket is opened and extract the bytes
stored in the datagram packet to a String.
Parameters are passed as,

The local port number known to the sender as well

Message to be sent

The datagram sender (UDP_Server.java) program creates a DatagramPacket object and


sets its destination IP address to the IP address of the remote host, the port number at
which the message is expected to receive and the actual message.

The sender program has nothing much to do after sending the message and hence the
socket is closed.

Similarly, the socket at the receiver side (UDP_Client) is also closed after receiving and
printing the message.

____________________________________________________________________________________

7.8 Issues of Server


_____________________________________________________________________
1.

Introduction

Server is a computer program that provides services to other computer programs


in the same or other computers on network.

Server socket application answers the client socket.

There are number of clients connected with a single server so it faces many
challenges while handling these client requests at a same point of time.

2.

Concurrent vs iterative servers

An iterative server is a server program which handles only one client program at
any point of time.

A concurrent server is a server program which can handle multiple client


programs at any point of time.

3.

Connection-oriented vs connection-less servers

In a connection-oriented protocol, there is overhead of setting up a


communications path between the sender and receiver, which will be maintained
until the sender and receiver have completed their entire conversation.

Connection-oriented protocols will provide guaranty of message delivery in the


order in which they were sent.

In a Connectionless service, we do not require to establish a session or


communication path.

Connectionless services are like sending a postcard via post sender assumes that
receiver will get it.

4.

Stateful vs stateless servers


A stateful server is a server program which maintains state of connected
clients
and their sessions in web servers.

'

While stateless servers do not maintain state of connected clients and thensessions.

7.9 Interactive Servers


_______________________________________________________________

1.

Introduction
An iterative server is a server program which handles only one client
program .
any point of time.

2.

Working

a. If one or more clients requests server while it is in communication with other


client, such requests need to wait for the existing communication to be completed

b. Such, pending client connection requests will handle on a First-come-FirstServe


basis. But, such a design is not so much efficient.

c. Sometimes clients may have to wait for longer period of time for the requests
in
the waiting queue to be processed by server.

d. When the client requests differ in the amount of time they take to be handled :
the server, it would then lead to a situation where a client with a lower execution
time for its request at the server may have to wait for the, requests (ahead in the
queue) that have a relatively longer execution time to be completed first.

e. Every server should specify INADDR ANY as internet address while binding

f.
7.9.1

It is needed for hosts with multiple IP addresses


Interactive connection oriented server (TCP)

Introduction

1.

> An iterative TCP server is a server program which handles only one client
program at any point of time by establishing a connection between client and
server.

The client program will work like a simple client socket program, whereas only
the algorithm for the server is modified.

Interactive servers are used when the server process knows in advance how long it
takes to handle each client request and it handles each request by itself.

i.

Only a Single copy of server runs at all times

ii.

A client may have to wait if the server is busy at that point of time ,

2.

Algorithm for Interactive server


a. Create a TCP socket

Allocate a new socket

E.g. : ServerSocket calcServer = new ServerSocket(serverPort);


b. Bind it to a port/address (INADDR_ANY)

bind to the well-known address for the service being offered

c. Place the socket in passive mode (listen)

Place the socket in passive mode

d. Accept connection and obtain socket - clientSocket

Accept the next connection request from the socket, and obtain a new
socket for the connection

e.g.: Socket clientSocket = calcServer.accept();


e. Interact with client using socket- clientSocket

Read a request repeatedly from the client and formulate a response

Send a reply back to the

client
E.g.
BufferedReader br =
new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
PrintStream ps = new PrintStream(clientSocket.getOutputStream());

f. Close socket clientSocket and go to (4) or...

3.

When finished with a particular client, close the connection

Return to step 3 to accept a new connection

E.g. clientSocket.close();
Example
a. The example code is to find factorial of number sent by a client program and
return the factorial value to the requesting client.
b. In order to simulate the effect of time,consuming client requests, we make the
server program to sleep for 200 milliseconds after performing each addition.
c. As iterative servers are single-threaded programs, the whole program sleeps
when
we invoke the sleep() static function of the Thread class.

>
Program 3 : Socket program to compute and send factorial of
number from server to client.

Running above code :

Output:

Output:

7.9.2

1.

Introduction

Interactive Connectionless server (UDP)

An iterative UDP server is a server program which handles only one client
program at any point of time without establishing any connection between client
and server.
The client program will work like a simple client socket program, whereas only
the algorithm for the server is modified.
This UDP protocol is unreliable and does not guarantee the end to end delivery of
packet.
Concurrent servers are used when the server process knows in advance how long
it takes to handle.

Each client request only a Single copy of server runs at all times.
2.

Algorithm for Interactive UDP server


a. Create a UDP socket

Create and allocate a new server socket.

E.g. : DatagramSocket mySocket = new DatagramSocket();


b. Bind it to a port (INADDR_ANY)

Create a socket and bind it to the well known address for the service being
offered.

Then leave the socket unconnected state.


c. Read message from client (recvfrom)

Now repeatedly call recvfrom to receive the next request from a client.

Create a new slave thread/process to handle the response of request given


by each client.

Receive a specific request upon creation as well as access to the socket


E.g. :

byte[] buffer = message.getBytes();

DatagramPacket packet =

new DatagramPacket(buffer, buffer.length, receiverHost,

receiverPort);

d. Process the request

Perform all task and processing the data coming from the client.

e. Send reply to client

f. Go to (c) or...

g. Exit

7.10 Concurrent Servers


__________________________________________________________
1.

Introduction

A concurrent TCP server is a server program which can handles multiple client
programs at any point of time by establishing a connection between client and
server.

The client program will work like a simple client socket program, whereas only
the algorithm for the server is modified.

2.

E.g. : mySocket.send(packet);

Form a reply according to the application protocol and send it back to the
client using sendto process.

Working

An alternative design is a concurrent server; it can process client requests with


variable service request time.

When a client request is received, the server process generates a separate thread.
which is exclusively meant for a particular client.

So, if a program has to sleep after each processing step, it would be the particular
thread (doing that processing) that will sleep and not the whole server process,
which was the case with an iterative server.

While a thread of a process is sleeping, the operating system can schedule the
other threads of this process to run.

By doing above process waiting time of client requests with a relatively shorter
processing time, could be significantly reduced.

Code for the client program is independent of the design choice for the server.

In other words, one should be able to use the same client program with either an
iterative server or a concurrent server.

7.10.1 Concurrent connection oriented server (TCP)

1.

Introduction
A concurrent TCP server is a server program which can handles multiple
client; programs at any point of time by establishing a connection between client
and server_

The client program will work like a simple client socket program, whereas only
the algorithm for the server is modified.

Concurrent servers are used when the server process don't know in advance how
long it takes to handle client request.

2.

Algorithm for concurrent connection oriented server


a. Create a TCP socket

Allocate a new socket


E.g.
ServerSocket calcServer = new ServerSocket(serverPort);

b. Bind it to a port (INADDR_ANY)

bind to the well-known address for the service being offered

c. Place the socket in passive mode (listen)

Place the socket in passive mode

d. Accept connection

Accept the next connection request from the socket, and obtain a new socket
for the connection
E.g. : Socket clientSocket = calcServer.accept();
e. Fork slave process

i.

Close old socket


Close the socket for the old connection

E.g.
clientSocket.close();

ii.

Interact with the client using new socket

Close the socket for the old connection

E.g.

BufferedReader br =
new BufferedReader(new

InputStreamReader(clientSocket.getInputStream()));

int count = Integer.parseInt(br.readLine());

PrintStream ps = new PrintStream(clientSocket.getOutputStream());

iii.

Close new connection


Close the socket for new connection opened recently.

E.g. : factThread thread = new factThread(clientSocket); iv.

Exit

f.

Close new socket

Close the socket for new connection opened recently.

E.g.: clientSocket.close();
g.

Go to

(d) or...
h.
3.

Exit
Example

a.
The example code is to find factorial of number sent by a client program and
return the factorial value to the requesting client.

b.
In order to simulate the effect of time consuming client requests, we make the
server program to sleep for 200 milliseconds after performing each addition.
>
Program 4: Socket program to compute and send factorial
of number from server to client

PrintStream ps = new

PrintStream(clientSocket.getOutputStream( ));

ps.println(fact);

ps.flush();

clientSocket.close( );

}catch(Exception e){e.printStackTrace();}

}}

class ConcurrentTCPServer

public static void main(String[ ] args)

Try{

int serverPort = lnteger.parselnt(args[0]);

ServerSocket calcServer = new ServerSocket(serverPort);

--------------------------------System.out. println("............---------------
---------------------------------...................");

System.out.println("Program : Concurrent connection oriented

Server");
........................................................System.out.println("--------------
...................................................--.......................");

System.out.println("Server is started with port"+ args[0]);

..........................................................System. out.println("-......----- .....................................................-----------");


..............................................................................System.out.println("....Waiti
ng for client.....................................................");
.......................................................................System, out.println(- ..........................................................................");

while (true) {

catch(Exception e){e.printStackTrace( );}


}

_____________________________

Running above code :

Step 1 : Compile and run server socket

Copy Java code file to bin folder of Java

Compile ConcurrentTCPServer.java program using javac command

Run ConcurrentTCPServer.java program using Java command pass port number as argument

in
below program 1111 is port number.

Output:

Step 2: Compile and run Client socket


Copy Java code file to bin folder of Java
Compile FactClient.java program using javac command
Run FactClient.java program using Java command pass port number as argument in
below
program 1111 is port number.

Output:

Step 3 : Compile and run another Client socket

Copy java code file to bin folder of Java on other machine

Compile FactClient.java program using javac command

Run FactClient.java program using java command pass port number as argument in
below

program 1111 is port number.

Output:

7.10.2 Concurrent Connectionless server

(UDP) 1.

Introduction

A concurrent UDP server is a server program can handles multiple client


programs at any point of time without establishing a connection between client
and server.

The client program will work like a simple client socket program, whereas only
the algorithm for the server is modified.

concurrent servers are used when the server process don't know in advance how
long it takes to handle each client request.

Only a Single copy of server runs at all times

2.

Algorithm for Interactive server


a. Create a UDP socket

Create and allocate a new server socket.

E.g. : DatagramSocket mySocket = new DatagramSocket();


b. Bind it to a port (INADDR_ANY)

Create a socket and bind it to the well known address for the service being
offered.

Then leave the socket unconnected state.


c. Read message from client (recvfrom)

Now repeatedly call recvfrom to receive the next request from a client.

Create a new slave thread/process to handle the response of request given


by each client.

Receive a specific request upon creation as well as access to the socket

E.g. : byte[] buffer = message.getBytes();


DatagramPacket packet = new DatagramPacket(buffer,

buffer.length, receiverHost, receiverPort);


d. Fork slave process

i.

Process the socket

Perform all task and processing the data coming from the

client,
ii.

Send reply to client

Form a reply according to the application protocol and send it


back
to the client using sendto process.

; iii.

E.g.

mySocket.send(packet)

Exit

e. Close new socket

Close the socket for new connection opened recently.

E.g.: mySocket.close();

f. Go to (c) or...

g. Exit

Review Questions

Q. 1

Write a Short Note on Socket Programming.

Q. 2

Explain various Types of Sockets in Java Programming.

Q. 3

Write a Short Note on Stream Socket.

Q. 4

Write a Short Note on Datagram Socket.

Q. 5

Explain Java TCP Programming.

Q. 6

Explain Java UDP Programming.

Q. 7

Discuss TCP/IP and UDP/IP Communication as apply to socket.

Q. 8

Explain any to constructor used in Java to create TCP Client Socket.

Q. 9

Explain any to constructor used in Java to create UDP Client Socket.

Q. 10

Explain any to constructor used in Java to create TCP Server Socket.

Q. 11

How does Server Socket receive incoming request from client and how does it

terminate connections.

Q. 12

Write a Short Note on JAVA.NET.SERVERSOCKET Class.

Q. 13

Explain Socket Class and Server Socket Class with their methods.

Q. 14

What is Socket ? Which function create socket ? what are its argument ?

Q. 15

What is purpose of argument.

Q. 16

Explain working of connection oriented interactive servers with help of sample

code.

Q. 17

Explain Working of connectionless interactive servers.

Q. 18

Explain working of connection oriented Concurrent servers with help of sample

Q. 19

Explain Working of connectionless Concurrent servers.

Q. 20

Write simple client/server application which will print present time to any client

code.

which is
connected server without reading anything from client.

Q. 21

Write client/server application using Datagram Packet and DatagramSocket

where
client send number to server and server returns to server square up that number.

Q. 22 Write client server application using Socket and ServerSocket where client send
number to server and server returns reverse of that number.

Q. 23 Write client server application using Socket and ServerSocket where client send
Two number to server and server returns addition of those number.

Q. 24 Write client server application that construct to socket object to connect to host
port using TCP. It must give message 'Connection Establish' on setting connection and
"connection Terminated" on closing connection other errors should handle with proper
messages.

Q. 25 Write a Short Note on JAVA.NET.DATAGRAMSOCKET Class.

Appendix A J

> Practical 1 :

List Of Practiais

Write a function in JAVA to simulate the cache control, input and

output modules of ARP.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

Practical 2 :

Write a JAVA code to implement the routing algorithm for

RIP.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

> Practical 3 :

IDE : NetBeans or Eclipse

Write a JAVA code to find the shortestpath between two points in

the network.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

> Practical 4 :

Write a JAVA code to simulate the main module of TCP.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

Practical 5 :

Write a JAVA code that calculates the checksum of UDP

datagram.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

> Practical 6 :

Write a JAVA code for TCP echo Server application.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

> Practical 7 :

Write a JAVA client/server TCP code in which a client sends a

number to server and server responds by returning its factorial.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

> Practical 8:

Write a JAVA client/server TCP code to illustrate simple chat application.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

> Practical 9 :

Write a JAVA client/server UDP code in which a client greets the

server and the server send date and time to the client.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

> Practical 10 :

Write JAVA client/server UDP code where client send series of

numbers to server and server returns greatest among them.

Preferred Programming Tools

Development Tool : Java Development Kit 1.4 or above

Environment : Java runtime environment 1.4 or above

IDE : NetBeans or Eclipse

You might also like