Recovering upload termination behavior

You are reverse engineering an undocumented upload routine to describe its externally visible behavior. The Python implementation below returns a status and the number of send attempts. Each reply corresponds to one attempt. Every supplied list contains at least three replies, and slicing with replies[:3] selects only its first three entries.


Python
def upload(replies):
    sends = 0
    for reply in replies[:3]:
        sends += 1
        if reply == "ACK":
            return ("complete", sends)
        if reply == "FATAL":
            return ("stopped", sends)
    return ("pending", sends)


Complete the recovered behavior table. Enter each status exactly as returned by the code and each attempt count as an exact integer. Each row is a separate run starting with sends equal to zero.

RunReplies in arrival orderReturned statusSend attempts
AACK, RETRY, RETRY
BRETRY, ACK, FATAL
CRETRY, RETRY, FATAL, ACK
DRETRY, RETRY, RETRY, ACK

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Reverse Engineering Questions: