Computer Science 0478 · Question 1[11 marks]
A secure network router sanitizes incoming transmission packets, extracts message headers, and verifies packet integrity using modular subroutines.
(a)[2]
State two reasons why subroutines should receive data via parameters rather than directly accessing and modifying global variables.
(b)[3]
Write a Cambridge pseudocode function named ExtractHeaderTag that:
- Accepts a single string parameter Packet : STRING.
- Returns a string of type STRING.
- If the length of Packet is strictly less than 4 characters, returns "ERR".
- Otherwise, extracts the first 4 characters starting at position 1 and returns them converted to uppercase using library routines SUBSTRING and UCASE.
(c)[4]
Packet data integrity is verified by summing the ASCII values of all characters in a payload string and computing the modulo 256 remainder. Write a Cambridge pseudocode function named ComputeChecksum that:
- Accepts a parameter Payload : STRING and returns an INTEGER.
- Iterates through each character of Payload from index 1 to LENGTH(Payload).
- Uses library routine ASC(Char) to obtain the numeric ASCII code of each character and calculates the cumulative sum.
- Returns the final sum MOD 256.
(d)[2]
Explain two ways in which decomposing software into modular procedures and functions improves collaborative teamwork among multiple software engineers.