Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
 1 
CS 451: Distributed Systems 
Spring 2007 
Assignment #1 
Due Thursday, Feb 15, 12:30 pm 
 
Part 1(worth 25%). Short Answer (Answer all 6 questions) 
Show all work to receive partial credit. Note: You must do these questions by yourself (NOT with 
your partner of Part 2). You are required to use a word processing program to write your answers to 
homework assignments in this class (submissions should be in PDF). Whenever something is unclear in 
the question, form assumptions, and make those assumptions explicit in your answers. In all answers, be 
as specific as possible. Limit your answer to each question or each part of a question to a maximum of 
approximately 1/4 page. 
 
1. Exercise 1.1 from the book: Give five types of hardware resource and five types of data or software 
resource that can usefully be shared. Give examples of their sharing as it occurs in distributed systems. 
 
2. Exercise 1.4: What are the advantages and disadvantages of HTML, URLs and HTTP as core 
technologies for information browsing? Are any of these technologies suitable as a basis for client-
server computing in general? 
 
3. Exercise 1.7: A server program written in one language (for example C++) provides the 
implementation of a BLOB object that is intended to be accessed by clients that may be written in a 
different language (for example Java). The client and server computers may have different hardware, 
but all of them are attached to an internet. Describe the problems due to each of the five aspects of 
heterogeneity that need to be solved to make it possible for a client object to invoke a method on the 
server object. 
 
4. Exercise 2.6: List the types of local resource that are vulnerable to an attack by an untrusted program 
that is downloaded from a remote site and run in a local computer. 
 
5. Exercise 2.10: Give some examples of faults in hardware and software that can/cannot be tolerated by 
the use of redundancy in a distributed system. To what extent does the use of redundancy in the 
appropriate cases make a system fault-tolerant? 
 
6. Exercise 2.14: Consider two communication services for use in asynchronous distributed systems. In 
service A, messages may be lost, duplicated or delayed and checksums apply only to headers. In 
service B, messages may be lost. delayed or delivered too fast for the recipient to handle them, but 
those that are delivered arrive order and with the correct contents. Describe the classes of failure 
exhibited by each service. Classify their failures according to their effect on the properties of validity 
and integrity. Can service B be described as a reliable communication service? 
Part 2 (worth 75%). Programming Assignment  (IM via sockets) 
You are encouraged to do this assignment with one other person from our class. You can do this 
assignment by yourself if you wish.  
The purpose of this assignment is to gain experience using TCP and sockets using C/C++ on Linux (you 
must use C/C++ ; you may also use Cygwin – http://www.cygwin.com).  You are to create a client for 
 2 
our version of the “Instant Messaging” (IM) that is so prevalent in today’s Internet use. It is assumed in 
this assignment that everyone is familiar with the basic mechanisms of IM – if not, please see 
http://en.wikipedia.org/wiki/Instant_messaging  
Note that our version will be a little primitive, because we are interested in gaining experience with low-
level programming (sockets) and we’re not really interested (at this point in the class) in the graphical 
aspects. Also, because “operating systems” is a co-requisite, this assignment is going to assume that you 
may not have learned multi-threaded programming (yet).  
You are to create three programs: 
 IM_Register:  This program should be invoked only once, to register yourself with a central 
server (which we will run for you). This central server will keep track of your network location 
and the time at which you last “logged in”. There are four command-line arguments: directory-
server-hostname   directory-server-port   username  password. 
 IM_Listen: Run this program to authenticate (“login”) to the central server and then sit there 
waiting for others wanting to talk with you. There are five arguments: directory-server-hostname  
directory-server-port  username  password  portnumber (the portnumber you are listening on).  
 IM_Chat: First, this program authenticates to the central server, then this program requests a list 
of active clients (those who have “listen”-ed recently).  This program should then prompt the user 
for whom to attempt to connect to. If a connection can be made, then this program should 
facilitate a dialogue with the other party. Once this dialogue is complete, this program should 
terminate. There are four command-line arguments: directory-server-hostname   directory-server-
port   username  password. 
Upon completion, your normal operation should be to run “IM_Listen” in one window, and “IM_Chat” in 
another window. You can test your code by asking specific other teams or by finding a “random” team 
who happens to be on the same time. 
Create your programs based on the messages identified below: 
2.1 Messages to/from the IM Directory Server 
 
Message from client Example Message(s) received from IM Directory 
Server 
Register name passwd Register MHumphrey 
123go 
OK 
Already Registered 
Unknown Error 
Unregister name passwd Unregister MHumphrey 
123go 
OK 
Not Registered 
Bad Password 
Unknown Error 
List Registered  Num (newline, then “Num” newline-
separated strings) 
Unknown Error 
Login name passwd 
hostname port 
Login MHumphrey 123go 
barney.cs.virginia.edu 
50056 
OK 
Already LoggedIn 
Not Registered 
 3 
Bad Password 
Unknown Error 
Logout name passwd  Logout MHumphrey 
123go 
OK 
Not Registered 
Not LoggedIn 
Bad Password 
Unknown Error 
KeepAlive name passwd KeepAlive MHumphrey 
123go  
OK 
Not Registered 
Not LoggedIn 
Bad Password 
Unknown Error 
List Active  Num (newline, then “Num” newline-
separated strings) 
Unknown Error 
List name List MHumphrey hostname port 
Not Registered 
Not LoggedIn 
Unknown Error 
 
Notes:  
 If a client has not sent a “keep alive” message in the last five minutes, the server may assume the 
client is no longer active, and that client may be logged out. 
2.2 Messages between IM clients 
Note: in the following, assume that MHumphrey is trying to initiate a conversation with BRubble. 
Mhumphrey is in the role of “Initiator Peer” and BRubble is in the role of “Acceptor Peer”. 
 
Message from Initiator Peer Example Message(s) from Acceptor Peer 
Hello name Hello MHumphrey OK 
Too Busy 
Incorrect Network Address 
Unknown Error 
Goodbye  OK 
Not Connected 
Unknown Error 
msg Are you liking this 
assignment? 
OK 
Unknown Error 
 
Notes:  
 As in normal human conversation (and existing IM clients), both clients in a dialogue can be 
“talking” at the same time.  
Questions to address in your submission 
 
1. Protocol design: Is the set of messages complete in your opinion? That is, should there be more 
message types (what are they?) Does one or more of the messages seem superfluous? Are there 
 4 
some messages that could benefit from more, less, or different responses? (Keep in mind issues of 
complexity, interoperability, debuggability, etc.) 
 
2. Security of the protocol: Do you believe that adequate security has been applied to the messages 
to create a sufficiently secure system? (e.g., can you identify messages that seem to be insecure? 
Can you identify messages that seem to have unnecessary security measures applied to them?) 
 
3. What are the pros/cons of your implementation? Would someone actually like to use your system 
on a daily basis (as compared to Yahoo messenger, for example)? What are some limitations to 
your implementation? 
 
4. What testing did you do? That is, what did you do to convince yourself that your implementation 
was correct and/or the performance was sufficient? 
 
Grading Policy for this Programming Assignment 
 
Each program must be properly and reasonably designed, documented, implemented, and tested/evaluated.  
The grading for this part of the assignment will be: 
 
1. 50%: The quality of the code itself. This includes: the readability of the code, the correctness of 
the code, the efficiency of the code, etc. (Do not have debugging statements execute in the final 
version of your program). 
2. 50%: The answers to the questions above. 
What to hand in AND email 
 
You must both hand-in a paper copy of your answers to both parts of this assignment AND email an 
electronic copy (PDF) of both parts of this assignment to humphrey@cs.virginia.edu by 12:30pm on 
Thursday Feb 15. Each student should submit his/her solutions to Part 1 separately, and each team should 
submit only one solution to Part 2 (make sure that all submissions to Part 1 and Part 2 clearly contain the 
names of your team’s members).