Experiment-5 NT-LAB Manual
Experiment-5 NT-LAB Manual
Experiment-5
Aim of the Experiment: Development of client-side and server-side socket programs for the
connection-less User Datagram Protocol (UDP) process-to-process communication using ‘c’language
using UNIX Socket Programming APIs. Execute the client/server programs and analyze the
message/Protocol Data unit (PDU) exchange between client-server using Wireshark Protocol Analyzer.
Objective: Students will get hands-on experience on UNIX Socket Application Programming
Interfaces (APIs) and analyze the traffic /protocols using Wireshark Protocol Analyzer for UDP
client/server communications.
Software Required: UNIX/Linux OS with GNU Compiler Collection (gcc) complier, Wireshark
Protocol Analyzer
Network Scenario: In a network, two computers/hosts need to communicate over a connection- less
framework over UDP. To enable this communication two socket programs has to be written in‘c’-
language. The server program is ‘udp_server.c’ and the client program is ‘udp_client.c’. After writing
the code, it has to be complied using UNIX gcc compiler. We have to considered two machines running
over Linux OS for implementation. The message communication between client and server output to
be visualized in Linux ‘Terminal’ window. Additionally, the protocol data units / packets exchanged
between client and server need to be analyzed using Wireshark protocol analyzer.
Fundamentals of Client / Server Communication using Socket Programming
int main()
{
int sockfd;
struct sockaddr_in my_addr; // my address information
struct sockaddr_in their_addr; // connector's address information
socklen_t addr_len;
int numbytes;
char buf[MAXBUFLEN];
int main()
{
int sockfd;
struct sockaddr_in their_addr; // connector's address information
//struct hostent *he;
int numbytes;
char arg[30];
printf("Enter a message\n");
gets(arg);
A. Terminal
Observe the messages transaction between client-server and vice-versa.
Conclusion: Students should write the final outcome of this experiment in their own language.
***