CS356 Computer Networks (Spring 2007)
TA Office Hours
Mon: 10:30 am to 11:30 am
Thu: 2:00 pm to 3:00 pm (right after class)
ESB Room 229, Desk#3
Exam and Homework Feedback
Homework 1 Feedback
Correct solution
Things to watch out for
- Variable of type range (e.g. var i : 0..3) are not
the same as integers. Trying to set set a variable i := n when i only
takes values from 0..n-1 is an error.
- If your variable declaration is dependent on another
value, e.g. 0..n-1 is dependent on n, then make the value of n is known
(it may be declared aconst or an input)
- Variables and arrays should be accompanied by initial
values (within comments) unless the protocol does not care about the
initial value or you explicitly overwrite the initial value in the
process specification.
- For questions asking you to fill in a line in a given
process specification, as in Question 2, do not use any new arrays or
variables that have not been declared in the process specification.
- Try not to use parameters execessively where a
variables would have sufficed. In many cases, such as in Question 3,
the guard "rcv rqst(x) from ...." x can simply be a variable that
captures the value of the message field. However be careful when writing "rcv rqst(x) from p[y]" where y is a variable, because p[y] will correspond to only one specific process, depending on the current value of the variable y. In such a case, y is usually declared as a parameter.
Grading Guideliens
Question 1:
- Appropriate declaration and initial values (the array would be
0..3 instead of boolean, and initial value would be all 0s or all 3s
depending on your specification).
- Updating avail[r] involves incrementing/decrementing instead of toggling the boolean value, similarly for guards and conditions.
- There are at least two variants of the correct specification, one
non-deterministically assigns the resource to the next requester, the
other is "fairer" and cycles through pending requests in sequence when
a resource becomes available. The fairer specification received more
credit in this homework.
- Common errors: instead of 3 users per resource, implementing one
user per resource and a total of 3 distinct resources in use at any
given time.
Question 2:
- Send all messages before allowing receipt of any reply (ready must remain false till all messages are sent)
- The variable i should contain an appropriate value when ready turns to false (i.e. 0 or n, depending on your implementation).
- Handle replies and timeouts appropriately by modifying the value of i.
- Common errors: sending and receiving from one q[i] at a time or sending only to a single q[i] at all times.
Question 3:
- Process p[i] waits after sending a request. Process r switches to the appropriate process q[j], and process q simply replies.
- This question demonstrates the use of variables vs. parameters for incoming messages. See the last bullet under "Things to watch out for" above.
- Common errors: constants not declared, not including "j:=any"
in process p and making r wait before it receives a reply from q (r did
not need to "wait" after sending a message, it just acts as a switch).
Midterm 1 Feedback
Correct solution.
Grading Guidelines
Question 1:
Appropriate use of the given input n.
Keeping track of sends and receives in one or more integer
variables. Accompanying boolean variables like ready or waiting are
redundant, but acceptable.
Correctly referring to the "other" process, i.e. i+1 mod 2 or 1-i.
Specifying correct types and initial values for any additional
variables.
Properly formed AP syntax.
Question 2:
Send alternating bits, starting with zero.
No activity unless timeout or ack received.
New transmission on ack receipt vs. RE-transmission on timeout
Common Errors
Question 1:
Not using n or i, and hard-coding 5, 7 or p[0] and p[1].
When using i, unnecessarily replicating instructions and using i=0
and i=1 in the guard.
Attempting to access n.p[1-i] or assuming variables to be global.
Using #ch.p[i].p[1-i] instead of maintaining variables to keep track
of
the number of messages.
Question 2:
Not using a "ready" or "waiting" boolean variable and relying only on timeout for
transmisson.
In process q, using parameter instead of variable (technically this is not an "error" so
it was not penalized).