computer networks lab

Topics: Internet socket, Domain Name System, Transmission Control Protocol Pages: 10 (1374 words) Published: October 10, 2013
CS2307-COMPUTER NETWORKS LAB MANUAL

PROGRAM USING TCP SOCKETS
EX NO: 1.i DATE AND TIME SERVER
AIM:
TO implement date and time display from local host to server using TCP ALGORITHM: CLIENT
1.start the program
2. To create a socket in client to server.
3. the client connection accept to the server and replay to read the system date and time. 5. Stop the program.
ALGORITHM: SERVER
1.start the program
2. To create a socket in server to client.
3. To display the current date and time to client
5. Stop the program.

EX NO:1.ii CLIENT-SERVER APPLICATION FOR CHAT
AIM:
To write a client-server application for chat using TCP
ALGORITHM: CLIENT
1.start the program
2. To create a socket in client to server.
3. The client establishes a connection to the server.
4. The client accept the connection and to send the data from client to server and vice versa
5. The client communicate the server to send the end of the message 6. Stop the program.
ALGORITHM: SERVER
1.start the program
2. To create a socket in server to client
3. The server establishes a connection to the client.
4. The server accept the connection and to send the data from server to client and vice ersa
5. The server communicate the client to send the end of the message 6.Stop the program.

EX NO:1.iii IMPLEMENTATION OF TCP/IP ECHO
AIM:
To implementation of echo client server using TCP/IP
ALGORITHM:
1.start the program
2 To create a socket in client to server.
3. 3he client establishes a connection to the server.
4. The client accept the connection and send data to server and the server to replay the echo message to the client
5. The client communicate the server to send the end of the message 6. Stop the program.

Ex No:2 PROGRAM USING SIMPLE UDP
EX NO:2.i DOMAIN NAME SYSTEM
AIM:
To write a C program to develop a DNS client server to resolve the given hostname.
ALGORITHM:
1. Create a new file. Enter the domain name and address in that file. 2. To establish the connection between client and server.
3. Compile and execute the program.
4. Enter the domain name as input.
5. The IP address corresponding to the domain name is display on the screen 6. Enter the IP address on the screen.
7. The domain name corresponding to the IP address is display on the screen. 8. Stop the program.
Program :
#include
#include
#include
#include
#include
#include
#include
int main(int argc,char *argv[1])
{
struct hostent *hen;
if(argc!=2)
{
fprintf(stderr,"Enter the hostname \n");
exit(1);
}
hen=gethostbyname(argv[1]);
if(hen==NULL)
{
fprintf(stderr,"Host not found \n");
}
printf("Hostname is %s \n",hen->h_name);
printf("IP address is %s \n",inet_ntoa(*((struct in_addr *)hen->h_addr))); }
RESULT:
Thus the above program udp performance using domain name server was executed and successfully

EX NO 3 :
PROGRAMS USING RAW SOCKETS (LIKE PACKET CAPTURING AND
FILTERING)
AIM :
To implement programs using raw sockets (like packet capturing and filtering) ALGORITHM :
1. Start the program and to include the necessary header files 2. To define the packet length
3. To declare the IP header structure using TCPheader
4. Using simple checksum process to check the process
5. Using TCP \IP communication protocol to execute the program 6. And using TCP\IP communication to enter the Source IP and port number and Target IP address and port number.
7. The Raw socket () is created and accept the Socket ( ) and Send to ( ), ACK 8. Stop the program
//---cat rawtcp.c---
// Run as root or SUID 0, just datagram no data/payload
#include
#include
#include
#include
#include
// Packet length
#define PCKT_LEN 8192
// May create separate header file (.h) for all
// headers' structures
// IP header's structure
struct ipheader {
unsigned char iph_ihl:5, /* Little-endian */
iph_ver:4;
unsigned char iph_tos;
unsigned short int iph_len;
unsigned short int iph_ident;
unsigned char iph_flags;
unsigned short int...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Essay about Introduction to Network Concepts
  • A Network Protocol Essay
  • Computer Lab Rules & Regulations Essay
  • Essay about Network Pro Exam Objectives
  • Computer Lab Managemetn System Essay
  • Essay about Online Computer Labs Monitoring System
  • Campus Computer Labs-the Issue at Hand Research Paper
  • Computer Networks Essay

Become a StudyMode Member

Sign Up - It's Free