Book 3 · Chapter 14
Communication and internet technologies
B3·14This chapter is in the ebook.
Read it in full on cswithzak.com. Every question has its mark scheme and every program is ready to run. The free practice for each section is below, with the short code the book prints beside it.
For the whole chapter
- Topic pageCommunication and Internet Technologies
B3·14·T - QuizCommunication & Internet Technologies
B3·14·Q1 - LabTCP/IP layers & encapsulation
B3·14·X1 - LabPacket vs circuit switching
B3·14·X2
§14.1 Protocols
Short code B3·14·1
- FlashcardsFlashcards §14.1: Protocols & the TCP/IP stack
B3·14·F1 - Past-paper questionsPast-paper questions §14.1 (protocols)
B3·14·1
§14.2 Circuit switching and packet switching
Short code B3·14·2
- FlashcardsFlashcards §14.2: Circuit & packet switching, routing
B3·14·F2 - Past-paper questionsPast-paper questions §14.2 (circuit-switching-and-packet-switching)
B3·14·2
Why computers need protocols
Short code B3·14·10
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Protocols as a stack
Short code B3·14·11
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
The four layers of TCP/IP
Short code B3·14·12
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
A message from one host to another
Short code B3·14·13
DECLARE Data : STRING
DECLARE Segment : STRING
DECLARE Packet : STRING
DECLARE Frame : STRING
Data ← "GET /home"
Segment ← "[T:80 #1]" & Data
Packet ← "[I:203.0.113.9]" & Segment
Frame ← "[L:b2]" & Packet & "[chk]"
OUTPUT Data
OUTPUT Segment
OUTPUT Packet
OUTPUT FrameGET /home is untouched inside every wrapping.Output
GET /home [T:80 #1]GET /home [I:203.0.113.9][T:80 #1]GET /home [L:b2][I:203.0.113.9][T:80 #1]GET /home[chk]
The web and file transfer: HTTP and FTP
Short code B3·14·14
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Email: SMTP, POP3 and IMAP
Short code B3·14·15
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
BitTorrent: peer-to-peer file sharing
Short code B3·14·16
DECLARE Have : ARRAY[1:3, 1:6] OF BOOLEAN
DECLARE PeerName : ARRAY[1:3] OF STRING
DECLARE p : INTEGER
DECLARE k : INTEGER
DECLARE Source : INTEGER
PeerName[1] ← "the seed"
PeerName[2] ← "Ali"
PeerName[3] ← "Ben"
FOR k ← 1 TO 6
Have[1, k] ← TRUE
Have[2, k] ← k <= 3
Have[3, k] ← k = 4 OR k = 5
NEXT k
FOR k ← 1 TO 6
Source ← 1
FOR p ← 2 TO 3
IF Have[p, k] = TRUE
THEN
Source ← p
ENDIF
NEXT p
OUTPUT "Piece ", k, " from ", PeerName[Source]
NEXT kHave[p, k] is TRUE when peer p holds piece k; the seed (peer 1) is used only when no other peer has the piece. Notice the seed sends just one piece of six.Output
Piece 1 from Ali Piece 2 from Ali Piece 3 from Ali Piece 4 from Ben Piece 5 from Ben Piece 6 from the seed
Circuit switching
Short code B3·14·17
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Packet switching
Short code B3·14·18
DECLARE Slot : ARRAY[1:5] OF STRING
DECLARE ArrivedSeq : ARRAY[1:5] OF INTEGER
DECLARE ArrivedData : ARRAY[1:5] OF STRING
DECLARE i : INTEGER
DECLARE Message : STRING
// the packets in the order they arrived: 2, 5, 1, 4, 3
ArrivedSeq[1] ← 2
ArrivedData[1] ← "T A"
ArrivedSeq[2] ← 5
ArrivedData[2] ← " 4"
ArrivedSeq[3] ← 1
ArrivedData[3] ← "MEE"
ArrivedSeq[4] ← 4
ArrivedData[4] ← "ATE"
ArrivedSeq[5] ← 3
ArrivedData[5] ← "T G"
FOR i ← 1 TO 5
Slot[ArrivedSeq[i]] ← ArrivedData[i]
NEXT i
Message ← ""
FOR i ← 1 TO 5
Message ← Message & Slot[i]
NEXT i
OUTPUT MessageOutput
MEET AT GATE 4
DECLARE Got : ARRAY[1:6] OF BOOLEAN
DECLARE Arrived : ARRAY[1:4] OF INTEGER
DECLARE i : INTEGER
FOR i ← 1 TO 6
Got[i] ← FALSE
NEXT i
Arrived[1] ← 2
Arrived[2] ← 6
Arrived[3] ← 1
Arrived[4] ← 4
FOR i ← 1 TO 4
Got[Arrived[i]] ← TRUE
NEXT i
FOR i ← 1 TO 6
IF Got[i] = FALSE
THEN
OUTPUT "Ask for packet ", i, " again"
ENDIF
NEXT iOutput
Ask for packet 3 again Ask for packet 5 again
The router in packet switching
Short code B3·14·19
FUNCTION NextHopFor(Dest : STRING) RETURNS STRING
DECLARE Best : STRING
DECLARE BestCost : INTEGER
DECLARE r : INTEGER
Best ← "ISP"
BestCost ← 999
FOR r ← 1 TO 4
IF Table[r].Network = Dest AND Table[r].Cost < BestCost
THEN
Best ← Table[r].NextHop
BestCost ← Table[r].Cost
ENDIF
NEXT r
RETURN Best
ENDFUNCTION
OUTPUT NextHopFor("10.4.0.0")
OUTPUT NextHopFor("172.16.0.0")
OUTPUT NextHopFor("192.168.5.0")TRoute records (Chapter 13), filled in before this runs. For a destination network the router keeps the matching entry with the lowest cost, and falls back on the default route (ISP) when nothing matches.Output
R3 R2 ISP
DECLARE HopLimit : INTEGER
DECLARE R : INTEGER
DECLARE Alive : BOOLEAN
HopLimit ← 3
Alive ← TRUE
R ← 0
WHILE Alive = TRUE AND R < 5
R ← R + 1
HopLimit ← HopLimit - 1
IF HopLimit = 0
THEN
OUTPUT "R", R, " discards the packet"
Alive ← FALSE
ELSE
OUTPUT "R", R, " forwards it, hop limit now ", HopLimit
ENDIF
ENDWHILE
IF Alive = TRUE
THEN
OUTPUT "Delivered"
ENDIFOutput
R1 forwards it, hop limit now 2 R2 forwards it, hop limit now 1 R3 discards the packet
Circuit or packet? Choosing a method
Short code B3·14·20
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Past-paper practice
Short code B3·14·90
Practice for this page of the book: the quiz, flashcards and past-paper questions for its section are listed above.
Workbook 3: Communication and internet technologies
Short code W3·14 · Advanced Theory Workbook
The write-in workbook for this chapter has drills, exam-style practice, trace tables, fix-the-mistake and mark-it-yourself pages. Its full mark schemes and an interactive version arrive here with the chapter.


