Hamza
Hamza
Hamza
Assignment 2:
Computer network
Question no 1:
Describe the working of HTTP cookies. Describe its advantages and disadvantages. (CLO- 2,
SO-2) (Marks 10).
2
3
Question no 2:
Answer the following question regarding the working of DNS. (CLO-2, SO-2) (Marks 20).
a. Suppose a user has webserver running at a system with domain name
www.cuiwah.edu.pk with IP address 203.124.43.197. Its authoritative DNS is
ns1.comsats.net.pk with IP address 210.56.11.130. How will the record of
domain name www.cuiwah.edu.pk and its IP address 203.124.43.197 will be
inserted in the DNS hierarchy.
4
b. After inserting the domain name and its IP address in Q3(a), suppose a user
wants to find the IP address of www.cuiwah.edu.pk . The user is connected
to local DNS server 192.168.1.1. Describe in the step-by-step how the user’s
DNS query for www.cuiwah.edu.pk will be resolved.
c. If there is no DNS, can we access the web and email servers? Explain the
reason for your answer.
d. Describe the main advantage and disadvantage of DNS.
Question no 3:
5
Consider an e-commerce site that wants to keep a purchase record for each of its customers.
Describe how this can be done with cookies. (CLO-2, SO-2) (Marks 10).
6
Question no 4:
Look over your received e-mails and examine the header of a message sent from a user with
a .edu e-mail address. Is it possible to determine from the header the IP address of the host
from which the message was sent? Do the same for a message sent from a Gmail account.
(CLO-2, SO-2) (Marks 10).
7
Question no 5:
Write a Python program that applies socket programming to establish a TCP connection
between a client and a server for file transfer. (CLO-2, SO-2) (Marks 10).
Server-code:
package com.mycompany.server2;
import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
public class Server2 {
while (true) {
// Wait for client connection
Socket s = ss.accept();
System.out.println("Connection Established with client.");
Client code:
package com.mycompany.client2;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;
9
if (msg != null) {
System.out.println("Message received from server: " + msg);
} else {
System.out.println("No message received.");
}
Question no 6:
Suppose Alice, with a Web-based e-mail account (such as Hotmail or Gmail), sends a
message to Bob, who accesses his mail from his mail server using POP3. Discuss how the
message gets from Alice’s host to Bob’s host. Be sure to list the series of application-layer
protocols that are used to move the message between the two hosts. (CLO-2, SO-2) (Marks
10).
11