CS558_4b__Socket_Programming_VM-1
CS558_4b__Socket_Programming_VM-1
(January–May 2025)
Assignment - 4b
Task: Install a Virtual Machine (VM) using any virtualization software (e.g.,
VirtualBox, VMware, KVM). Re-run the assigned application (Application 1,
2, or 3) under the following networking scenarios:
1. VM to VM: Run both client and server on two separate VMs connected
via a virtual network.
2. VM to Personal (Host): Run the client on the VM and the server on
your host machine (or vice versa).
3. Personal to VM: Run the client on the host and the server on the VM
(or vice versa).
Instructions:
• Report any challenges faced during the setup (e.g., NAT vs Bridged Adapter issues).
1
In the second phase, the client transmits a short Data Message (Type 3 message) over
the earlier negotiated UDP port. The server will display the received Data Message and
send a Data Response (Type 4 message) to indicate the successful reception. After this
data transfer phase, both sides close their UDP sockets.
Message Format
The messages used to communicate contain the following fields:
A <Data Message> in Client will be a Type 3 message with some content in its
message section.
1. Implement a request queue where client requests are stored before processing.
3. The server should accept an additional command-line argument to select the schedul-
ing policy.
2
Performance measurement
(a) Measure the throughput of TCP and UDP for 1-KB, 2-KB, 3-KB, . . . , 32-KB
messages. Plot the measured throughput as a function of message size.
3
Performance Measurement
This simulation includes detailed performance analysis. Throughput and latency will be
measured for both TCP and UDP modes under varying video resolutions (480p, 720p,
and 1080p). For UDP, the simulation will introduce packet loss to study its impact on
video quality. Resource utilization in terms of CPU and memory consumption will also
be monitored and compared for both protocols. The following table outlines the key
metrics:
Metric Description
Throughput Amount of video data transmitted per second (Mbps)
Latency Time delay between request and first packet received (ms)
Packet Loss (UDP) Percentage of packets lost during transmission
CPU Usage Percentage of CPU consumed during streaming
Memory Usage Amount of RAM used during streaming
The collected results will be visualized using appropriate graphs, such as Throughput
vs. Resolution and Latency vs. Resolution, to highlight the differences in protocol
performance under various conditions.
• Client: <executable code> <Server IP> <Server Port> <Mode: TCP/UDP> <Resolution:
480p/720p/1080p>
Additional Notes
The implementation must include proper error handling and socket management. Packet
loss, network latency, and bandwidth limitations should be simulated programmatically
to reflect real-world networking conditions. Since this is a simulation, actual video files
are not required—instead, mock data should be used to represent the video stream for
simplicity and to reduce resource usage.
The server should be capable of supporting concurrent clients through multithreading,
and the client should be able to switch between TCP and UDP streaming modes easily.
Code should be well-documented with clear comments to support future modifications or
enhancements.
4
Application #3: TCP and UDP Communication using
Base64 Encoding in C
In this assignment, you are required to implement two C programs: a server and a
client. The server must be capable of handling multiple clients concurrently and should
support communication over both TCP and UDP sockets. The client will connect to the
server using either TCP or UDP, based on user input, and will transmit Base64-encoded
messages.
The primary objective is to create a simple communication protocol using Base64
encoding that supports both TCP (connection-oriented) and UDP (connectionless) com-
munication methods. Additionally, the server must support concurrent communication
with multiple clients using multithreading.
Functionality
1. Server
The server program should start by listening for incoming connections on a specified port,
which should be passed via command-line arguments. It must support both TCP and
UDP connections.
When a client connects via TCP, the server should create a new thread dedicated
to handling that client. This ensures that multiple TCP clients can be served concur-
rently. On the other hand, since UDP is connectionless, the server handles incoming UDP
messages in the main thread.
Upon receiving a message (from either TCP or UDP), the server decodes the Base64-
encoded content and prints the original message. It then sends an acknowledgment (ACK)
message back to the client. The server should remain active, able to serve multiple clients
simultaneously. When a termination message (Type 3) is received from a client, the server
should gracefully close that connection.
2. Client
The client connects to the server using either TCP or UDP, as specified by the user.
It accepts text input from the user, encodes it using Base64 encoding, and sends the
encoded message to the server.
After sending the message, the client waits for an acknowledgment (ACK) from the
server. The client can continue sending messages until it chooses to terminate the ses-
sion by sending a Type 3 (termination) message. The client should also handle session
termination gracefully.
Message Format
Each message exchanged between the client and server consists of the following fields:
5
Field Description
Message Type Integer indicating the type of message (1, 2, or 3)
Message Content Character array of fixed size (e.g., MSG LEN)
Message Types
There are three distinct types of messages that can be sent between client and server: