CS 2210 - Notes CH 2
CS 2210 - Notes CH 2
O Level
Computer Science
CS 2210 – Notes
Chapter No. 2
Data Transmission
Data Packets
What are packets?
Packets are small 'chunks' of data that make up a larger piece of data that has
been broken down by the TCP protocol so that it can be transmitted over the
internet
TCP stands for Transmission Control Protocol and is used for organising data
transmission over networks
Small 'chunks' of data are easier and quicker to route over the internet than big
'chunks' of data
o Routing involves finding the most optimal path over a network
Data can include anything from text, images, audio, video, animations, etc, or any
combination of these
(1 of 5 etc.)
To transmit the message “This is a message :)”over the internet, TCP might break the
message down into 4 packets
o source IP address
o destination IP address
o payload (the data)
o a packet number
Error checks make sure that when a packet is received there is minimal or no
corruption of the data
Corruption is where packet data is changed or lost in some way, or data is gained
that originally was not in the packet
Read error detection methods for more detail on how data packets can be
checked to ensure corruption is avoided/minimised
Packet Switching
What is packet switching?
Interference and corruption are minimal as individual packets can be resent if they
are lost or damaged
The whole file doesn’t need to be resent if a corruption occurs, this saves
time and internet bandwidth
Packet switching is quicker than sending a large packet as each packet finds the
quickest way around the network
It's harder to hack an individual's data as each packet contains minimal data, and
travels through the network separately
Worked Example
A local market shop wishes to arrange a delivery of goods from a supplier. Anna, the shop
owner, decides to send an email to request the delivery of the goods at a certain date and
time.
Describe how packet switching is used to send this email and how it can be protected from
corruption.
[8]
Answer
The business email is first broken down into packets which are given a source
address (where it's come from) and a destination address (where it's going
to) [1]
Each packet receives a packet number so that the email can be reassembled
when it reaches its destination [1]
5|Page
Each packet also receives an error check such as a parity bit. A parity bit
checks whether any bits have been flipped due to corruption [1]
Each packet is sent over the internet via routers. Routers contain routing tables
that determine the next closest router to the destination [1]
Packets may take different routes depending on internet traffic and arrive at
their destination in any order [1]
Packets are checked for errors using the error checks and missing packets can
be requested to be resent [1]
Once all packets have been received then they can be put together in order
using the packet numbers [1]
Once assembled the original email can be read by the other business [1]
For high marks make sure your answer is coherent, that is it follows logically from one point
to the next.
Explaining parity bits without mentioning error checking first may not gain you additional
marks
Serial and parallel are methods of transmitting data (bits) from a sender to a
receiver
Each method determines how many bits can be transmitted at once
Serial transmission
Parallel transmission
6|Page
A stream of bits is sent in sequence, one after the other across multiple wires at
the same time
Transmission is asynchronous, data does not always arrive at the same time
A skew can be caused by data arriving out of order in asynchronous transmission
A traditional printer cable is an example of a wired parallel connection
Simplex transmission
Half-duplex transmission
Full-duplex transmission
Worked Example
Explain why parallel half-duplex data transmission is the most appropriate method.
[6]
Answer
Any four of these points qualifies as a full answer, however make sure your answer is
cohesive.
Saying “Parallel would allow for the fastest transmission but this does not have to be at the
same time” would qualify as one mark as only the first part makes sense and follows
logically
Advantages Disadvantages
Cable connectors fit in only one way. Older versions of USB have limited
This prevents incorrect connec ons and ensures transmission rates for example USB
compa ble data transmission 2.0 has 480Mbps
Worked Example
Julia uses a USB connec on to transfer data onto her USB flash memory drive.
One benefit of using a USB connec on is that it is a universal connec on.
(i) State two other benefits of using a USB connec on.
[2]
(ii) Iden fy the type of data transmission used in a USB connec on.
[1]
Answers
(i) Any two of:
It cannot be inserted incorrectly [1]
Supports different transmission speeds [1]
High speed transmission [1]
Automa cally detected [1]
Powers the device for data transfer [1]
(ii)
Serial [1]
Why Errors Occur
Why do errors occur?
Errors can occur using wired or wireless technology due to interference
Examples of interference include wire degrada on or electrical fields changing the signal
Results of interference include:
o Data loss - data is lost in transmission
o Data gain - addi onal data is received
o Data change - some bits have been changed or flipped
Wireless technology uses radio signals or other electromagne c signals to transmit data
11 | P a g e
o These signals can be blocked by physical barriers such as buildings, walls, cars or
other objects
o Interference can be caused by bad weather such as rain or clouds, or by
other wireless signals or electromagne c radia on
Wired technology carries more chance of causing an error as physical components can
be damaged, degrade or receive interference from outside signals
o Data loss can also occur from interrup ons to data transmission such as a blocked
signal or if the transmission is intermi ent
Why check for errors?
Computers expect data in certain formats
o A format is a way of arranging the data so that it can be easily understood by people
and by computers
o People agree to certain formats so that systems work more efficiently and there is
li le chance of misunderstanding each other
An example of a format is date and me
Date and me can have mul ple formats such as:
o 13/04/14 (DD/MM/YY)
o 12/31/2020 (MM/DD/YYYY)
o Jul-04-16 (MMM/DD/YY)
If data is not as expected, things can go wrong
For example, if a receiver expected to receive a date in format DD/MM/YY as 03/04/17 but
received 04/03/17, did the sender mean 3rd April 2017 or 4th March 2017?
An error or corrup on occurs when data received is not as expected and therefore is difficult
or impossible to process
Worked Example
Alex receives an email over a wireless connec on from a work colleague containing an important
document.
Iden fy what interference Alex could experience when sending this email and iden fy the outcomes
of interference.
Further explain why Alex should check to make sure the document contains no errors.
[4]
Answer
12 | P a g e
Weather condi ons or physical barriers such as building can affect signals, for example bits
could be flipped in the document making it hard to understand the original meaning [1]
Alex should be aware that interference can cause wirelessly received data to contain errors
or corrup on [1]
Data could be lost, addi onal data could be gained or data could be changed [1]
As Alex received an important work document they need to check for errors so that their
work is unaffected and they do not receive incorrect informa on [1]
Parity Check
What is a parity check?
A parity check determines whether bits in a transmission have been corrupted
Every byte transmi ed has one of its bits allocated as a parity bit
The sender and receiver must agree before transmission whether they are using odd or even
parity
If odd parity is used then there must be an odd number of 1’s in the byte, including the
parity bit
If even parity is used then there must be an even number of 1’s in the byte, including the
parity bit
The value of the parity bit is determined by coun ng the number of 1’s in the byte,
including the parity bit
If the number of 1’s does not match the agreed parity then an error has occurred
Parity checks only check that an error has occurred, they do not reveal where the error(s)
occurred
Even parity
Below is an arbitrary binary string
EVEN
Byte
Parity bit
0 1 0 1 1 0 1 0
If an even parity bit is used then all bits in the byte, including the parity bit, must add up to
an even number
o There are four 1’s in the byte
o This means the parity bit must be 0 otherwise the whole byte, including the parity bit,
would add up to five which is an odd number
Odd parity
13 | P a g e
ODD
Byte
Parity bit
1 1 0 1 1 0 1 0
If an odd parity bit is used then all bits in the byte, including the parity bit, must add up to
an odd number
o There are four 1’s in the byte. This means the parity bit must be a 1 otherwise the
whole byte, including the parity bit, would add up to four which is an even number
The table below shows a number of examples of the agreed parity between a sender and
receiver and the parity bit used for each byte
Example # Agreed parity Parity bit Main bit string Total number of 1’s
#1 ODD 0 1 1 0 1 0 1 1 5
#2 EVEN 1 0 0 0 1 0 0 0 2
#3 EVEN 1 0 1 0 1 1 1 1 6
#4 ODD 1 0 1 1 1 0 0 1 5
#5 ODD 1 1 0 1 0 1 0 1 5
#6 EVEN 0 1 0 0 1 1 1 0 4
Example #1: The agreed parity is odd. All of the 1’s in the main bit string are added (5). As
this number is odd already the parity bit is set to 0 so the whole byte stays odd
Example #2: The agreed parity is even. All of the 1’s in the main bit string are added (1). As
this number is odd the parity bit is set to 1 to make the total number of 1’s even (2)
Example #6: The agreed parity is even. All of the 1’s in the main bit string are added (4). As
this number is even already the parity bit is set to 0 so the whole byte stays even
How do errors occur?
When using parity bits, an error occurs when the number of total bits does not match the
agreed parity
Bits can be flipped or changed due to interference on a wire or wirelessly due
to weather or other signals
Example # Agreed parity Parity bit Main bit string Total number of 1’s Error
#1 ODD 1 1 1 0 1 0 1 1 6 Error
#2 EVEN 1 0 0 0 1 0 0 0 2 No error
14 | P a g e
#3 EVEN 1 0 1 1 1 1 1 1 7 Error
#4 ODD 1 0 1 1 1 0 0 1 5 No error
#5 ODD 1 1 0 1 0 1 1 1 6 Error
#6 EVEN 0 1 0 0 0 1 1 0 3 Error
Parity checks are quick and easy to implement but fail to detect bit swaps that cause the
parity to remain the same
Parity Byte & Block Check
What are parity byte & block checks?
Parity blocks and parity bytes can be used to check an error has occurred and where the
error is located
Parity checks on their own do not pinpoint where errors in data exist, only that an error has
occurred
A parity block consists of a block of data with the number of 1’s
totalled horizontally and ver cally
A parity byte is also sent with the data which contains the parity bits from the ver cal parity
calcula on
Below is a parity block with a parity byte at the bo om and a parity bit column in the second
column
ODD Parity bit Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 Bit 8
Byte 1 0 1 1 0 1 0 1 1
Byte 2 0 0 0 0 1 0 0 0
Byte 3 1 0 1 0 1 1 1 1
Byte 4 1 0 1 1 1 0 0 1
Byte 5 1 1 0 1 0 1 0 1
Byte 6 1 1 0 0 1 1 1 0
Byte 7 0 0 1 1 1 1 1 0
Byte 8 0 1 0 1 1 0 0 0
Parity byte 0 1 1 1 1 1 1 1
Each bit column calculates the ver cal parity for each row, the parity byte
It is calculated before transmission and sent with the parity block
Each parity bit tracks if a flip error occurred in a byte while the parity byte calculates if
an error occurred in a bit column
By cross referencing both horizontal and ver cal parity values the error can be pinpointed
In the above example the byte 3 / bit 5 cell is the error and should be a 0 instead
The error could be fixed automa cally or a retransmission request could be sent to the
sender
Checksum
What is a checksum?
A checksum is a value that can be used to determine if data has been corrupted or altered
It indicates whether data differs from its original form but does not specify where
Checksums are calculated using an algorithm and the value is added to the transmission
The receiving device re-calculates the checksum and compares to the original
If the checksums do not match, it is assumed an error has occurred
Worked Example
Describe the process a checksum algorithm uses to determine if an error has occurred
[5]
Answer
Before data is transmi ed a checksum value is calculated [1]
The checksum value is transmi ed with the data [1]
The receiver calculates the checksum value using the received data [1]
The calculated checksum is compared to the transmi ed checksum [1]
If they are the same then there is no error otherwise an error has occurred [1]
Echo Check
What is an echo check?
An echo checks involve transmi ng the received data back to the sender
The sender then checks the data to see if any errors occurred during transmission
This method isn’t reliable as an error could have occurred when the sender transmits the
data or when the receiver transmits the data
16 | P a g e
01100100
10010001
00000011
10110010
[4]
(b) An error may not be detected when using a parity check.
Iden fy why an error may not be detected.
[1]
Answers
(a)
(b)
Any one from:
there is a transposi on of bits [1]
it does not check the order of the bits (just the sum of 1s/0s) [1]
even number of bits change [1]
incorrect bits s ll add up to correct parity [1]
17 | P a g e
Check Digits
What is a check digit?
A check digit is the last digit included in a code or sequence, used to detect errors in numeric
data entry
Examples of errors that a check digit can help to iden fy are:
o Incorrect digits entered
o Omi ed or extra digits
o Phone c errors
Added to the end of a numerical sequence they ensure validity of the data
Calculated using standardised algorithms to ensure widespread compa bility
Examples of where check digits can be used include:
o ISBN book numbers
o Barcodes
ISBN book numbers
Each book has a unique ISBN number that iden fies the book
A standard ISBN number may be ten digits, for example, 965-448-765-9
The check digit value is the final digit (9 in this example).
This number is chosen specifically so that when the algorithm is completed the result is a
whole number (an integer) with no remainder parts
A check digit algorithm is performed on the ISBN number and if the result is a whole
number, then the ISBN is valid
Barcodes
Barcodes consist of black and white lines which can be scanned using barcode scanners
Barcode scanners shine a laser on the black and white lines which reflect light into the
scanner
The scanner reads the distance between these lines as numbers and can iden fy the item
Barcodes also use a set of digits to uniquely iden fy each item
The final digit on a barcode is usually the check digit, this can be used
to validate and authen cate an item
Worked Example
Check digit algorithms are used to determine whether an error has occurred in transmi ed data.
18 | P a g e
When data received contains an error a request is sent (automa cally) to resend the data
The resend request is repeatedly sent un l packet is received error free/limit is
reached/acknowledgement received
Encryp on
What is encryp on?
Encryp on is a method of scrambling data before being transmi ed across a network
Encryp on helps to protect the contents from unauthorised access by making data
meaningless
While encryp on is important on both wired and wireless networks, it's even more cri cal
on wireless networks due to the data being transmi ed over radio waves, making it easy
to intercept
How is wireless data encrypted?
Wireless networks are iden fied by a 'Service Set Iden fier' (SSID) which along with a
password is used to create a 'master key'
When devices connect to the same wireless network using the SSID and password they are
given a copy of the master key
The master key is used to encrypt data into 'cipher text', before being transmi ed
The receiver uses the same master key to decrypt the cipher text back to 'plain text'
To guarantee the security of data, the master key is never transmi ed. Without it, any
intercepted data is rendered useless
Wireless networks use dedicated protocols like WPA2 specifically designed for Wi-Fi security
20 | P a g e
The secret key can be shared with the receiver without sending it electronically:
o Both par es could verbally share the key in person
o Both par es may use standard postage mail to share the key
o An algorithm may be used to calculate the key by sharing secret non-key informa on
What is asymmetric encryp on?
Asymmetric encryp on is when two keys are used, a public and private key
o Public key: a key known to everyone
o Private key: a key known only to the receiver
Both keys are needed to encrypt and decrypt informa on
Asymmetric encryp on works as follows:
o Person A uses a public key to encrypt their message
o Person A sends their message over the network or internet
o Person B decrypts the message using their secret private key
Only one private key can be used to decrypt a message and it is not sent over the
internet like a symmetric key
Keys can be large, a key using 100 bits would generate
1,267,650,600,228,229,401,496,703,205,376 different combina ons
Large keys are near impossible for a hacker to guess
Worked Example
Complete the sentences about symmetric encryp on. Use the terms from the list. Some of the terms
in the list will not be used. You should only use a term once.
algorithm
cipher
copied
delete
key
plain
private
public
standard
stolen
understood
unreadable
22 | P a g e
The data before encryp on is known as ______ text. To scramble the data, an encryp on ______,
which is a type of ______, is used. The data a er encryp on is known as ______ text. Encryp on
prevents the data from being ______ by a hacker.
[5]
Answer
One mark for each correct term in the correct place:
The data before encryp on is known as plain text. To scramble the data, an
encryp on algorithm/key, which is a type of key/algorithm, is used. The data a er encryp on is
known as cipher text. Encryp on prevents the data from being understood by a hacker.