Network Application Design - Midterm Exam Solutions | ECE 4564, Exams of Electrical and Electronics Engineering

Fall 2005 Midterm Material Type: Exam; Class: Network Application Design; Subject: Electrical & Computer Engineer; University: Virginia Polytechnic Institute And State University; Term: Fall 2005;

Typology: Exams

Pre 2010

Uploaded on 11/08/2007

third-1
third-1 🇺🇸

14 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 4564 Midterm Exam Solutions Fall 2005 Page 1 of 7
Virginia Tech
ECE 4564: Network Application Design
Midterm Exam Solutions Fall 2005
1. From the perspective of TCP, what determines if a host is a server?
(a) A server provides responses to HTTP requests.
(b) A server creates a socket, makes it passive using the LISTEN operation, and then accepts
connections with the ACCEPT operation.
(c) A server accepts a SYN request and responds with an ACK and a SYN request to complete the
connection.
(d) TCP is strictly a peer-to-peer protocol and, therefore, there is no feature or operation that
distinguishes a client from a server.
Answer: (c). Answer (a) is true from the perspective of HTTP, but not from the perspective of TCP. Answer
(b) is true, but from the perspective of the sockets application program interface and not TCP. Answer (d) is
not true.
2. The following is a key difference between TCP and UDP.
(a) TCP provides a reliable datagram service, while UDP provides a best-effort datagram service.
(b) TCP provides a reliable stream service, while UDP provides a best-effort datagram service.
(c) TCP uses a header, so it is less efficient than UDP which is a “header-less” protocol.
(d) TCP uses port numbers to identify process- or application-level end-points, while UDP does not
use port numbers.
Answer: (b). Only answer (b) is true.
3. An HTTP user agent running on a host with Microsoft Windows as the operating system can
successfully access a server running on a host with Linux as the operating system. What makes this
possible?
(a) Both the user agent and the server use a common set of protocols, specifically IP, TCP, and
HTTP.
(b) Both the user agent and the server must use a common or similar sockets interface to the TCP/IP
protocol suite.
(c) Microsoft Windows and Linux use a common implementation for the TCP/IP protocol stack.
(d) The developers of the server software must write the server with special features to
accommodate Microsoft Windows.
Answer: (a). A common set of protocols is required, as indicated in answer (a). The client and server can use
different interfaces to TCP/IP and different implementations. Special features are not required to allow use of
HTTP with a Linux server and a Windows client.
4. What is an “ephemeral socket”?
(a) A socket created by a client and that is connected to the server.
(b) A socket created by a server and that is connected to the client.
(c) A socket created by a server and that is used to accept connections from a client.
(d) A socket temporarily created by a server to receive UDP datagrams.
Answer: (b). An ephemeral socket is created when the accept call returns and is connected to the client whose
connection was accepted.
pf3
pf4
pf5

Partial preview of the text

Download Network Application Design - Midterm Exam Solutions | ECE 4564 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

Virginia Tech

ECE 4564: Network Application Design

Midterm Exam Solutions ™ Fall 2005

  1. From the perspective of TCP, what determines if a host is a server?

(a) A server provides responses to HTTP requests. (b) A server creates a socket, makes it passive using the LISTEN operation, and then accepts connections with the ACCEPT operation. (c) A server accepts a SYN request and responds with an ACK and a SYN request to complete the connection. (d) TCP is strictly a peer-to-peer protocol and, therefore, there is no feature or operation that distinguishes a client from a server. Answer: (c). Answer (a) is true from the perspective of HTTP, but not from the perspective of TCP. Answer (b) is true, but from the perspective of the sockets application program interface and not TCP. Answer (d) is not true.

  1. The following is a key difference between TCP and UDP.

(a) TCP provides a reliable datagram service, while UDP provides a best-effort datagram service. (b) TCP provides a reliable stream service, while UDP provides a best-effort datagram service. (c) TCP uses a header, so it is less efficient than UDP which is a “header-less” protocol. (d) TCP uses port numbers to identify process- or application-level end-points, while UDP does not use port numbers. Answer: (b). Only answer (b) is true.

  1. An HTTP user agent running on a host with Microsoft Windows as the operating system can successfully access a server running on a host with Linux as the operating system. What makes this possible? (a) Both the user agent and the server use a common set of protocols, specifically IP, TCP, and HTTP. (b) Both the user agent and the server must use a common or similar sockets interface to the TCP/IP protocol suite. (c) Microsoft Windows and Linux use a common implementation for the TCP/IP protocol stack. (d) The developers of the server software must write the server with special features to accommodate Microsoft Windows. Answer: (a). A common set of protocols is required, as indicated in answer (a). The client and server can use different interfaces to TCP/IP and different implementations. Special features are not required to allow use of HTTP with a Linux server and a Windows client.
  2. What is an “ephemeral socket”?

(a) A socket created by a client and that is connected to the server. (b) A socket created by a server and that is connected to the client. (c) A socket created by a server and that is used to accept connections from a client. (d) A socket temporarily created by a server to receive UDP datagrams. Answer: (b). An ephemeral socket is created when the accept call returns and is connected to the client whose connection was accepted.

  1. Why does the client for the UDP TIME service need to send a message to the server, while the client for the TCP TIME service does not? (a) The UDP TIME service requires a simple authentication message be sent to the server, while this feature is provided by TCP when it establishes a connection. (b) Different people developed the TIME protocol for UDP than developed the TIME protocol for TCP. (c) TCP provides the server with the IP address and port number of the client when there is a connection request. UDP does not provide this information when it establishes a connection. (d) The server needs to know the IP address and port number of the client. With UDP, this is provided by the client sending a message to the server. With TCP, this is provided by the client connecting to the server. Answer: (d). Only answer (d) is correct. Note that UDP does not establish a connection, as specified in answer (c).
  2. Using the Sockets class with Microsoft’s .NET, how is a SYN message generated by a host?

(a) By executing the Socket.Connect method at the client. (b) By executing the Socket.Connect method at the server. (c) By executing the Socket.Synchronize method at the client. (d) By executing the Socket.Synchronize method at the server. Answer: (a). Calling the Socket.Connect method at the client causes TCP at the client to generate a SYN request to the server. TCP at the server will also generate a SYN request to the client, but this might be done by TCP at the server before Socket.Accept is called, as is the case with pending connections. So, answer (a) is better than answer (b). There is no such method as Socket.Synchronize.

  1. Which of the following is not true for SMTP?

(a) SMTP messages must consist of 7-bit ASCII characters. (b) SMTP uses TCP. (c) SMTP is a mail access protocol. (d) SMTP is a client-server protocol. Answer: (c). All are true except answer (c). SMTP is not a mail access protocol. IMAP and POP3 are commonly used mail access protocols.

  1. Is HTTP a stateless protocol?

(a) No. It supports “cookies” that provide state information. (b) No. It uses TCP which is a stateful protocol. (c) Yes. No state is maintained by HTTP between different HTTP requests. (d) Yes. It uses UDP which is a stateless protocol. Answer: (c). HTTP is stateless, although other schemes may be used with HTTP to maintain state. For example, using cookies is a way to maintain state, but state is maintained outside of TCP. HTTP uses TCP, not UDP.

  1. Under what conditions do HTTP persistent connections offer the greatest advantage?

(a) When both the client and server use only HTTP/1.1. (b) When the client-server round-trip time is low. (c) When objects are being transferred from client to server using PUT or POST. (d) When small objects are being transferred.

causes the receiver buffer at the server and the send buffer at the client to fill, thus leading to deadlock. (This scenario was discussed in lecture.)

  1. What happens at the TCP level when a TCP client executes the following for socket mySocket: mySocket.Shutdown(SocketShutdown.Send)? (a) TCP frees resources associated with the connection, but not with the socket descriptor mySocket. (b) TCP sends a TCP segment with the “FIN” bit set in the header to TCP at the server. (c) TCP at the client waits to receive a “FIN” from the server and then sends a “FIN” and an “ACK” to TCP at the server. (d) TCP does not send any segment initiated by this Shutdown call. Answer: (b). TCP at the client will send a “FIN” to TCP at the server. This does not free resources as in answer (a). TCP at the client can still receive data from the server and, when it receives a FIN from the server, it will send only an “ACK” back to the server. This is contradictory to answer (c). Answer (d) is also false.
  2. Which of the following is not an appropriate use of time-outs for socket operations at a server?

(a) To detect a client that is “hung” or otherwise unresponsive. (b) To help avoid deadlock due to an unresponsive client. (c) To wait for TCP to complete sending a stream of data from the client. (d) To reduce resources expended due to a denial-of-service attack. Answer: (c). Time-outs are not a way to deal with TCP’s Nagle algorithm, as suggested by answer (c). The other answers are all appropriate uses for time-outs at the server.

  1. Consider the following code snippet from the TCPCallbackEchoClient.cs example. mySocket.BeginSend(sendBuffer, 0, 1024, SocketFlags.None, new AsyncCallback(SendCallback), state); mySocket.BeginReceive(recvBuffer, 0, 1024, SocketFlags.None, new AsyncCallback(ReadCallback), state); Which of the following is true for “SendCallback” cited in the code above? (a) SendCallback must be declared to be private. (b) SendCallback is a method that will be called to actually send the buffer. (c) SendCallback is a method that will be invoked when the send is completed. (d) SendCallback will always be executed immediately. Answer: (b), (c), or (d). As presented in lecture, the correct answer is (c). However, further investigation indicated that callback routine may be executed before the operation completes and the EndSend method will block until the operation completes. It is, thus, possible that (b) or (c) is correct. Answer (d) is also allowed since the thread for the callback routine is, at least, eligible to execute immediately. Answer (a) is simply false as the method must be public, not private.
  2. Consider the code snippet in Question 16. Suppose sendBuffer and recvBuffer point to the same buffer space. Would this create a potential problem? (a) No. The buffer will be used first by BeginSend and then by BeginReceive, which is called after BeginSend. (b) No. Mutual exclusion for use of the buffer is provided by .NET. (c) Yes. BeginReceive may start loading the buffer with new data before it is completely sent following the BeginSend. (d) Yes. The .NET garbage collection may delete the buffer after one operation completes but before the other completes.

Answer: (c). There could be a conflict between the send and the receive operations as they are executed in different threads.

  1. Consider the code snippet in Question 16. What is the purpose of the argument “state”?

(a) Argument “state” is a Boolean that indicates whether or not subsequent calls are stateful. (b) Argument “state” is a Boolean that indicates if mutual exclusion is needed with other asynchronous calls. (c) Argument “state” provides information to the system about the requested receive or send operation. (d) Argument “state” provides information to the callback method. Answer: (d). The state object is passed into the callback method to provide application-specific information.

  1. Consider the following code snippet from the from the TCPSelectEchoServer.cs example. tempList.Clear(); for (int i = 0; i < socketList.Count; ++i) tempList.Add((Socket)socketList[i]); Socket.Select(tempList, null, null, -1);

What is the purpose of the “for” loop in the code? (a) To copy active sockets from socketList to tempList since it will be overwritten by the Socket.Select method. (b) To copy only the active sockets from socketList to tempList so tempList contains no inactive sockets. (c) To format tempList as required by the Socket.Select method since socketList is not in proper form. (d) To ensure all sockets in socketList are cast as type Socket in tempList. Answer: (a). Socket.Select will overwrite tempList with just sockets needing service (for read or accept, as indicated in Question 20), so the code needs to preserve the full list of sockets for the next call to Socket.Select. This is done by copying the list of sockets in socketList to tempList before the call to Socket.Select. Note that socketList should not have any “inactive” sockets, so answer (b) does not make sense.

  1. Consider the code snippet in Question 19. What will be in tempList after Socket.Select returns?

(a) A list of all sockets ready for service. (b) A list of all sockets ready to be read. (c) A list of all sockets ready to accept a connection. (d) A list of all sockets ready to be read or to accept a connection. Answer: (c). Socket.Select will leave in tempList just those sockets that are ready for service for a read or accept operation. Note that sockets that are ready to be written will not be in the list. So, answer (c) is the best answer.

  1. Consider the UDP BTP server of Project 1. We wish to add support for a new method described below.

PROTOCOL Method Request: PROTOCOL Action: Determine the protocol type (see below) and return to the client as an ASCII text message. Reply: ASCII text message of at most 128 characters that contains the protocol type.

treated as just data, as is done by the ECHO server examples. However, points were not counted off if this assumption were made and the implementation is correct with this assumption.

  1. Consider a HTTP server for a heavily used commercial site (like Yahoo! or Amazon.com). Point out specific advantages and disadvantages of using a design based on “predetermined concurrency.” Present your answer as a list of advantages and a list of disadvantages. Correct answers need to provide at least two distinct advantages and disadvantages. Advantages
    • The scheme provides concurrency so that the server can simultaneously process multiple client connections.
    • The scheme allows the level of concurrency to be controlled, so large bursts of demand (many simultaneous connection requests) will not severely degrade the performance of all server operations.
    • The scheme controls the level of concurrency so that the effect of a denial-of-service attack based on making many connections to the server will be limited.
    • Since threads are created in advance, there is no overhead to create a thread for the processing of each client connection.
    • The scheme is a good match to a multiprocessor system, so such a system can be used to improve server performance.
    • Allows overlapped execution of file input/output and network input/output operation.
    • Simpler than some other schemes, such as using adaptive or delayed concurrency. Disadvantages
    • There is extra overhead for thread switching.
    • The number of client connections is fixed, so during periods of high demand, some client connections may be refused.
    • The optimal number of threads (number of connections) must be properly determined, which requires administrative monitoring and configuration.
    • More complex than an iterative server. Note that the fact that the fact that a server with predetermined concurrency can quickly empty a buffer with connectionless communication is not relevant here since HTTP is a connection-oriented application protocol.