You are on page 1of 8

Assignment # 1

Computer Networks Lab

Roll No. 22I-1659


Program: Cyber security
Section: C

Submitted to: Maam Sunduss Aamir


Submitted by: Muneeb Kashif

Fast, National University Of Computer


and Emerging Science
Task 1:
For this task we first start by writing code for a client and server that will exchange a message in
C. The client will send a message and the server will receive and display it.
Client Code:
Server Code:

Task 2:
For this task we need to modify the code so that the client and server when placed on two
different computers will connect to each other and perform the exchange of messages. This
requires us to make a change to the client code file which is as follows. The server does not
require any changes as it will only receive the connection request from the client.
The above code shows that the function inet_pton is being used in the code and the IP address
of the server is added so that the client can make a connection to the server which is on
another computer system.
Task 3 – 5:
In this task we open Wireshark and execute the code for task 2 and capture the packets that are
exchanged between the client and server. We will use these to answer the questions in the
following tasks.
Task 6:

The source IP address (client) is 172.16.50.199 as can be seen from the above screenshot.
Task 7:
The destination IP address (server) is 172.16.63.242 as can be seen from the screenshot in task
6.
Task 8:

The message captured in Wireshark sent by the client is “Hello form client” as can be seen
from above screenshot.
Task 9:

The source port number is 42208 as can be seen from above screenshot.
Task 10:
The destination port number is 8080 as can be seen from above screenshot in task 9.
Task 11:
In this task we have to modify the code so that the message sent by client is not easily
understandable. This can be done through encryption.

The above screenshot shows the function that is added to the client server that encrypts the
message by adding 10 to its ASCII value. This will encrypt the message so that when the
message is captured by Wireshark it is not understandable.

The above code is added to the server so that the message received is decrypted by subtracting
10 from its ASCII value and then displaying it.
Task 12:
The above screenshot shows the message captured by Wireshark that is encrypted after making
changes to the code in task 11.

You might also like