Computer Science (AS & A Level) · Oct / Nov 2023 · Paper 23 · Question 8
9618
As printed in the paper
The question as text
A class of students are developing a program to send data between computers. Many computers are connected together to form a wired network. Serial ports are used to connect one computer to another. Each computer: • is assigned a unique three-digit ID • has three ports, each identified by an integer value • is connected to between one and three other computers. Messages are sent between computers as a string of characters organised into fields as shown: <STX><DestinationID><SourceID><Data><ETX> Field name Description STX a single character marking the start of the message (ASCII value 02) DestinationID three numeric characters identifying the destination computer SourceID three numeric characters identifying the source computer Data a variable length string containing the data being sent (Minimum length is 1 character) ETX a single character marking the end of the message (ASCII value 03) For example, the following message contains the data "Hello Jack" being sent from computer "202" to computer "454": <STX>"454202Hello Jack"<ETX> Each computer will run a copy of the same program. Each program will contain a global variable MyID of type string which contains the unique ID of the computer in which the program is running. The first two program modules are defined as follows: Module Description GetData() (already written) • returns the data field from a message that has been received • If no message is available, the module waits until one has been received. ReceiveFile() • takes a file name as a parameter of type string • creates a text file with the given file name (no checking required) • writes the data field returned by GetData() to the file • repeats until the data field is "****", which is not written to the file • outputs a final message giving the total number of characters written to the file, for example: 132456 characters were written to newfile.txt
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
8(a)[7]
8(b)[3]
8(c)[7]
8(d)[3]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

