SYSC 5800: Network
Computing
Sample
Solution to Sample Final Exam
Question 1. Computer Networks (10
marks)
Most protocol implementations are based on a layered architecture. Explain the reason behind this design and describe an example protocol stack that is based on this layered architecture.
Answer (10 marks):
Providing network services requires solutions to many problems: routing, addressing, flow control, congestion control, error control, security, etc. Rather than solving all issues in a single, hard to maintain piece of software, layered protocol architectures divide the problem into sets of smaller subproblems. A protocol at layer N will make use of the services provided by the layer below to do its job, providing services in turn to the layer above it. At the top layer, the application implements the actual application logic.
One commonly referenced protocol stack is the 7 layer OSI reference model:
Another example is the TPC/IP protocol stack, which has fewer layers (in essence it does not have a separate session or presentation layer, and merges the Physical and Data Link layers):
Question 2. RPC (10 marks)
What is the basic idea behind RPC? What are some of the challenges in implementing RPCs?
Answer (10 marks):
Basic Idea:
l
Remote Procedure Calls allow a
program to make use of procedures executing on a remote machine, exporting a
programming abstraction (procedure call) that programmers are familiar with
l
RPCs are
based on sockets, and therefore dispense us from using them directly
l Remote Procedures could in principle be written in a different language than the clients
Challenges:
l
Registration and identification of
a procedure
–
The procedure registers its name to the
RPC server
–
The client invokes the procedure by
specifying the machine name, the procedure name, and by passing the parameters
l
Encoding and decoding of procedure
parameters
–
Given the difference in address space,
and possibly in internal type encoding schemes and programming language, there
is a need to use an external/agreed upon data representation
– The client and the server will have to translate procedure parameters (encoding) and the return value (decoding) to and from that representation
l
Dealing with errors
–
Client and server can fail independently
(not the case with “regular” procedure calls). How often should remote
procedure be invoked?
l
Ideally: exactly once (hard to
guarantee)
l
At-most once
l
At-least once (idempotent
operations)
l
Ordering relationships
–
Does order of two RPCs
to same server matter?
–
If so, what should be that order (partial
order semantics, total order semantics):
Question 3. Coordination Languages (10
marks)
JMS (Java Message Service) provides persistent subscriptions in a publish-subscribe system: once a client makes a persistent subscription, the message broker will deliver events/messages to clients if they are connected. When a client is not connected, the message broker will buffer events until the client reconnects. Discuss how JMS is similar to and also differs from:
1. TIB/Rendezvous
2. Tuplespaces
Answer (10 marks):
JMS is similar to TIB/Rendezvous in that it offers a publish-subscribe type coordination model, in which the producer (publisher) of information and the consumer (subscriber) do not need to know each other (referentially decoupled). However, unlike TIB/Rendezvous, persistent subscriptions also allow for temporal decoupling. In addition, unlike TIB/Rendezvous, direct communication is NOT supported (minor point).
JMS is similar to Tuplespaces in that it allows for both referential and temporal decoupling in the communication between sender and receiver. However, unlike Tuplespaces, the temporal decoupling is just one option (subscriptions can also be non-persistent). In addition, the communication model is different: rather than using Tuplespace operations, the communication primitives are based on publish/subscribe operations.
Question
4. WWW Programming (10
marks)
Imagine we have a website with a form that allows a user to fill in a single textfield with name “input”. Once the user clicks on submit, the client uses the GET method to retrieve the following HTML webpage:
<html>
<head><title>Sample
Output</title></head>
<body>
You typed in: <i>blabla</i>
</body>
</html>
where “blabla” is the text entered by the user. Provide implementations of the server side using
1. CGI
2. Java Servlets
3. JSP
Note: for the Java Servlets solution, only provide the implementation of
public doPost(HttpServletRequest req, HttpServletResponse
response)
{ …
}
Answer (10 marks):
Using CGI (with the script being written in Perl):
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print
“<html><head><title>Sample Output</title></head>”;
print “<body>”;
($varname, $mydata) = split(/=/,$ENV{'QUERY_STRING'});
print "You typed
in: <i>$mydata</i>\n";
print
"</body>”;
print “</html>";
Using a Servlet:
public doPost(HttpServletRequest req, HttpServletResponse
response)
{ PrintWriter
out = response.getWriter();
out.println("<html><head><title>Sample
Output</title></head");
out.println("<body>");
String input = req.getParameter("input");
out.println("You typed in: <i>"
+ input + “</i>”);
out.println("</body>”);
out.println(“</html>");
}
Using JSP:
<html>
<head><title>Sample
Output</title></head>
<body>
<%
String input = request.getParameter(“input”); %>
You
typed in: <i><%= input %></i>
</body>
</html>
Question
5. Grid Computing
(10 marks)
Describe the generic Layered Grid Architecture as presented in class. Discuss how this layered architecture is similar to and different from a layered protocol architecture.
Answer (10 marks):