Networks and the web · A level · OCR H446 1.3.3, AQA 7517 4.9.4.1, Eduqas A500QS 2.2 · about 30 min
The four layers, encapsulation, ports and sockets, and HTTP, HTTPS, FTP, SMTP, POP3 and SSH.
[1 mark]Put the layers of the TCP/IP stack in order, from the top (nearest the application) to the bottom.
Number the lines 1 to 4 to put them in the right order.
LinkNetworkTransportApplication[1 mark]Which layer adds the source and destination port numbers?
[1 mark]What is a socket?
[1 mark]On which port does a web server listen for HTTPS by default?
[1 mark]Which protocol does an email client use to download messages from its mail server, usually deleting them from the server?
[1 mark]As a packet crosses several routers on the Internet, which addresses are replaced at every hop?
The robot at 192.168.4.23 asks the Server at 192.168.4.1 for its battery level.
Write checksum(text): its input is any string; it returns the sum of the character codes (ord) of every character in text, modulo 256, as two uppercase hexadecimal digits (format(n, "02X")).
1. Build and send one packet: the body <source IP>,<destination IP>,<source port>,<destination port>,<data> with source port 49152, destination port 80 and data GET /battery, then *, then the body's checksum.
2. The Server replies with a packet in the same format. Wait for it, checking messages() every 0.1 s.
3. Split off the checksum after the last *. If the body's checksum matches, print checksum ok, then from socket <source IP>:<source port>, then data: <data>. The data is everything after the fourth comma. If it does not match, print checksum wrong.
The robot does not drive.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
def checksum(text):
return "00"
send("192.168.4.23,192.168.4.1,49152,80,GET /battery")Plan your program here, then type it in and press Run.