Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Assignment_2

The document outlines a lab assignment focused on socket programming, specifically creating a TCP echo client-server application in C. It includes instructions for implementing both the server and client programs, as well as a comparison between HTTP and HTTPS, steps to capture HTTP request packets, and DNS query analysis. Additionally, it provides specific questions and answers related to HTTP requests and DNS queries for a given URL.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Assignment_2

The document outlines a lab assignment focused on socket programming, specifically creating a TCP echo client-server application in C. It includes instructions for implementing both the server and client programs, as well as a comparison between HTTP and HTTPS, steps to capture HTTP request packets, and DNS query analysis. Additionally, it provides specific questions and answers related to HTTP requests and DNS queries for a given URL.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Lab Assignment - 4

SOCKET PROGRAMMING

Implement echo client-server message passing application. Messages sent from the client should

be displayed on the server and then the program should terminate.

1. Write a server (TCP) C Program that opens a listening socket and waits to serve clients.

2. Write a client (TCP) C Program that connects with the server program knowing IP

address and port number.

3. Get the input string from console on client and send it to server, server displays the same

String.

1) import socket

s = socket.socket()
print("socket created")

s.bind(('127.0.0.1', 8888))

s.listen(3)
print('waiting for conncetions')
c, addr = s.accept()
print("connedted with ", addr)
while True:

rec = c.recv(1024).decode()
print(rec)
message = input("message from server side to client side: ")
c.send(bytes(message, 'utf-8'))
if message == '0' or rec == '0':
c.close()
break
2) import socket

c = socket.socket() #

c.connect(('127.0.0.1', 8888))
name = '1'

while True:

name = input("send a message to server: ")


c.send(bytes(name, 'utf-8'))
rec = c.recv(1024).decode()
if (name == '0' or rec == '0'):
c.close()
break

print(rec)

3)
3)

HTTP

1. Give brief details about HTTP. What is the difference


between HTTP and HTTPS?

HTTP HTTPS
1) In HTTP, URL begins with http://. 1) In HTTPs, URL starts with https://.

2) HTTP uses port number 80 for 2) HTTPs uses 443 port number for
communication communication.

3)HTTP works at Application Layer. 3) HTTPS works at Transport Layer.

4) In HTTP, Encryption is absent. 4)Encryption is present in HTTPS

5) HTTP does not improve search 5) HTTPS helps to improve search


ranking ranking

6)HTTP faster than HTTPS 6) HTTPS slower than HTTP

7) In HTTP, Encryption is absent. 7) Encryption is present in HTTPS.

2. Write down the steps to capture HTTP request packets for the
following URL.

URL: http://gaia.cs.umass.edu/wireshark-labs/HTTP-wireshark-
file2.html

1)Open Wireshark

2)Click on capture
3)You'll want to capture traffic that goes through your ethernet driver.
click on the start button to capture traffic via this interface.

4) Visit the URL that you wanted to capture the traffic from.
5) Go back to your Wireshark screen and press capture button to stop
capturing.
6) After the traffic capture is stopped, please save the captured traffic
and analyze the packet.

3. Answer the following questions for the above


URL request.

a) Which version your browser and server are running on?

Ans. Internet Protocol Version 4, Src: 192.168.25.178, Dst: 128.119.245.12

b) What is the IP address of your host machine and server?

Ans. IP of host : 192.168.25.178

IP of server : 128.119.245.12

c) List out the languages accepted by your browsers.

Ans: en-US,en;q=0.9

d) What is the status code returned from the server to your browser?

Ans: Status Code: 200 / [Status Code Description: OK] / Response Phrase:
OK

e) What is the size of the content received from the server?


Ans: Frame Number: 285

Frame Length: 784 bytes (6272 bits)

f) Check the last modification date of the retrieved HTML file.

Ans. Last-Modified: Tue, 01 Nov 2022 05:59:01 GMT\r\n

g) Did you receive the content of the file as a response?

Ans. Yes. [HTTP response 1/2] / Content-Type: text/html; charset=UTF-


8\r\n

h) Did you receive the content of the file if you requested the same
HTML file?

Ans. Thus if you download this multiple times on your browser, a


complete copy <br>\n

That will only be sent once by the server due to the inclusion of the IN-
MODIFIED-SINCE<br>\n

field in your browser's HTTP GET request to the server.\n

----> Congratulations again! Now you've downloaded the file lab2-2.html.


<br>\n

DNS

Apply nslookup on the following URL and answer the following


questions related to the DNS.
URL: www.mit.edu

1. Are DNS queries sent and received using TCP or UDP?

Ans: Tcp

2. What is the destination port of the DNS query and source port of the
DNS response?

Ans: User Datagram Protocol, Src Port: 58659, Dst Port: 53

3. What is the IP address of the DNS query message? Verify the IP


address of the local DNS server using ipconfig.

Ans: 192.168.167.178

4. What is the “Type” of the DNS query sent?

Ans: Encapsulation type: Ethernet (1)

You might also like