0% found this document useful (0 votes)
12 views28 pages

Lab Manual

The document is a lab manual for Computer Network-II at Dr. D. Y. Patil Pratisthan’s College of Engineering, detailing various experiments related to client-server models using TCP and UDP protocols. It includes implementations of services such as Daytime, ECHO, and file transfer protocols, along with theoretical explanations, algorithms, and code examples for both server and client sides. The manual aims to enhance understanding of network applications, socket programming, and the fundamentals of Domain Name Systems.

Uploaded by

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

Lab Manual

The document is a lab manual for Computer Network-II at Dr. D. Y. Patil Pratisthan’s College of Engineering, detailing various experiments related to client-server models using TCP and UDP protocols. It includes implementations of services such as Daytime, ECHO, and file transfer protocols, along with theoretical explanations, algorithms, and code examples for both server and client sides. The manual aims to enhance understanding of network applications, socket programming, and the fundamentals of Domain Name Systems.

Uploaded by

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

Dr. D. Y.

Patil Pratisthan’s College of


Engineering, Salokhenagar.

Department of Computer Science &Engineering

LAB MANUAL Computer Network-II


Sr. List of Experimens
No.
1 Client program using UDP to connect to well-known services (echo, time of the day service etc.).

2 Implementing concurrent TCP multiservice client/server.

3 Implementing Iterative UDP client/server.

4 Study of following DNS Tools with all its options. nslookup, dig, host,whois.

5 Implement trivial file transfer protocol (TFTP).

6 Configuration of basic services for FTP, HTTP, Telnet etc. on Linux Platform

7 Write program to send a mail using SMTP commands and receive a mail using POP3commands.

8 Capturing & amp; Analyzing operation of various application layer protocols using network
protocol analyzer. (Wireshark and tcpdump)

9 Study of various streaming multimedia protocols in Internet (Using various audio/video


streaming services on the Internet)

Course Outcomes
1 Develop the client server model using sockets
2 Understand and apply next generation protocol and addressing model
3 Elaborate the fundamentals of Domain Name Systems
4 Apply the concepts of Remote login and FTP in network applications
Experiment No – 1

Experiment Title – Implementation of Daytime services using connection oriented sockets


systems calls.
Aim – To understand connection oriented Daytime services.

Theory -
TCP Based Daytime Service

One daytime service is defined as a connection based application on TCP. A server listens for
TCP connections on TCP port 13. Once a connection is established the current date and time is
sent out the connection as a ascii character string (and any data received is thrown away). The
service closes the connection after sending the quote.

Daytime Syntax
There is no specific syntax for the daytime. It is recommended that it be limited to the ASCII
printing characters, space, carriage return, and line feed. The daytime should be just one line. One
popular syntax is: Weekday, Month Day, Year Time-Zone

Example:
Tuesday, February 22, 1982 17:37:43-PST
Daytime Protocol
Another popular syntax is that used in SMTP:
dd mmm yy hh:mm:ss zzz
Example: 02 FEB 82 07:59:01 PST

ALGORITHM:
1. This is the implementation of the daytime using TCP method. In this program the time is
denoted in some formatted type as below
DAY TIME IS --- >15 FEB 2010 16:23:24 IST
2. In this program the standard port number used is “13”
3. The type of the family used is AF_INET and the port no used is”13”and internet address
used is “192.168.2.150” .
4. The socket is created in the program uses the SOCK_STREAM method which
corresponds to the TCP protocol .
5. The headers implemented are “stdio.h” ,”sys/socket.h”,netinet/in.h”.
6. The first one is the standard input output file,the second is the type of the connection that
is implementation in the program ,the third is the socket creation file, the last one is the
internet protocol
Implementation –

Server Side -
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <time.h>

int main()
{
int sfd,r,bi,port;
char buff[1024];
struct sockaddr_in servaddr,cliaddr;
socklen_t clilen;
sfd=socket(AF_INET,SOCK_DGRAM,0);
if(sfd==-1)
{
perror("Socket");
return 0;
}
printf("\n Enter the port no:");
scanf("%d",&port);
printf("The port no is:%d\n",port);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(port);
servaddr.sin_addr.s_addr = INADDR_ANY;
bi=bind(sfd,(struct sockaddr*)&servaddr,sizeof(servaddr));
if(bi==-1)
{
perror("Bind()");
return 0;
}
clilen = sizeof(cliaddr);
r=recvfrom(sfd,buff,sizeof(buff),0,(struct sockaddr*)&cliaddr,&clilen);
buff[r]=0;
time_t ticks;
ticks = time(NULL);
snprintf(buff,sizeof(buff),"%24s\r\n",ctime(&ticks));
sendto(sfd,buff,sizeof(buff),0,(struct sockaddr*)&cliaddr,sizeof(cliaddr));
exit(0);
return 0;
}

Client Side -
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>

int main()
{
int listenfd,port,r;
char buff[1024];
struct sockaddr_in servaddr,cliaddr;
socklen_t servlen;
listenfd = socket(AF_INET,SOCK_DGRAM,0);
if(listenfd==-1)
{
perror("Socket");
return 0;
}
printf("\n Enter the port no:");
scanf("%d",&port);
printf("The port no is:%d",port);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(port);
servaddr.sin_addr.s_addr = INADDR_ANY;
sendto(listenfd,buff,sizeof(buff),0,(struct sockaddr*)&servaddr,sizeof(servaddr));
r=recvfrom(listenfd,buff,sizeof(buff),0,(struct sockaddr*)&servaddr,&servlen);
buff[r]=0;
printf("\n The time received from the server:%s\n",buff);
exit(0);
return 0;
}

Conclusion: Daytime services using connection oriented sockets system calls


Experiment No – 2
Experiment Title – Implementation of ECHO services using connection less sockets systems
calls.
Aim – To write a program for UDP echo client server.

Theory -
An Echo Server is an application that allows a client and a server to connect so a client can send
a message to the server and the server can receive the message and send, or echo, it back to the
client.
In the UDP Echo server , we create a socket and bind to a advertised port number. Then an infinite
loop is started to process the client requests for connections. The process receives data from the
client using recvfrom () function and echoes the same data using the sendto() function.

ALGORITHM:
SERVER:
STEP 1: Start
STEP 2: Declare the variables for the socket
STEP 3: Specify the family, protocol, IP address and port number
STEP 4: Create a socket using socket() function
STEP 5: Bind the IP address and Port number
STEP 6: Listen and accept the client’s request for the connection
STEP 7: Read and Display the client’s message
STEP 8: Stop
CLIENT:
STEP 1: Start
STEP 2: Declare the variables for the socket
STEP 3: Specify the family, protocol, IP address and port number
STEP 4: Create a socket using socket() function
STEP 5: Call the connect() function
STEP 6: Read the input message
STEP 7: Send the input message to the server
STEP 8: Display the server’s echo
STEP 9: Close the socket
STEP 10: Stop

Implementation –

Server Side -
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<errno.h>
void dg_echo (int sockfd, struct sockaddr *pcliaddr, socklen_t clilen);
int main (int argc, char **argv)
{
int sockfd,port;
struct sockaddr_in servaddr, cliaddr;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
printf("Enter the port number : ");
scanf("%d",&port);
bzero (&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(port);
bind (sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr));
dg_echo(sockfd, (struct sockaddr *) &cliaddr, sizeof(cliaddr));
}
void dg_echo (int sockfd, struct sockaddr *pcliaddr, socklen_t clilen)
{
int n;
socklen_t len;
char mesg[1000];
len = clilen;
while(strcmp(mesg,"bye")!=0)
{
n = recvfrom (sockfd, mesg, 1000, 0, pcliaddr, &len);
printf("\nClient message :%s",mesg);
sendto (sockfd, mesg, n, 0, pcliaddr, len);
}
exit(0);
}

Client Side -
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<errno.h>
void dg_cli(FILE *fp,int sockfd,struct sockaddr_in *psa,socklen_t servlen);

int main (int argc, char **argv)


{
int sockfd,port;
struct sockaddr_in servaddr;
bzero (&servaddr, sizeof(servaddr));
printf("Enter the port number : ");
scanf("%d",&port);
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(port);
inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
dg_cli (stdin,sockfd,(struct sockaddr_in *)&servaddr,sizeof(servaddr));
exit(0);
}
void dg_cli(FILE *fp,int sockfd,struct sockaddr_in *psa,socklen_t servlen)
{
int n;
char sendline[1000], recvline[1000 + 1];
while(strcmp(recvline,"bye")!=0)
{
printf("\nEnter the message : ");
while (fgets (sendline, 1000, fp) != NULL)
{
sendto(sockfd,sendline,100,0,psa,servlen);
n = recvfrom(sockfd, recvline, 1000, 0, NULL, NULL);
recvline[n] = 0;
fputs (recvline, stdout);
}
exit(0);
}
}

Conclusion: Thus we have studied Implementation of ECHO services using connection less
sockets systemscalls.

Experiment Title – Implementation of ECHO services using connection oriented sockets


systems calls.
Aim – To write a program for TCP echo client server.
Theory –
An echo server is usually an application which is used to test if the connection between a client
and a server is successful.
An echo server is a programmer that sends you back the same message you just sent it. For it to
work, you will need a client, and a server.
The client is what will send the message, and where you will see the response appear. The server
receives the message and sends it back to the client.
In the TCP Echo client a socket is created. Using the socket a connection is made to the server
using the connect () function. After a connection is established, we send messages input from
the user and display the data received from the server using send () and read() functions.

ALGORITHM:

SERVER:
STEP 1: Start
STEP 2: Declare the variables for the socket
STEP 3: Specify the family, protocol, IP address and port number
STEP 4: Create a socket using socket() function
STEP 5: Bind the IP address and Port number
STEP 6: Listen and accept the client’s request for the connection
STEP 7: Read the client’s message
STEP 8: Display the client’s message
STEP 9: Close the socket
STEP 10: Stop

CLIENT:
STEP 1: Start
STEP 2: Declare the variables for the socket
STEP 3: Specify the family, protocol, IP address and port number
STEP 4: Create a socket using socket() function
STEP 5: Call the connect() function
STEP 6: Read the input message
STEP 7: Send the input message to the server
STEP 8: Display the server’s echo
STEP 9: Close the socket
STEP 10: Stop
Implementation –

Server Side -

#include<stdio.h#include<sys/types.h> #include<sys/socket.h>#include<netinet/in.h> #include<arpa/inet.h>


#include<stdlib.h> #include<unistd.h> #include<string.h> #include<errno.h>
int main()
{
int sock,con,byte_rec,flag=0,port;
char send_data[1024],rec_data[1024];
struct sockaddr_in ser,cli;
int sin_size;
if((sock=socket(AF_INET,SOCK_STREAM,0))==-1)
{
perror("Socket\n");
exit(1);
}
ser.sin_family=AF_INET;
printf("Enter the port number : ");
scanf("%d",&port);
ser.sin_port=htons(port);
ser.sin_addr.s_addr=INADDR_ANY;
bzero(&(ser.sin_zero),8);
if(bind(sock,(struct sockaddr*)&ser,sizeof(struct sockaddr))==-1)
{
perror("can't bind\n");
exit(1);
}
if(listen(sock,3)==-1)
{
perror("listen\n");
exit(1);
}
printf("Waiting \n");

sin_size=sizeof(struct sockaddr_in);
con=accept(sock,(struct sockaddr*)&cli,&sin_size);
printf("Connected\n\n");
while(1)
{
byte_rec=recv(con,rec_data,1024,0);
rec_data[byte_rec]='\0';
printf("received data : %s\n\n",rec_data);
send(con,rec_data,strlen(rec_data),0);
if(strcmp(rec_data,"end")==0)
break;
}
close(con);
close(sock);
return 0;
}

Client Side -

#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<netdb.h>
#include<errno.h>

int main()
{
int sock,byte_rec,port;
char send_data[1024],rec_data[1024];
struct hostent *host;
struct sockaddr_in ser,cli;
host=gethostbyname("127.0.0.1");
if((sock=socket(AF_INET,SOCK_STREAM,0))==-1)
{
perror("Socket\n");
exit(1);
}
printf("socket created\n");
ser.sin_family=AF_INET;
printf("Enter the port number : ");
scanf("%d",&port);
ser.sin_port=htons(port);
ser.sin_addr= *((struct in_addr *)host->h_addr);
bzero(&(ser.sin_zero),8);
if(connect(sock,(struct sockaddr*)&ser,sizeof(struct sockaddr))==-1)
{
perror("connect\n");
exit(1);
}

while(1)
{
printf("\nsend:");
scanf("%s",send_data);
send(sock,send_data,strlen(send_data),0);
byte_rec=recv(sock,rec_data,1024,0);
rec_data[byte_rec]='\0';
printf("Rec data : %s\n",rec_data);

if(strcmp(rec_data,"end")==0)
break;
}
close(sock);
return 0;
}

Conclusion: Thus we have studied Implementation of ECHO services using connection


oriented sockets systems calls.
Experiment No – 3
Experiment Title – Implementing Iterative UDP client/server.
Aim – To understand concept of iterative server and no of connection request handle in iterative
manner.

Theory -
Iterative Server

An iterative server handles both the connection request and the transaction involved in the call
itself.

Iterative servers are fairly simple and are suitable for transactions that do not last long.
However, if the transaction takes more time, queues can build up quickly.

 An iterative server serves the requests one after the other.


 It is easier to design and implement.
 Iterative design is suitable when the service time for each request is small (because the
mean response time is still acceptably small).
 It is suitable for simple services such as the TIME service. Iterative design is not suitable
when the service time for a request may be large.

Example -
Two clients are using a file transfer service:
• The 1st client requests to get a file of size 200 Mbytes,
• The 2nd client requests to get a file of size 20 bytes.
If iterative design is used, the 2nd client has to wait a long time.

1st client (200 Mbytes)


Iterative
Server
2nd client (20 bytes)

Conclusion –
Iterative servers are fairly simple. We understand concept and implemented iterative
server using socket program using UDP.
Implementation –
Server Side -
#include<stdio.h>
#include<sys/socket.h>
#include<netdb.h>
#include<string.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{
int sd,sd1,i,clilen,len,sport;
struct sockaddr_in ser,cli;
char smsg[20],rmsg[20];
printf("\n\t Enter the Port : ");
scanf("%d",&sport);

if((sd=socket(AF_INET,SOCK_STREAM,0))<0)
{
printf("\n\t Error in socket");
return 0;
}
bzero(&ser,sizeof(ser));
ser.sin_family=AF_INET;
ser.sin_port=htons(sport);
ser.sin_addr.s_addr=htonl(INADDR_ANY);
if(bind(sd,(struct sockaddr*)&ser,sizeof(ser)) <0)
{
printf("\n\t Error in bind");
return 0;
}
if(listen(sd,5) <0)
{
printf("\n\t Error in Listen");
return 0;
}
do
{
printf("\n\t Enter the client no to be communicate : ");
scanf("%d",&i);
if(i==0)
exit(0);
printf("\n\t Client %d is connected",i);
clilen=sizeof(cli);
if((sd1=accept(sd,(struct sockaddr*)&cli,&clilen)) <0)
{
printf("\n\t Error in Accept");
return 0;
}
printf("\n\t Accepted ");
do
{
recv(sd1,rmsg,20,0);
printf("\n\t Clinet Msg Received : %s ",rmsg);
printf("\n\t Enter Server String : ");
scanf("%s",smsg);
send(sd1,smsg,20,0);
wait(20);
} while((strcmp(smsg,"exit"))!=0);
} while(i!=0);
close(sd);
}
Client Side –
#include<stdio.h>
#include<sys/socket.h>
#include<netdb.h>
#include<string.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<unistd.h>
#include<stdlib.h>
int main()
{
int sd,len,cport;
struct sockaddr_in ser;
char smsg[20],rmsg[20];
printf("\n\t Enter the Port : ");
scanf("%d",&cport);
if((sd=socket(AF_INET,SOCK_STREAM,0))<0)
{
printf("\n\t Error in socket");
return 0;
}
bzero(&ser,sizeof(ser));
ser.sin_family=AF_INET;
ser.sin_port=htons(cport);
ser.sin_addr.s_addr=htonl(INADDR_ANY);
if(connect(sd,(struct sockaddr*)&ser,sizeof(ser)) <0)
{
printf("\n\t Error in connect");
exit(-1);
}
do
{
printf("\n\t Enter the Client String :");
scanf("%s",smsg);
send(sd,smsg,20,0);
wait(20);
recv(sd,rmsg,20,0);
printf("\n\t Server Msg Received : %s ",rmsg);
}while((strcmp(rmsg,"exit"))!=0);
close(sd);
}

Conclusion: Thus we have studied Iterative UDP client/server


Experiment No – 4

Experiment Title – Study of following DNS Tools with all its options. nslookup, dig, host, whois.

Aim – Study of DNS tools


Theory – 1. NSLOOKUP

nslookup is a command-line tool used for querying the Domain Name System (DNS) to obtain
domain name or IP address mapping information.

Basic Commands:

 Interactive Mode: nslookup


 Non-Interactive Mode: nslookup [hostname]
 Specify DNS Server: nslookup [hostname] [DNS server]

Options:

 Query Type: nslookup -type=[record type] [hostname] (e.g., A, MX, NS, etc.)
 Reverse Lookup: nslookup [IP address]
 Debug Mode: nslookup -debug [hostname]
 Port Number: nslookup -port=[port number] [hostname]
 Timeout: nslookup -timeout=[seconds] [hostname]
 Retry Count: nslookup -retry=[count] [hostname]

2. DIG (Domain Information Groper)

dig is a flexible command-line tool used for querying DNS name servers.

Basic Commands:

 Basic Query: dig [domain]


 Query Specific DNS Server: dig @[DNS server] [domain]

Options:

 Query Type: dig [domain] [record type]


 Reverse Lookup: dig -x [IP address]
 Short Answer: dig +short [domain]
 Verbose Output: dig +noall +answer [domain]
 Trace Path: dig +trace [domain]
 DNSSEC: dig +dnssec [domain]
 TTL Information: dig +ttlunits [domain]
 Query Timeout: dig [domain] +time=[seconds]
 Retry Attempts: dig [domain] +retry=[count]

3. HOST

host is a simple utility for performing DNS lookups.

Basic Commands:

 Basic Query: host [domain]


 Query Specific DNS Server: host [domain] [DNS server]

Options:

 Reverse Lookup: host [IP address]


 Query Type: host -t [record type] [domain]
 Verbose Output: host -v [domain]
 All Records: host -a [domain]
 DNSSEC: host -C [domain] (Checks DNSSEC chain)
 IPv4 Lookup: host -4 [domain]
 IPv6 Lookup: host -6 [domain]
 Timeout: host -W [seconds] [domain]
 Retry Count: host -R [count] [domain]

4. WHOIS

whois is a command-line utility used to query databases that store the registration information of
domain names.

Basic Commands:

 Basic Query: whois [domain]

Options:

 Specific WHOIS Server: whois -h [whois server] [domain]


 Verbose Output: whois -v [domain]
 Query by IP Address: whois [IP address]
 Query by Email: whois [email]
 Query by Handle: whois [handle]
 Timeout: whois -T [seconds] [domain]
 Format Output: whois -F [domain] (Formats the output)
 Redirect Request: whois -r [domain] (Follows redirects automatically)
 Specify Output Format: whois -f [format] [domain]

Using the Tools


Example Usage

1. NSLOOKUP:

sh
code
nslookup google.com
nslookup -type=MX google.com
nslookup google.com 8.8.8.8
nslookup -debug google.com

2. DIG:

sh
code
dig google.com
dig @8.8.8.8 google.com
dig google.com MX
dig -x 8.8.8.8
dig +short google.com

3. HOST:

sh
code
host google.com
host google.com 8.8.8.8
host -t MX google.com
host 8.8.8.8
host -v google.com

4. WHOIS:

sh
code
whois google.com
whois -h whois.verisign-grs.com google.com
whois 8.8.8.8
whois -v google.com

By using these tools with their various options, one can effectively perform DNS queries and
troubleshoot issues related to domain names and IP addresses.

Conclusion: Thus we have studied various DNS tools


Experiment No – 5
Experiment Title – Configuration of basic services for FTP.
Aim – To understand configuration and get knowledge about basic concept of FTP.

Theory -
FTP
NAME ftp - Internet file transfer program
ftp [-pinegvd] [host]
pftp [-inegvd] [host]
DESCRIPTION
Ftp is the user interface to the Internet standard File Transfer Protocol. The program allows a user
to transfer files to and from a remote network site Options may be specified at thecommand line,
or to the command interpreter.
-p Use passive mode for data transfers. Allows use of ftp in environ¡ments where a firewall
prevents connections from the outside world back to the client machine. Requires that
the ftp server support the PASV command. This is the default now for all clients (ftp and
pftp) due to security concerns using the PORT transfer mode. The flag is kept for
compatibility only and has no effect anymore.
-i Turns off interactive prompting during multiple file transfers.
-n Restrains ftp from attempting ``auto-login'' upon initial connection. If auto-login is enabled,
ftp will check the .netrc (see netrc(5)) file in the user's home directory for an entry
describing an account on the remote machine. If no entry exists, ftp will prompt for the
remote machine login name (default is the user identity on the local machine), and, if
necessary, prompt for a password and an account with which to login.
-e Disables command editing and history support, if it was compiled into the ftp executable.
Otherwise, does nothing.
-g Disables file name globbing.
-v Verbose option forces ftp to show all responses from the remote server, as well as report
on data transfer statistics.
-d Enables debugging. The client host with which ftp is to communicate may be specified on
the command line. If this is done, ftp will immediately attempt to establish aconnection to
an FTP server on that host; otherwise, ftp will enter its command interpreter and await
instructions from the user. When ftp is awaiting commands from the user the prompt `ftp>'
is provided to the user. The following commands are recognized by ftp: ! [command
[args]]
Invoke an interactive shell on the local machine. If there are arguments, the first is taken to be
command to execute directly, with the rest of the arguments as its arguments.
$ macro-name [args]
Execute the macro macro-name that was defined with the macdef command. Arguments are
passed to the macro unglobbed.
account [passwd] Supply a supplemental password required by a remote system for access to
resources once a login has been successfully completed. If no argument is included, the
user will be prompted for an account password in a non-echoing input mode.
append local-file [remote-file]
Append a local file to a file on the remote machine. If remote-file is left unspecified, the local file
name is used in naming the remote file after being altered by any ntrans or nmap setting. File
transfer uses the current settings for type, format, mode, and structure.

Conclusion: Thus we have studied Configuration of basic services for FTP


Experiment No – 6
Experiment Title – Configuration of basic services for FTP, HTTP, Telnet etc. on Linux Platform

Aim: – Configuration of basic services for FTP, HTTP, Telnet

Procedure: 1. FTP Service (vsftpd)

vsftpd (Very Secure FTP Daemon) is a popular FTP server for Unix-like systems.

Installation and Configuration:

1. Install vsftpd:

sh

code
sudo apt-get update
sudo apt-get install vsftpd

2. Configure vsftpd: Edit the configuration file:

sh
code
sudo nano /etc/vsftpd.conf

o Enable anonymous FTP (optional):

sh
code
anonymous_enable=YES

o Allow local users to log in:

sh
code
local_enable=YES

o Enable file upload:

sh
code
write_enable=YES

o Set local umask:

sh
code
local_umask=022

3. Restart vsftpd:

sh
code
sudo systemctl restart vsftpd
sudo systemctl enable vsftpd
4. Test FTP: Use an FTP client or command line to connect:

sh
code
ftp localhost
2. HTTP Service (Apache)

Apache HTTP Server is one of the most popular web servers.

Installation and Configuration:

1. Install Apache:

sh
code
sudo apt-get update
sudo apt-get install apache2

2. Configure Apache: The default configuration file is located at:

sh
code
/etc/apache2/apache2.conf

Virtual Hosts can be configured in:

sh
code
/etc/apache2/sites-available/000-default.conf

Example Virtual Host:

sh
code
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

3. Restart Apache:

sh
code
sudo systemctl restart apache2
sudo systemctl enable apache2

4. Test HTTP: Open a web browser and go to http://localhost.

3. Telnet Service

Telnet is a network protocol used to provide a command-line interface for communication with a
remote device or server.

Installation and Configuration:

1. Install Telnet Server:


sh
code
sudo apt-get update
sudo apt-get install xinetd telnetd

2. Configure Telnet: Create a new configuration file for Telnet:

sh
code
sudo nano /etc/xinetd.d/telnet

Add the following content:

sh
code
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}

3. Restart xinetd:

sh
code
sudo systemctl restart xinetd
sudo systemctl enable xinetd

4. Test Telnet: Use a Telnet client or command line to connect:

sh
code
telnet localhost
Additional Configurations and Security Considerations
FTP:

 User Management: Create users for FTP access:

sh
code
sudo adduser ftpuser
sudo passwd ftpuser

 Securing FTP: Consider using SFTP (part of the SSH suite) for secure file transfer.

HTTP:

 Document Root: Place your website files in /var/www/html.


 Modules: Enable/disable modules using a2enmod and a2dismod.
 Security: Use HTTPS by installing and configuring SSL/TLS certificates.
Telnet:

 Security Warning: Telnet is not secure as it transmits data in plain text. Use SSH instead.
 Firewall: Ensure the appropriate ports are open in your firewall.

Conclusion:

By following these steps, you can configure basic FTP, HTTP, and Telnet services on a Linux
platform. Always consider the security implications of running these services, especially Telnet,
which should be replaced by SSH for secure remote access.
Experiment No – 7

Experiment Title- Write program to send a mail using SMTP commands and receive a mail using
POP3commands.

Aim: Study program to send a mail using SMTP commands and receive a mail using POP3commands

Proceure: SMTP (Simple Mail Transfer Protocol) and POP3 (Post Office Protocol version 3) are
protocols used for sending and receiving emails, respectively. They operate over TCP/IP and are
fundamental in email communication. Below, I'll outline the basic commands used with these protocols:

SMTP Commands

SMTP is used for sending emails from a client to a server or between servers. Here are some basic SMTP
commands:

1. EHLO/HELO: Initiates an SMTP session and identifies the client to the server.
o Syntax: EHLO hostname or HELO hostname
2. MAIL FROM: Specifies the sender's email address.
o Syntax: MAIL FROM: <[email protected]>
3. RCPT TO: Specifies the recipient's email address. Multiple recipients can be specified.
o Syntax: RCPT TO: <[email protected]>, <[email protected]>
4. DATA: Marks the start of the message data. The actual email message follows this command.
o Syntax: DATA
5. Subject: Specifies the subject of the email.
o Syntax: Subject: Your subject here
6. Message Body: Contains the content of the email.
o Syntax: Enter the body of the email here. End with a period . on a new line to indicate the
end of the message.
7. QUIT: Terminates the SMTP session.
o Syntax: QUIT

POP3 Commands

POP3 is used by email clients to retrieve emails from a server. Here are some basic POP3 commands:

1. USER: Specifies the username for authentication.


o Syntax: USER username
2. PASS: Specifies the password for authentication.
o Syntax: PASS password
3. LIST: Lists the emails and their sizes.
o Syntax: LIST
4. RETR: Retrieves a specific email by its sequence number.
o Syntax: RETR message_number
5. DELE: Marks an email for deletion.
o Syntax: DELE message_number
6. QUIT: Terminates the POP3 session and logs out.
o Syntax: QUIT

Sending an Email using SMTP Commands

You can send an email using telnet to connect to an SMTP server and manually issue the SMTP commands.
Below is a bash script that does this:
Code:
#!/bin/bash

SMTP_SERVER="smtp.example.com"
SMTP_PORT=25
MAIL_FROM="[email protected]"
RCPT_TO="[email protected]"
SUBJECT="Test Email"
BODY="This is a test email sent using SMTP commands."

(
echo "HELO localhost"
sleep 1
echo "MAIL FROM:<$MAIL_FROM>"
sleep 1
echo "RCPT TO:<$RCPT_TO>"
sleep 1
echo "DATA"
sleep 1
echo "Subject: $SUBJECT"
echo "From: $MAIL_FROM"
echo "To: $RCPT_TO"
echo ""
echo "$BODY"
echo "."
sleep 1
echo "QUIT"
) | telnet $SMTP_SERVER $SMTP_PORT

Receiving an Email using POP3 Commands

You can receive an email using telnet to connect to a POP3 server and manually issue the POP3 commands.
Below is a bash script that does this:

#!/bin/bash

POP3_SERVER="pop3.example.com"
POP3_PORT=110
USERNAME="[email protected]"
PASSWORD="your_password"

(
sleep 1
echo "USER $USERNAME"
sleep 1
echo "PASS $PASSWORD"
sleep 1
echo "LIST"
sleep 1
echo "RETR 1" # Retrieving the first email
sleep 1
echo "QUIT"
) | telnet $POP3_SERVER $POP3_PORT

Conclusion: Understanding and being able to use these commands can be useful for
troubleshooting and understanding email communication at a low-level protocol perspective.
Experiment No – 8

Experiment Title – Capturing &amp; amp; Analyzing operation of various application layer protocols
using network protocol analyzer. (Wireshark and tcpdump)

Aim: To capture and analyze the operation of various application layer protocols using network protocol
analyzers such as Wireshark and tcpdump.

Procedure:

1. Setup and Installation

 Wireshark:
1. Download and install Wireshark from Wireshark's official website.
2. Open Wireshark and select the network interface you wish to capture traffic on.
 tcpdump:
1. Install tcpdump using the package manager (e.g., sudo apt-get install tcpdump on Debian-
based systems or sudo yum install tcpdump on Red Hat-based systems).
2. Run tcpdump with appropriate options from the command line.

2. Capturing Traffic

 Wireshark:
1. Start Wireshark and select the interface to capture on.
2. Apply a capture filter if needed (e.g., tcp port 80 to capture HTTP traffic).
3. Click the "Start" button to begin capturing traffic.
 tcpdump:
1. Open a terminal.
2. Run a basic capture command, e.g., sudo tcpdump -i eth0 -w capture.pcap, to capture all
traffic on interface eth0 and write it to a file capture.pcap.
3. To capture specific traffic, use filters, e.g., sudo tcpdump -i eth0 tcp port 80 -w
http_capture.pcap.

3. Generating Traffic

 To analyze specific application layer protocols, generate traffic using the appropriate applications:
o HTTP: Open a web browser and visit various websites.
o HTTPS: Access secure websites.
o DNS: Perform DNS queries using tools like nslookup or dig.
o FTP: Use an FTP client to transfer files.
o SMTP/POP3/IMAP: Send and receive emails.
o SSH: Connect to a remote server using SSH.

4. Analyzing Traffic

 Wireshark:
1. Stop the capture once sufficient traffic has been recorded.
2. Use display filters to isolate traffic of interest (e.g., http, dns, ftp, etc.).
3. Examine individual packets to understand protocol operations:
 HTTP: Look at GET and POST requests and their corresponding responses.
 DNS: Examine DNS queries and responses.
 FTP: Analyze the commands and responses during file transfer.
 SMTP: Inspect the communication between email client and server.
4. Use Wireshark's built-in protocol dissectors and statistics features to summarize and
visualize the data.
 tcpdump:
1. Open the captured file in Wireshark for detailed analysis: wireshark capture.pcap.
2. Use tcpdump to filter and print specific packets directly: sudo tcpdump -r capture.pcap -nn
-A 'tcp port 80' to read and display HTTP packets.
5. Documenting Observations

 For each protocol, document the following:


o HTTP:
 Typical request/response pairs.
 Status codes and their meanings.
 Headers and payload analysis.
o HTTPS:
 Handshake process.
 Encrypted data segments.
o DNS:
 Query types (A, MX, NS, etc.).
 Response details.
o FTP:
 Command sequences (USER, PASS, RETR, STOR, etc.).
 Data transfer process.
o SMTP/POP3/IMAP:
 Command/response sequences.
 Authentication and data transfer.
o SSH:
 Handshake and key exchange.
 Encrypted communication.

6. Evaluation and Conclusion

 Summarize the captured data for each protocol.


 Highlight any notable patterns, anomalies, or security concerns.
 Discuss how network analyzers can be used for troubleshooting and optimizing network
performance.

Example Commands and Analysis


Wireshark:

 Start capture: Open Wireshark, select interface, click "Start".


 Apply filter: Type http in the display filter bar to show only HTTP packets.
 Analyze packets: Click on a packet to see details in the packet details pane.

tcpdump:

 Basic capture: sudo tcpdump -i eth0 -w capture.pcap


 Capture HTTP traffic: sudo tcpdump -i eth0 tcp port 80 -w http_capture.pcap
 Read capture file: sudo tcpdump -r capture.pcap
 Filter and display HTTP packets: sudo tcpdump -r capture.pcap -nn -A 'tcp port 80'

Conclusion: By following this procedure, you can effectively capture and analyze the operation of various
application layer protocols using network protocol analyzers like Wireshark and tcpdump. This will help in
understanding the behavior of these protocols and identifying potential issues in network communications.
Experiment No – 9

Title – Study of various streaming multimedia protocols in Internet.


Aim – Study streaming multimedia protocols in Internet

Theory – Streaming multimedia protocols are essential for delivering audio, video, and other
multimedia content over the Internet. Different protocols have been developed to cater to varying
requirements of quality, latency, and reliability. Below is a list of some widely used streaming
multimedia protocols:

1. Real-Time Streaming Protocol (RTSP)


o Purpose: Designed for controlling streaming media servers.
o Usage: Typically used in conjunction with the Real-Time Transport Protocol (RTP)
for delivering multimedia content.
o Characteristics:
 Allows for real-time control over the media stream, such as pause, play, and
record.
 Used in surveillance and IP cameras.
2. Real-Time Transport Protocol (RTP)
o Purpose: Delivers audio and video over IP networks.
o Usage: Often used in conjunction with RTSP or other control protocols.
o Characteristics:
 Provides end-to-end network transport functions suitable for applications
transmitting real-time data, such as audio, video, or simulation data.
 Includes timestamps and sequence numbers for proper synchronization and
delivery.
3. Hypertext Transfer Protocol (HTTP) Live Streaming (HLS)
o Purpose: Developed by Apple for streaming content over HTTP.
o Usage: Widely used for video streaming on the web and mobile devices.
o Characteristics:
 Breaks the overall stream into a sequence of small HTTP-based file
downloads.
 Supports adaptive bitrate streaming by providing multiple streams at
different bitrates.
4. Dynamic Adaptive Streaming over HTTP (DASH)
o Purpose: Standardized by MPEG, used for adaptive streaming.
o Usage: Supports a variety of devices and network conditions.
o Characteristics:
 Similar to HLS, it segments content into small chunks.
 Provides multiple representations of the same content for adaptive bitrate
streaming.
5. Secure Reliable Transport (SRT)
o Purpose: Developed to optimize streaming performance over unpredictable
networks.
o Usage: Used for low-latency video transport.
o Characteristics:
 Provides secure and reliable transport of video content.
 Includes features for packet loss recovery and encryption.
6. Smooth Streaming
o Purpose: Developed by Microsoft for adaptive streaming over HTTP.
o Usage: Used in Microsoft Silverlight applications and services.
o Characteristics:
 Similar to HLS and DASH, it adapts the quality of the stream in real-time
based on the user's network conditions.
7. Web Real-Time Communication (WebRTC)
o Purpose: Enables peer-to-peer communication through web browsers without the
need for plugins.
o Usage: Used in applications like video conferencing and live streaming.
o Characteristics:
 Provides low-latency communication.
 Supports audio, video, and data sharing between peers.

Protocol Latency Reliability Bandwidth Use Cases


Utilization
RTSP/RTP Low Medium Medium Surveillance, live
streaming
HLS Medium High High Web video
streaming, mobile
devices
DASH Medium High High Web video
streaming,
adaptive bitrate
SRT Low High Medium Low-latency video
transport
Smooth Streaming Medium High High Microsoft
Silverlight
applications
WebRTC Low Medium Medium Video
conferencing, real-
time
communication
Each protocol has its own strengths and is suited for different applications and network conditions.
By understanding these protocols, developers and network engineers can choose the most appropriate
technology for their specific needs.

Conclusion: Thus we have studied different multimedia protocols

You might also like