Networks and the web · A level · OCR H446 1.3.3, AQA 7517 4.9.1.1, Eduqas A500QS 2.2 · about 25 min
Serial and parallel, synchronous and asynchronous, baud rate, bit rate, bandwidth, latency and protocols.
[1 mark]Why is serial transmission preferred to parallel over long distances?
[1 mark]In asynchronous serial transmission, what is the purpose of the start bit?
[1 mark]A link uses 16 different signal levels and a baud rate of 2400. What is its bit rate in bits per second?
[1 mark]What does this program print?
baud = 4800 bits_per_frame = 1 + 8 + 1 print(baud // bits_per_frame, 'characters per second')
480 characters per second
Each character takes a start bit, 8 data bits and a stop bit, 10 bits in all, so 4800 bits per second carries 480 characters.
[1 mark]Which statement about bandwidth and bit rate is correct?
The LED can be a one-wire serial line: white for 1, off for 0.
Write frame(ch). Its input ch is a single character with a code from 0 to 255. It returns a string of exactly 10 characters, each 0 or 1: a start bit 0, the 8 data bits of the character's code least significant bit first, then a stop bit 1.
For each character of Hi!, in order:
1. print the character, a space and its frame, for example H 0000100101;
2. put each of the 10 bits on the LED in turn, led("white") for 1 and led("off") for 0, with wait(0.05) after each.
Then print bits sent: <n>, where n is the number of bits you put on the LED, counted by your loop. Last, print how long 1200 characters take at 9600 baud with a 2-level signal, using the length of one frame: time for 1200 characters: <seconds> s, where seconds is the result of the division printed as Python prints it.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
BAUD = 9600
def frame(ch):
data = format(ord(ch), "08b")
return data
for ch in "Hi!":
print(ch, frame(ch))The hint students can ask for: Get the character's code, write it as eight bits, then reverse them so the least significant bit goes first. Put the start bit in front and the stop bit after. Count bits as you put them on the LED, and use the count of bits per frame for the timing line.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
BAUD = 9600
def frame(ch):
data = format(ord(ch), "08b")[::-1]
return "0" + data + "1"
sent = 0
for ch in "Hi!":
bits = frame(ch)
print(ch, bits)
for bit in bits:
if bit == "1":
led("white")
else:
led("off")
wait(0.05)
sent = sent + 1
led("off")
print("bits sent:", sent)
seconds = 1200 * len(frame("A")) / BAUD
print(f"time for 1200 characters: {seconds} s")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.