Professional Documents
Culture Documents
Computer Networks Exam, 1 Term
Computer Networks Exam, 1 Term
Name:
Rules: Short answers are appreciated. Each question scores 2%. Duration 2
hours.
6. In the client-server model, can a server serve more than one client at a
time?
Yes, they are called concurrent servers.
8. What is the electrical cable that provides the most bandwidth? What is it
used for?
Coaxial cable. Among other uses you can find it on your TV set antenna.
10.What those connecting to port 1050 will obtain after we run the following
command:
sock l :1050 d cat
It is a line-oriented echo server. Each typed line will be echoed back to you.
12.Write the Java code for creating a UDP datagram variable (dp) that contains
the string "I'm UDP".
int[] buffer = new buffer[1024];
String msg = "I'm UDP"; buffer = msg.getBytes();
Datagram Packet dp = DatagramPacket(buffer,buffer.count);
14.Can you stop a running thread from running during 1 second? How?
Yes, it is Thread.sleep(1000);
18.Which HTTP method is mostly used for uploading contents to the web
server?
POST method
20.A web browser downloads a web page that contains four images. How
many round-trip times are needed if pipelining is used? (Let's assume
transmission time is negligible).
3 RTTs
22. LIST command responses (in POP3 protocol) are several lines long. How
does the client know an answer from the server is over?
Last line of the response consists of a single dot "."
23.How can we store the contents of the string s in the byte array dat? (Let's
assume dat is large enough).
dat = s.getBytes();
28.What type of service does TCP protocol provide? List three of its features.
TCP service is connection-oriented.
In-order delivery, flow control, congestion control.
30.What does happen to a TCP connection if a segment with the flag RST set is
received?
The connection is aborted. Data might be lost.
31.Is it possible for three consecutive TCP segments to be transmitted with the
same sequence number? Why?
Yes, it happens every time no new data is transmitted. These segments might
be sent for acknowledgment purposes only.
33.Does TCP use the same timeout value for each connection? Why?
No, each connection uses a varying timeout period. It is different even for
different moments of the same connection to adapt to network conditions.
39.Write Java code to extract the URL and print it to the screen, continue code
below:
ServerSocket ss = ServerSocket(80);
// it's a web server, so it's http protocol ...
Socket s = ss.accept(); // wait for client ...
Scanner sc = new Scanner(s.getInputStream());
sc.next(); System.out.println(sc.next());
40.What will happen when you print text using pw, ( PrintWriter pw = new
PrintWriter(s.getOutputStream());)? When lines will actually be
transmitted?
Data might be stored in the send buffer. Lines will be transmitted when flush()
or close() methods are called.
42.How can you know (in Java) the size of the file Mystery.txt ?
File f = new File("Mystery.txt"); System.out.println(f.length());
43.When reading from an InputStream, how do you know the end of the
stream has been reached?
When read call returns -1
44.Match the terms "linear increase" and "multiplicative decrease" with events
on TCP congestion control.
linear increase occurs while congestion avoidance while multiplicative
decrease happens after receiving three duplicated ACKs.
48.Do you remember the expression of the estimated RTT used by TCP?
EstimatedRTT = (1-α)*EstimatedRTT + α*SampleRTT /* α = 0.125 */