Networks · GCSE · OCR J277 1.3.2, AQA 8525 3.5, Edexcel 1CP2 4.1.7 · about 15 min
The four-layer TCP/IP model, encapsulation, and why layers are used.
[1 mark]Put the TCP/IP layers in order, from the top.
Number the lines 1 to 4 to put them in the right order.
ApplicationTransportLinkInternetApplication Transport Internet Link
Data goes down these layers to be sent, and up them when received.
[1 mark]At which layer does HTTP work?
[1 mark]Which layer adds IP addresses and routes packets between networks?
[1 mark]Which is an advantage of using layers?
[1 mark]What does this program print?
frame = "IP 1>2 | TCP 80 | hello"
for n in range(2):
frame = frame.split(" | ", 1)[1]
print(frame)hello
Each split removes the header at the front.
Write wrap(data, headers) and unwrap(frame). wrap adds each header in headers, in order, in front of the data with | between, printing <layer>: <data so far> after each (starting with application: GET /battery before any header). Send the finished frame by radio. Then unwrap removes the three headers, and you print received by application: <data>.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() data = "GET /battery" names = ["transport", "internet", "link"] headers = ["TCP 80", "IP 10.0.0.2>10.0.0.9", "WIFI 3C-02>3C-09"]
The hint students can ask for: Going down, each layer puts its header in front of what it was given, and you report the result at each step. Coming back up, take one header off the front at a time.
from bugbot import *
connect()
data = "GET /battery"
names = ["transport", "internet", "link"]
headers = ["TCP 80", "IP 10.0.0.2>10.0.0.9", "WIFI 3C-02>3C-09"]
def wrap(data, headers):
print("application:", data)
for i in range(len(headers)):
data = headers[i] + " | " + data
print(names[i] + ":", data)
return data
def unwrap(frame):
for header in headers:
frame = frame.split(" | ", 1)[1]
return frame
frame = wrap(data, headers)
send(frame)
print("received by application:", unwrap(frame))
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.