0% found this document useful (0 votes)
17 views208 pages

AQA GCSE Computer Science Paper2

The document covers the fundamentals of data representation, focusing on number bases such as decimal, binary, and hexadecimal. It explains how these bases are used in computing, particularly how binary represents all data and instructions, and why hexadecimal is preferred for ease of use. Additionally, it includes methods for converting between these number bases.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views208 pages

AQA GCSE Computer Science Paper2

The document covers the fundamentals of data representation, focusing on number bases such as decimal, binary, and hexadecimal. It explains how these bases are used in computing, particularly how binary represents all data and instructions, and why hexadecimal is preferred for ease of use. Additionally, it includes methods for converting between these number bases.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3 Fundamentals of data representation

3 Fundamentals of data representation


Learning objectives:
■ Understand the following
number bases
■ 3.1 Number bases
• decimal (base 10) Meaning of number base
• binary (base 2) The number base system specifies how many digits are used in constructing a
• hexadecimal (base 16) numeral (representation of a number) and by how much to multiply each digit.

■ Understand that computers For example, in the decimal system the numeral 734 is interpreted as meaning
use binary to represent all data 7 × 100 + 3 × 10 + 4 × 1
and instructions Decimal (base 10)
■ Explain why hexadecimal is The number base of the decimal system is ten because it has ten digits 0, 1, 2,
often used in computer science. 3, 4, 5, 6, 7, 8, 9 and the digit multiplier is a power of ten, 10n where n is

Information … −3, −2, −1, 0, 1, 2 , 3, …


Base 10 system is an example
The number represented by the numeral 734 in base 10 is constructed using
of a positional number system.
This type of system was first the place values indicated in Table 3.1.1 as follows
used by the Babylonians over 7 × 100 + 3 × 10 + 4 × 1
4000 years ago in Mesopotamia,
modern day Iraq. Positional
… 102 101 100 …
number systems are good for … 100 10 1 …
doing arithmetic with. 7 3 4

Table 3.1.1 Place values for the decimal system


Key concept
Decimal: To indicate the base we can use a subscript attached to the numeral, e.g. 73410.
The number base of the decimal
Binary (base 2)1
system is ten because it has ten
digits 0, 1, 2, 3, 4, 5, 6, 7, 8, The number base of the binary system is two because it has two digits 0, 1 and
9 and the digit multiplier is a the digit multiplier is a power of two, 2n where n is … −3, −2, −1, 0, 1, 2 , 3, …
power of ten, 10n where n is
…, −3, −2, −1, 0, 1, 2 , 3, … The number in decimal represented by the binary numeral 10111 is constructed
using the place values in Table 3.1.2 as follows

Key point 1 × 16 + 0 × 8 + 1 × 4 + 1 × 2 + 1 × 1
To indicate the base we use To indicate the base we use a subscript attached to the numeral, e.g. 101112.
a subscript attached to the … 24 23 22 21 20 …
numeral, e.g. 73410. … …
16 8 4 2 1
1 0 1 1 1
Key concept
Binary: Table 3.1.2 Place values for the binary system
The number base of the binary Now the quote “There are 10 types of people in the world those that
system is two because it has understand binary and those that don’t” might make more sense because
two digits 0, 1 and the digit
multiplier is a power of two, 2n 10Binary = 2Decimal
where n is
…, −3, −2, −1, 0, 1, 2 , 3, … 1 There is more on binary in Chapter 3.2. For the exam you will only have to
work with whole numbers up to 255 in decimal.
2 Fundamentals of data representation

Key concept Questions


Hexadecimal: 1 What is the decimal equivalent of the binary number 11001 shown in
The number base of the
Table 3.1.3?
hexadecimal system is sixteen
because it has sixteen digits 0, 24 23 22 21 20
1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
16 8 4 2 1
D, E, F and the digit multiplier
1 1 0 0 1
is a power of sixteen, 16n where
n is Table 3.1.3
…, −3, −2, −1, 0, 1, 2 , 3, …
2 The bit pattern 11001 in Table 3.1.3 is replaced by the bit pattern
11111 representing another number.
What is the decimal equivalent of this number?

Hexadecimal (base 16)2


The number base of the hexadecimal system is sixteen because it has sixteen digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,
D, E, F and the digit multiplier is a power of sixteen, 16n where n is …, −3, −2, −1, 0, 1, 2 , 3, …

The number in decimal represented by the hexadecimal numeral D4 is constructed using the place values in Table
3.1.4 as follows … 161 160 …
13 × 16 + 4 × 1
… 16 1 …
where D has been replaced by 13. D 4
The hexadecimal digits A, B, C, D, E and F are, in decimal, 10, 11, 12, 13, 14 Table 3.1.4 Place values for
and 15 respectively. the hexadecimal system
The number in decimal represented by the hexadecimal numeral 38AD4 is
constructed using the place values in Table 3.1.5 as follows
3 × 65536 + 8 × 4096 + 10 × 256 + 13 × 16 + 4 × 1

To indicate the base we use a subscript attached to the numeral, e.g. 38AD416.
… 164 163 162 161 160 …
… 65536 4096 256 16 1 …
3 8 A D 4
Table 3.1.5 Some more place values for the hexadecimal system

Questions
3 What is the decimal equivalent of the hexadecimal number 51CBE shown in Table 3.1.6?

164 163 162 161 160


65536 4096 256 16 1
5 1 C B E

Table 3.1.6
4 The hexadecimal number 51CBE in Table 3.1.6 is replaced by the hexadecimal number FFFFF
representing another number. What is the decimal equivalent of this number?

2 There is more on hexadecimal in Chapter 3.2. For the exam you will only have to work with whole numbers up to 255
in decimal.
2.1 Number bases

Binary is used to represent all data and instructions


Figure 3.1.1 shows executable binary codes called machine code
instructions.
These executable binary codes or bit patterns instruct computer
hardware to carry out some machine task, e.g. ADD two numbers
and display the result on the screen of the visual display unit.
The language of computer hardware is binary, i.e. binary codes or
bit patterns that the hardware can interpret in a meaningful way as
data or instructions. Figure 3.1.1 Machine code displayed in
binary
For example, the bit pattern 10010111 could represent
• a machine instruction
• an integer
• an item of text, e.g. the letter 'A'
• a pixel of a bitmap image
• a part of a sound file.
When a computer program is downloaded from the Internet it streams into
your computer as a sequence of bit patterns. These bit patterns could represent
any of the above.
In fact, if the bit pattern stream is downloaded as an attachment to an email it Figure 3.1.2 The
could be a computer virus. The virus arrives as data but ends up being executed same machine
as machine code which potentially does nasty things to your computer. code expressed in
hexadecimal

Information
5 The stream of bit patterns 11110010...10101101 consists of several Debugging:
thousand binary digits i.e. 1s and 0s of data. Debugging software means to
identify and remove errors from
State three possible things that this stream might represent.
the software.
Maurice Wilkes, computing
pioneer:
Why is hexadecimal used?
“By June 1949, people had
Hexadecimal as shorthand for binary begun to realize that it was not
Long strings of 1s and 0s are difficult for a human to work with so so easy to get a program right
programmers often switch to the hexadecimal equivalent because it is much as had at one time appeared.
easier to work with. It was on one of my journeys
between the EDSAC1 (World’s
Compare Figure 3.1.1 and Figure 3.1.2 which show respectively, a sample of first stored program digital
machine code and its hexadecimal equivalent. computer) room and the
punching equipment (programs
If the strings of 1s and 0s represent executable code then debugging this code is
were submitted on punched
much easier if the code is displayed in hexadecimal form. cards) that the realization came
Its meaning is easier to determine than its binary form. over me with full force that a
good part of the remainder of
Similarly, writing numbers in hexadecimal form is less error prone than writing my life was going to be spent
the same numbers in binary especially if the binary form consists of long strings in finding errors in my own
of 1s and 0s. programs.”
2 Fundamentals of data representation

Information For example, it would be cumbersome and error prone to specify the colour for
In some programming
text on a page of HTML in 24 binary digits, better to use the shorthand form
languages, e.g. Java, a number of hexadecimal, e.g. #1F040A.
represented in hexadecimal is
Here the # symbol is used to indicate that the numeral is in hexadecimal.
indicated by placing 0x before
the numeral, e.g. 0x3C4. The contents of memory or registers of a computer system can be displayed
for debugging purposes. It is usual for the software that is used for debugging
to display these contents in hexadecimal because it is much easier for a human
to read the numbers in this form as well as taking up less space on the display
Key point
screen.
Long strings of 1s and 0s are
Software is needed because the numbers are actually stored in memory
difficult for a human to read
so programmers often switch locations and registers in base 2 form.
to the hexadecimal equivalent Memory addresses are more conveniently expressed in hexadecimal than binary.
because it is
For example, the memory limit of Windows 7 is 4 GiB. This requires the use of
much easier to read
more compact, 32 binary digits to express the address of a particular memory word or location
4x fewer digits but in hexadecimal it requires only 8 hexadecimal digits. Incidently, it would
require 10 decimal digits.
easier to debug code
expressed in hexadecimal. However, hexadecimal is more suitable when working with digital hardware
than decimal because hexadecimal uses 4x fewer digits than binary (³²⁄₄) but
decimal uses 3.2x fewer (³²⁄₁₀), an awkward factor to work with.

Information 6 What is wrong with this statement:


“Hexadecimal is often used instead of binary in a computer’s memory
The unit of storage GiB or because it is more compact.”?
GigaByte is 220 bytes

In this chapter you have covered:


■ The following number bases
• decimal (base 10)
• binary (base 2)
• hexadecimal (base 16)
■ That computers use binary to represent all data and instructions
■ Why hexadecimal is often used in computer science.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Understand how binary can
be used to represent whole
■ 3.2 Converting between number bases
numbers Converting from decimal to binary
Method 1
■ Understand how hexadecimal
Using the place values in Table 3.2.1, take the decimal number to be converted
can be used to represent whole
and find between which two column place values it lies, e.g. 3510 lies between
numbers
columns with place values 32 and 64, respectively.
■ Be able to convert in both Place 1 in the column with the lower of the two place values and 0 in the
directions between:
higher of the two as shown in Table 3.2.1.
• binary and decimal
With the given example, take the place value 32 away from the decimal
• binary and hexadecimal number, leaving 310. Place 0 in all the columns with place values greater than
• decimal and 310. It is then trivial to see that we need one 2 and one 1 to match 310.
hexadecimal. … 26 25 24 23 22 21 20 …
… 64 32 16 8 4 2 1 …
Information 0 1 0 0 0 1 1
Throughout this chapter you Table 3.2.1 Some place values for the binary system and the binary
may find Microsoft® Windows’ representation of decimal 35
calculator in programmer mode
Questions
a handy tool with which to
explore the relationship between 1 Convert the following numbers expressed in decimal to their binary
decimal and binary, decimal and equivalent using Method 1.
hexadecimal.
(a) 3310 (b) 2410 (c) 5810 (d) 12710

Key method Method 2 - the method of successive division


Example: Take the decimal number and repeatedly divide by 2 writing down the
Decimal to decimal by remainder each time as shown in Table 3.2.2, stopping when zero is reached.
successive division, picks out
the individual digits The binary equivalent of 3510 is read from the remainder column beginning at
e.g. n = 46210 the last row and working up the table.

n n⁄₁₀ r Quotient New number Remainder


462 46 2 35/2 17 1
46 4 6 17/2 8 1
4 0 4 8/2 4 0
4/2 2 0
Where r is the remainder. 2/2 1 0
The remainder supplies the 1/2 0 1
individual digits, one at a time,
Table 3.2.2 Successive division by 2 method
e.g. 2.
3 Fundamentals of data representation

Questions
2 Convert the following numbers expressed in decimal to their binary equivalent using Method 2.
Show the intermediate results in a table with structure similar to Table 3.2.2.
(a) 3310 (b) 2410 (c) 5810 (d) 12710

Converting from binary to decimal


See Chapter 3.1.
Converting from decimal to hexadecimal
We can use the method of successive division similar to the one used for decimal to binary
conversions, this time dividing by 16. Table 3.2.3 shows a worked example for n = 24910 . The
last column is read from the last row upwards giving F916.

Quotient New number Remainder


249/16 15 9
15/16 0 15(F)

Table 3.2.3 Successive division by 16 method

Questions
3 Convert the following numbers expressed in decimal to their hexadecimal equivalent using the method
described above. Show the intermediate results in a table with structure similar to Table 3.2.3.
(a) 4710 (b) 12710 (c) 18910 (d) 25510

Converting from hexadecimal to decimal


See Chapter 3.1.

Converting from hexadecimal to binary


This can be done in a straightforward way as follows:
Write down the number in hexadecimal
Replace each hexadecimal digit by its binary B47A
equivalent using 4 binary digits
Figure 3.2.1 shows how this can be done with the example of B47A16 1011 0100 0111 1010
giving the result Figure 3.2.1 Hexadecimal to binary
B47A16 = 10110100011110102

The method relies on the fact that the hexadecimal digits 0 to F map to 0 to 15 in decimal and this decimal range
can be coded by just four binary digits. When a number represented in four binary digits is multiplied by 1610, it
becomes a number represented by eight binary digits with zeroes in the least significant four bit positions, twelve
binary digits when multiplied by 1610 again and so on.

Questions
4 Convert the following numbers expressed in hexadecimal to their binary equivalent using the method
described above.
(a) 4716 (b) 3A216 (c) 6FE716 (d) BEEF16
2.2 Converting between number bases

Converting from binary to hexadecimal


This can be done in a straightforward way as follows:

Write down the number in binary


Add leading 0s to the left-hand side of the bit pattern so that the number of
bits is a multiple of 4 (if necessary)
Replace each block of four binary digits by their hexadecimal equivalent
1011 0100 0111 1010
Figure 3.2.2 shows how this can be done with the example of B47A16
giving the result
10110100011110102 = B47A16
B47A
Figure 3.2.2 Binary to Hexadecimal

Questions
5 Convert the following numbers expressed in binary to their hexadecimal equivalent using the method
described above.

(a) 11112 (b) 101011012 (c) 1011002 (d) 1100111000112

Using binary to represent decimal whole numbers


Whole numbers are numbers without a fractional part. Whole numbers can be positive, negative or zero. In fact,
whole number is another name for an integer.
You are only required to be able to represent decimal whole number values between 0 to 255 in binary.
Table 3.2.4 shows some decimal whole number values and their equivalent representation in binary.
Table 3.2.5 shows eight bits and their place values. The maximum decimal whole number that can be represented
in these eights bits is 255. The binary representation of decimal 255 is 11111111 as shown in Table 3.2.5 and
calculated as follows
1 × 128 + 1 × 64 + 1 × 32 + 1 × 16 + 1 × 8 + 1 × 4 + 1 × 2 + 1 × 1 = 255

Decimal Binary Decimal Binary Decimal Binary Decimal Binary



value value value value value value value value
0 00000000 8 00001000 � 240 11110000 248 11111000
1 00000001 9 00001001 � 241 11110001 249 11111001
2 00000010 10 00001010 � 242 11110010 250 11111010
3 00000011 11 00001011 � 243 11110011 251 11111011
4 00000100 12 00001100 � 244 11110100 252 11111100
5 00000101 13 00001101 � 245 11110101 253 11111101
6 00000110 14 00001110 � 246 11110110 254 11111110
7 00000111 15 00001111 � 247 11110111 255 11111111

Table 3.2.4 Table of binary codes in eight bits and their decimal equivalent values
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
Table 3.2.5 Place values for binary representing whole numbers between 0 and 255
3 Fundamentals of data representation

Questions
6 Express the following decimal whole numbers in binary using 8 bits.
(a) 128 (b) 127 (c) 245 (d) 254

Using hexadecimal to represent decimal whole numbers


You are only required to be able to represent decimal whole number values between 0 to 255 in hexadecimal.
Table 3.2.6 shows some decimal whole number values and their equivalent representation in hexadecimal.
Table 3.2.7 shows two hexadecimal digits and their place values. The maximum decimal whole number that can be
represented with two hexadecimal digits is 255. For this maximum number the hexadecimal representation is FF as
shown in Table 3.2.7 and calculated as follows
F × 16 + F × 1 = 15 x 16 + 15 x 1 = 240 + 15 = 255

Hexa- Hexa- Hexa- Hexa-


Decimal Decimal Decimal Decimal
decimal decimal � decimal decimal
value value value value
value value value value
0 00 8 08 � 240 F0 248 F8
1 01 9 09 � 241 F1 249 F9
2 02 10 0A � 242 F2 250 FA
3 03 11 0B � 243 F3 251 FB
4 04 12 0C � 244 F4 252 FC
5 05 13 0D � 245 F5 253 FD
6 06 14 0E � 246 F6 254 FE
7 07 15 0F � 247 F7 255 FF

Table 3.2.6 Table of two digit hexadecimal codes and their decimal equivalent values

161 160
16 1
F F
Table 3.2.7 Place values for hexadecimal representing whole numbers between 0 and 255

Questions
7 Express the following decimal whole numbers in hexadecimal using two hexadecimal digits.
(a) 128 (b) 127 (c) 245 (d) 254

In this chapter you have covered:


■ How binary can be used to represent whole numbers
■ How hexadecimal can be used to represent whole numbers
■ Converting in both directions between:
• binary and decimal
• binary and hexadecimal
• decimal and hexadecimal.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Know that:
■ 3.3 Units of information
• a bit is the fundamental Information
unit of information We are surrounded in everyday life by information-carrying symbols or signs.
• a byte is a group of 8 bits For example, road signs are an expression of information for road users.

■ Know that quantities of bytes In Figure 3.3.1(a) the information conveyed is of a factual kind. Figure
can be described using prefixes: 3.3.1(a) has the meaning, the road ahead narrows, that is a fact.
• kilo, 1 kB is 1,000 bytes In Figure 3.3.1(b) the information conveyed is of a instructional kind. The
• mega, 1 MB is 1,000 GIVE WAY sign has a meaning that is an instruction.
kilobytes
• giga, 1 GB is 1,000
Megabytes
• tera, 1 TB is 1,000
Gigabytes
■ Be able to compare quantities
of bytes using the prefixes
above. (a) (b)
Figure 3.3.1 Some information-carrying road signs
As “pretty” as symbols/signs may be, their purpose is not
decoration but instead it is communication of something. That
something is information.
We therefore separate the symbol from the information it carries.
The symbol is merely the carrier of information.
In digital computers, collections of binary digits or bits are used to
represent information and to convey information from one place
to another - Figure 3.3.2. Whilst in transit the bits are just data
Figure 3.3.2 Two computing machines (uninterpreted symbols). The bits are turned into information
communicating in binary when they are interpreted, i.e. when their meaning is extracted.
The bit streams in Figure 3.3.2 being downloaded could be for example, an
Key concept image or a computer program or a magazine article or a web page, etc.
Bit: The smallest unit of information being conveyed is a 0 or a 1, i.e. a Binary
The bit is the fundamental unit
digIT or bit, abbreviated to b.
of information.
It is abbreviated to the symbol Thus the bit is the smallest unit of information.
b.
The meaning of a bit is not known until it is processed or interpreted, e.g. is it
Byte: part of an image or a program or a web page?
A byte is a group of 8 bits.
It is abbreviated to the symbol
For convenience, bits are grouped together into a unit called a byte for which
B. the abbreviation B is used. A byte is 8 bits.
3 Fundamentals of data representation

Key concept Questions


Information = data + meaning
1 State the information conveyed by the following symbols:

Key concept ☺ He Ar
You might need to do some research to discover some of the answers.
A datum (plural data) is any
physical phenomenon or object 2 State the number of bytes in 1111000010101100.
that carries information, e.g.
road sign object, speech.
There can be no information Power of Decimal number Exponent
Ten
without data. Data is how
information is represented. 1012 1000000000000 12
1011 100000000000 11
Powers of 10
1010 10000000000 10
Figure 3.3.3 shows in red the decimal number corresponding to a
109 1000000000 9
given power of 10. The power is known as the exponent. The exponent
specifies the number of zeroes in the decimal number. 108 100000000 8
107 10000000 7
To avoid writing out long strings of zeroes, the names, symbols and
106 1000000 6
corresponding powers of 10 are used as shown in Table 3.3.1.
105 100000 5
Power of 104
Name Symbol 10000 4
10
103 1000 3
kilo k 103
mega M 106 102 100 2
giga G 109 101 10 1
tera T 1012
Figure 3.3.3 Powers of 10
Table 3.3.1 Unit name, symbol and
corresponding power of 10
Quantities of bytes
Storage device manufacturers measure capacity using
the decimal system (base 10), so 1 gigabyte (GB) is
calculated as exactly 1,000,000,000 bytes or 1 billion
bytes.
Figure 3.3.4 shows the reporting of the capacity of a
Western Digital hard disk.
Table 3.3.2 shows how to express a decimal numeral
which is a power of 10 in units of k, M, G and T.
If the decimal numeral refers to a quantity of bytes
then we can express the quantity using the units of k,
M, G and T.

Figure 3.3.4 Exterior of a hard disk


showing storage capacity of 160.0 GB
2.3 Units of information

Using symbol Using named Did you know?


Decimal Power Using form of unit unit for Genetic information in the form of
genes are instructions which together
number of 10 units for quantities quantities of
with other essential ingredients
of bytes bytes serve the purpose of controlling
1000 103 1k 1kB 1 kilobyte and guiding the development of
10000 104 10k 10kB 10 kilobytes organisms.
100000 105 100k 100kB 100 kilobytes
1000000 106 1M 1MB 1 megabyte Background
10000000 107 10M 10MB 10 megabytes This picture of a tree stump is
100000000 108 100M 100MB 100 megabytes an example of another type of
1000000000 109 1G 1GB 1 gigabyte information, environmental
10000000000 1010 10G 10GB 10 gigabytes information. The concentric rings
100000000000 1011 100G 100GB 100 gigabytes visible in the wood of a cut tree
trunk provide information on the
1000000000000 1012 1T 1TB 1 terabyte
age of the tree and the growing
Table 3.3.2 Quantities of bytes expressed in units k, M, G and T conditions at the time a ring was laid
Questions down. Here the information carrier
is a tree ring.
3 Express the following decimal numerals in the form 10n
(a) 1000 (b) 1000000 (c) 10000000
4 Convert the following quantities in bytes to kB
1000 (b) 10000
5 Convert the following quantities in bytes to MB
(a) 500000 (b) 2000000 (c) 30000000

Background
Historically, the terms kilobyte, megabyte, etc have often been used to represent powers of 2.
This rather confusing situation has been resolved by the gradual adoption of the International Electrotechnical
Commission (IEC) standard for binary prefixes, which specify the use of gigabyte (GB) to strictly denote
1000000000 bytes and gibibyte (GiB) to denote 1073741824 bytes. This standard is now part of the
International System of Quantities.
You are not required to know the powers of 2 alternative units. However, for the sake of completeness it is
included here.
Powers of 2
Table 3.3.3 shows decimal numbers expressed as powers of 2, their equivalent binary and the corresponding
unit. In 2 raised to the power of 10, 10 is known as the exponent. The exponents 10, 20, 30, 40 specify the
number of zeroes in the binary numeral.
Decimal Power
Binary number Unit
number of 2
1024 210 10000000000 kibibyte
220
1048576 100000000000000000000 mebibyte
230
1073741824 1000000000000000000000000000000 gibibyte
240
1099511627776 10000000000000000000000000000000000000000 tebibyte
Table 3.3.3 Some decimal numbers expressed as powers of 2
3 Fundamentals of data representation

Background
To avoid writing out long strings of zeroes, the names, symbols and
corresponding powers of 2 are used as shown in Table 3.3.4. Name Symbol Power of 2
kibi Ki 210
If the binary numeral refers to a quantity of bytes then we can express the 220
mebi Mi
quantity using the units of Ki, Mi, Gi and Ti as shown in Table 3.3.5. gibi Gi 230
B refers to byte. tebi Ti 240

Table 3.3.4 Unit name, symbol and


Key fact corresponding power of 2
kibi, Ki - 210
mebi, Mi – 220 Using symbol Using named
gibi, Gi – 230
Decimal Power Using form of unit unit for
tebi, Ti – 240
number of 2 units for quantities quantities of
of bytes bytes
kilo, k - 103
1024 210 1Ki 1KiB 1 kibibyte
mega, M – 106
giga, G – 109 1048576 220 1Mi 1MiB 1 mebibyte
tera, T – 1012 1073741824 230 1Gi 1GiB 1 gibibyte
1099511627776 240 1Ti 1TiB 1 tebibyte
Table 3.3.5 Quantities of bytes expressed in units

In this chapter you have covered:


■ That:
• a bit is the fundamental unit of information
• a byte is a group of 8 bits
■ That quantities of bytes can be described using prefixes:
• kilo, 1 kB is 1,000 bytes
• mega, 1 MB is 1,000 kilobytes
• giga, 1 GB is 1,000 Megabytes
• tera, 1 TB is 1,000 Gigabytes
■ Comparing quantities of bytes using the prefixes above.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Be able to add together up to
■ 3.4 Binary arithmetic
three binary numbers Adding two binary integers
The rules for adding numbers expressed in the binary numeral system are
■ Be able to apply a binary shift basically the same as for any other system. We add the contents of each column
to a binary number
in turn, starting from the right with the least significant digit column and
■ Describe situations where moving progressively leftward. Any carry from a column must be added to the
binary shifts can be used. sum of the digits in the next column as shown in Figure 3.4.1 which shows the
sum 011011002 + 001010102 of two 8-bit binary integers.

Information 12 + 02 + carry 12 = 02 carry 12 12 + 12 = 02 carry 12

You may find Microsoft®


Windows’ calculator in 27 26 25 24 23 22 21 20
programmer mode a handy tool 0 1 1 0 1 1 0 0
with which to convert between 0 0 1 0 1 0 1 0
binary and decimal and vice 1 Carry 1 0 Carry 1 0 1 Carry 1 0 1 1 0
versa.
Least
significant digit
column

12 + 12 = 02 carry 12

Figure 3.4.1 Addition of two 8-bit binary integers

The basic rules are as follows

02 + 02 = 02

02 + 12 = 12

12 + 02 = 12

12 + 12 = 02, carry 12 to the next column


since there is no symbol for 2.

The last rule states that 12 + 12 = 102.


3 Fundamentals of data representation

If we have a carry from the previous column then the carry must be added to the sum of the two digits of the
current column. So we have the additional rules

02 + 02 + carry 12 = 12

02 + 12 + carry 12 = 02 carry 12

12 + 02 + carry 12 = 02 carry 12

12 + 12 + carry 12 = 12 carry 12

Normally addition of two binary numerals representing unsigned binary integers is set out in the manner of the
example below
01101011
+00011011
10000110

Questions
1 Complete the following sums
02 + 02 = 02 + 02 + 12 =
02 + 12 = 02 + 12 + 12 =

12 + 02 = 12 + 12 + 12 =

12 + 12 =

2 Complete the following additions of two 4-bit binary integers:


0110 (b) 0 1 0 1
+0001 +0101

3 Complete the following additions of two 8-bit binary integers:


01101011 (b) 1 1 0 1 0 1 0 1
+00011011 +00011101
2.4 Binary arithmetic

Adding three binary integers


We add the contents of each column in turn, starting from the right with the least significant digit column and
moving progressively leftward. Any carry from a column must be added to the sum of the digits in the next column.
The basic rules are as follows

02 + 02 + 02 = 02
02 + 02 + 12 = 12
02 + 12 + 02 = 12
12 + 02 + 02 = 12
02 + 12 + 12 = 02, carry 12 to the next column
12 + 02 + 12 = 02, carry 12 to the next column
12 + 12 + 02 = 02, carry 12 to the next column
12 + 12 + 12 = 12, carry 12 to the next column 02 + 02 + 02 + carry 12 = 12

02 + 02 + 12 + carry 12 = 02 carry 12

If we have a carry from the previous column then the carry must be 02 + 12 + 02 + carry 12 = 02 carry 12
added to the sum of the three digits of the current column. 12 + 02 + 02 + carry 12 = 02 carry 12
So we have the additional rules shown in Figure 3.4.2. 02 + 12 + 12 + carry 12 = 12 carry 12
The last rule produces a carry of 102 not 12. In decimal this is a carry of 12 + 02 + 12 + carry 12 = 12 carry 12
2 not 1.
12 + 12 + 02 + carry 12 = 12 carry 12
Figure 3.4.3 shows the sum 011010002 + 001010102 + 010010112 of
12 + 12 + 12 + carry 12 = 02 carry 102
three 8-bit binary integers.

Figure 3.4.2 Additional rules that apply


to the addition of three binary digits

02 + 12 + 12 = 02 carry 12
12 + 12 + 12 = 12 carry 12
12 + 02 + 12 + carry 12 = 12 carry 12

27 26 25 24 23 22 21 20
0 1 1 0 1 0 0 0
0 0 1 0 1 0 1 0
0 1 0 0 1 0 1 1
1 Carry 1 1 Carry 1 0 1 Carry 1 1 1 Carry 1 0 1

This column uses the rule


12 + 12 + 02 = 02 carry 12
02 + 02 + 02 + carry 12 = 12 This column uses the rule
02 + 02 + 02 + carry 12 = 12

Figure 3.4.3 Addition of three 8-bit binary integers


3 Fundamentals of data representation

Normally addition of three binary numerals representing binary integers is set out in the manner of the example
below
01101000
00101010
+01001011
11011101

Of course, there is nothing to stop you adding two of the three binary numbers first and then adding the third to
the result!

Questions
4 Complete the following sums
02 + 02 + 12 = 02 + 02 + 12 + 12 =
02 + 12 + 12 = 02 + 12 + 12 + 12 =
12 + 12 + 12 = 12 + 12 + 12 + 12 =

5 Complete the following additions of three 4-bit binary integers:


(a) 0 1 1 0 (b) 0 1 1 1
0001 0101
+0110 +0001

6 Complete the following additions of three 8-bit binary integers:


01101011 (b) 0 1 0 1 0 1 0 1
00011011 00011101
+00011000 +01101001

Shifting bits in a binary number


A shift operation takes two inputs, one the number of shifts to apply, n, and the other the bit pattern to be shifted
by n bits. For example, the bit pattern in Figure 3.4.4 (a) when shifted by one bit to the left becomes the bit
pattern shown in Figure 3.4.4(b).
The least significant bit position is filled with 0. The most significant bit is shifted out and discarded.
Figure 3.4.4(a) 8-bit bit pattern before it is shifted left one bit 0 0 1 1 0 1 1 0

Figure 3.4.4(b) 8-bit bit pattern after it is shifted left one bit 0 1 1 0 1 1 0 0

Figure 3.4.4 is an example of a shift left operation.


With a shift right the bit pattern is moved to the right with the most significant bit position replaced by a zero.
The least significant bit is shifted out and discarded.

Figure 3.4.5(a) 8-bit bit pattern before it is shifted right one bit 1 0 1 1 0 1 1 0

Figure 3.4.5(b) 8-bit bit pattern after it is shifted right one bit 0 1 0 1 1 0 1 1
3.4 Binary arithmetic

Situations where binary shifts are used


Multiplying by 2
The 8-bit binary number 00110110 shown in Figure 3.4.6(a) represents the decimal number 54.
00110110 = 0 x 27 + 0 x 26 + 1 x 25 + 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20
= 0 x 128 + 0 x 64 + 1 x 32 + 1 x 16 + 0 x 8 + 1 x 4 + 1 x 2+ 0 x 1
= 54

Multiplying this decimal number by 2 we obtain 108.


108 = 0 x 128 + 1 x 64 + 1 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2+ 0 x 1
= 0 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 0 x 20
= 01101100

One left shift operation on the binary number in Figure 3.4.6(a) results in the binary number 01101100 (Figure
3.4.6(b)), which is in decimal 108, because
0 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 0 x 20 = 108

Thus one left shift operation is equivalent to multiplying by 2.


27 26 25 24 23 22 21 20
Figure 3.4.6(a) 8-bit bit pattern before it is shifted left one bit 0 0 1 1 0 1 1 0

Figure 3.4.6(b) 8-bit bit pattern after it is shifted left one bit 0 1 1 0 1 1 0 0

Two left shift operations is equivalent to multiplying by 2 x 2, i.e. 4 (22).


The resulting binary number from two left shift operations is 11011000.
In decimal, 11011000 = 1 x 27 + 1 x 26 + 0 x 25 + 1 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 0 x 20
= 1 x 128 + 1 x 64 + 0 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 0 x 2 + 0 x 1
= 216

However, this goes wrong when a left shift is applied to a binary number with 1 in the most significant position,
e.g. the binary number 11011000 which we have just calculated to be 216 in decimal.
Applying a left shift to 11011000 results in 10110000, i.e. 11011000 ↦ 10110000
But 10110000 = 1 x 27 + 0 x 26 + 1 x 25 + 1 x 24 + 0 x 23 + 0 x 22 + 0 x 21 + 0 x 20
= 1 x 128 + 0 x 64 + 1 x 32 + 1 x 16 + 0 x 8 + 0 x 4 + 0 x 2 + 0 x 1
= 176

Doubling 216 produces 432 not 176. Decimal number 432 is too big to be represented in 8 bits which is why the
left shift operation fails.
Questions

7 Show the binary number that results from 3 left shift operations on 0 0 0 1 0 1 1 1
the binary number in Figure 3.4.7. Figure 3.4.7

8 Show the binary number that results from 3 left shift operations on 0 0 1 0 0 1 1 1
the binary number in Figure 3.4.8. Comment on the result. Figure 3.4.8
3 Fundamentals of data representation

Dividing by 2
The 8-bit binary number 11011000 shown in Figure 3.4.9(a) represents the decimal number 216.
11011000 = 1 x 27 + 1 x 26 + 0 x 25 + 1 x 24 + 1 x 23 + 0 x 22 + 0 x 21 + 0 x 20
= 1 x 128 + 1 x 64 + 0 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 0 x 2 + 0 x 1
= 216

Dividing this decimal number by 2 we obtain 108.


108 = 0 x 128 + 1 x 64 + 1 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2+ 0 x 1
= 0 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 0 x 20
= 01101100

One right shift operation on the binary number in Figure 3.4.9(a) results in the binary number 01101100, in
decimal 108, because
0 x 27 + 1 x 26 + 1 x 25 + 0 x 24 + 1 x 23 + 1 x 22 + 0 x 21 + 0 x 20 = 108

27 26 25 24 23 22 21 20
Figure 3.4.9(a) 8-bit bit pattern before it is shifted left one bit 1 1 0 1 1 0 0 0

Figure 3.4.9(b) 8-bit bit pattern after it is shifted left one bit 0 1 1 0 1 1 0 0

Thus one right shift operation is equivalent to dividing by 2.


Two right shift operations is equivalent to dividing by 2 x 2, i.e. 4 (22).
The resulting binary number from two right shift operations is 00110110.
Table 3.4.1 shows successive divisions by 2 Decimal no Decimal no
Remainder
applied to the starting decimal number 216 before single Binary no Binary no after single
after
and then the resulting decimals. right shift Before After right shift
division
operation operation
The division by 2 is a type of division called 216 11011000 01101100 108 0
integer division. 108 01101100 00110110 54 0

In this division, the result is an integer 54 00110110 00011011 27 0


27 00011011 00001101 13 1
(whole number).
13 00001101 00000110 6 1
For the odd decimals, 27, 13, 3 and 1, the 6 00000110 00000011 3 0
result is a whole number and a non-zero 3 00000011 00000001 1 1
remainder. Remainders are either 0 or 1. 1 00000001 00000000 0 1

Table 3.4.1 Successive division by 2

Questions

9 Show the binary number that results from 3 right shift operations 0 0 0 1 1 0 0 0
on the binary number in Figure 3.4.10. Figure 3.4.10

10 Show the binary number that results from a single right shift 0 0 0 0 0 1 1 1
operation on the binary number in Figure 3.4.11. Comment on Figure 3.4.11
the result.
3.4 Binary arithmetic

In this chapter you have covered:


■ Adding together up to three binary numbers
■ Applying a binary shift to a binary number
• Left shift
• Right shift
■ Describing situations where binary shifts can be used
• Multiplying by 2
• Dividing by 2.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Understand what a character ■ 3.5 Character encoding
set is and be able to describe
ASCII
the following character
Long ago, before the Internet and the World Wide Web, the only characters that
encoding methods:
mattered were unaccented uppercase and lowercase English letters based on a 26
• 7-bit ASCII
letter alphabet, digits 0 - 9, and a variety of punctuation and special symbols.
• Unicode
■ Understand that character We have learned that computers work with numbers in the form of bit patterns.
codes are commonly grouped Therefore, to store letters of the alphabet and other characters we have to
and run in sequence within assign each one a number.
coding tables
An encoding scheme called ASCII does just this. It was invented to encode the
■ Describe the purpose of limited set of characters mentioned above.
Unicode and the advantages of
Unicode over ASCII In this scheme, characters are encoded using a number between 32 and 127. For
■ Know that Unicode uses the example, in the ASCII character set, space is 32, and the upper case letter 'A' is
same codes as ASCII up to 65. Device-control characters such as line feed and carriage return were added
127. to this set of characters and allocated numbers in the range 0 to 31.
Code Code Code Code
in decimal
Character
in decimal
Character
in decimal
Character
in decimal
Character In all, the entire character set is
32 Space 56 8 80 P 104 h encoded using numbers in the
33 ! 57 9 81 Q 105 i range 0 to 127.
34 “ 58 : 82 R 106 j
To represent this number range
35 # 59 ; 83 S 107 k
in the language of the machine,
36 $ 60 < 84 T 108 l
37 % 61 = 85 U 109 m
binary, requires 7 bits.
38 & 62 > 86 V 110 n Table 3.5.1, shows 96 of the
39 ‘ 63 ? 87 W 111 o possible 128 (27) codes.
40 ( 64 @ 88 X 112 p
For example, from Table 3.5.1
41 ) 65 A 89 Y 113 q
42 * 66 B 90 Z 114 r the ASCII code for the letter A
43 + 67 C 91 [ 115 s is 1000001 in binary and 65 in
44 , 68 D 92 \ 116 t decimal whilst the ASCII code for
45 - 69 E 93 ] 117 u the minus sign symbol - is 0101101
46 . 70 F 94 ^ 118 v in binary which is 45 in decimal.
47 / 71 G 95 _ 119 w
ASCII was invented in the
48 0 72 H 96 ` 120 x
1960s so that information could
49 1 73 I 97 a 121 y
50 2 74 J 98 b 122 z be exchanged over telephone
51 3 75 K 99 c 123 { wires between data processing
52 4 76 L 100 d 124 | equipment.
53 5 77 M 101 e 125 }
ASCII stands for American
54 6 78 N 102 f 126 ~
Standard Code for Information
55 7 79 O 103 g 127 DEL
Interchange.
Table 3.5.1 ASCII code lookup table
3 Fundamentals of data representation

All 128 codes are called character codes because they encode what is collectively known as characters.
However, only 95 codes are actually used for symbols, the other 33 are control codes, codes 0 to 31 and the code
127 which is reserved for an instruction delete a character code.
Code Code
Table 3.5.2 shows a lookup table for ASCII control in decimal
Character
in decimal
Character

codes, 0 to 31. 0 Null 16


The codes in Table 3.5.2 with a blank character field 1 17
2 18
are codes used for controlling communication over a
3 19
telephone line.
4 20
Line feed and carriage return are used to break a long 5 21
string of characters into separate lines. 6 22
7 Bell 23
When characters are organised on a line-by-line basis
8 Backspace 24
we call this text, e.g. the text that you are reading on
9 Horizontal tabulation 25
this page. 10 Line feed 26
Text files therefore consist of one long string of ASCII 11 Vertical tabulation 27 Escape

character codes with the line breaks marked by a 12 Form feed 28


combination of ASCII code 10 (line feed) and ASCII 13 Carriage return 29
14 30
code 13 (carriage return).
15 31
These control codes reposition a VDU’s cursor at the
Table 3.5.2 ASCII code lookup table for some control codes
beginning of the next line when displaying a text file
on a VDU. Key concept
ASCII or American Standard
Questions Code for Information
Interchange:
1 State the ASCII character code for In ASCII, the symbols
(a) the letter H (b) the decimal digit 3 (c) the symbol ? corresponding to the letters of
the alphabet (upper case and
2 What is the symbol or character corresponding to the following ASCII lower case), punctuation marks,
character codes special symbols and the decimal
digits 0 to 9 are assigned
(a) 97 (b) 37 (c) 48?
different 7-bit binary codes
Encode the message "Hello" in ASCII. according to a look up table.
3

4 Encode the text


"Hello
World!"
in ASCII.

5 Convert the following string of ASCII character codes to its equivalent


text form
72 101 108 108 111 10 13 87 111 114 108 100 33
3.5 Character encoding

Unicode
Logogram-based languages such as Chinese have characters that number in the tens of thousands. These characters
will never fit a 7-bit encoding scheme.
It is impossible, therefore, to represent a string such as 你好 世界 in any of the ASCII 7-bit encoding schemes.
The answer to this problem is an encoding scheme called Unicode ([Link]).
Unicode covers all of the characters in all of the world’s writing systems, plus accents and other special marks
and symbols, and control codes such as tab and carriage return, and assigns each one a standard number called a
Unicode code point.
Unicode version 8 defines code points for over 120,000 characters in well over 100 languages and scripts but not
Klingon, which was rejected in 2001 by the Unicode Technical Committee.
Key term
The Unicode Glossary defines a character as:
Unicode:
• The smallest component of written language that has semantic value, Unicode is a computing
i.e. meaning industry standard for
• The basic unit of encoding for Unicode character encoding the consistent encoding,
• The English name for the ideographic written elements of Chinese representation, and handling
origin. of text expressed in most of the
world’s writing systems.
UTF-32 is the simplest Unicode encoding form.
Unicode provides a unique
Each Unicode code point is represented directly by a single 32-bit code unit. number for every character:
Because of this, UTF-32 has a one-to-one relationship between encoded no matter what the platform;
no matter what the program;
character and code unit; it is a fixed-width character encoding form.
no matter what the language.
Whilst UTF-32 provides the simplest mapping, it uses much more space than is
necessary - 4 bytes for every Unicode code point or character. Information
Most computer-readable text is in ASCII, which requires only 7 bits which can Unicode code charts:

be accommodated in 1 byte (8 bits). [Link]


Knowledge of the detail of
In fact, all the characters in widespread use still number fewer than 65,536, UTF-32, UTF-16 and UTF-8 is
which can be coded in 16 bits or 2 bytes. This gave rise to two other Unicode not required for GCSE.
encoding forms - UTF-16 and UTF-8 of 16 bits and 8 bits respectively.
Figure 3.5.1 shows the three Unicode encoding forms - UTF-32, UTF-16, Information
UTF-8. In UTF-8 as many bytes as needed are allocated, e.g. the uppercase letter Characters:
A is allocated one byte (8 bits) which is the hexadecimal code 41. This is exactly Characters are represented by
code points that reside only
the same code that ASCII uses (or its 8-bit ANSI standard).
in a memory representation
In fact, Unicode uses the same codes as ASCII up to 127, albeit in 8 bits rather as strings in memory, on disk,
than 7 bits. or in data transmission. For
example U+0041 is Latin
A Ψ 菜 UTF-32 capital letter A.
00000041 000003A8 000083DC 00010381
The Unicode Standard
Version 8.0 - Core

A Ψ菜 D800 DF81 UTF-16 Specification:


[Link]
0041 03A8 83DC
versions/Unicode8.0.0/[Link]


41 CE A8 E8 8F 9C F0 90 8E 81
UTF-8 The Unicode Standard deals
with character codes.
Figure 3.5.1 Unicode encoding forms
3 Fundamentals of data representation

Questions
6 你 is one example of the set of 50000 Chinese characters. What character
coding scheme could you use to represent these 50000 Chinese characters and Code
Symbol
why? in decimal
48 0
7 State one advantage of Unicode over ASCII.
49 1
8 Why is it possible to use Unicode to represent 7-bit ASCII? 50 2
51 3
52 4
Character form of a decimal digit 53 5
Table 3.5.3 has been constructed by copying the ASCII code points for the decimal 54 6
digits 0 to 9 from Table 3.5.1. 55 7
56 8
Humans work with numerals consisting of decimal digits, e.g. 261, when they do 57 9
a calculation or record a number. If a decimal numeral sent from one computer
Table 3.5.3 ASCII codes
or computer component to another is used by a human at the receiving end for a for the decimal digit
calculation, the decimal digits of the numeral must first be mapped to their ASCII code symbols 0 to 9
equivalents before sending, and mapped back on receipt from ASCII code to decimal
digit form. Code Letter
65 A
For example, if 261 is typed at the keyboard, the sequence of ASCII codes 50, 54, 49
66 B
is generated and sent. A visual display unit (VDU) receiving these ASCII codes knows 67 C
that it should display 261 on its screen - see Figure 3.5.2. 68 D
To 69 E
Decimal number Decimal number
typed at keyboard To 49 54 50 decimal displayed on VDU 70 F
261 ASCII digits 261 71 G
72 H
Figure 3.5.2 From decimal numeral to ASCII codes and back to decimal numeral 73 I
74 J
The ASCII codes 50, 54, 49 are called the character code form of the decimal digits 75 K
261 e.g. 50 is the character code form of the decimal digit 2. To convert this character 76 L
code form 50 into the number 2 we should subtract 48. The character code form of the 77 M
decimal number 2 in 7-bits is 0110010 whereas its pure binary representation is 000 78 N
79 O
0010 in 7-bits.
80 P
Symbolically, the character code form 50, 54, 49 can be written as '2' '6' '1'. The single 81 Q
apostrophes around each digit are used to differentiate the character form from the 82 R
decimal digit form. 83 S
Grouping of character codes 84 T

Table 3.5.3 reflects how character codes are grouped within the ASCII coding table. 85 U
86 V
For example, the decimal character digits '0' to '9' are assigned codes that run in a
87 W
sequence that matches the sequence of decimal character digits, 48 ↦ '0', 49 ↦ '1',
88 X
50 ↦ '2', etc.
89 Y
This means that the codes for character digits '1' to '9' can be calculated once the code 90 Z
for character digit '0 'is known. Table 3.5.4 ASCII codes
for the uppercase letters
3.5 Character encoding

Similarly, Table 3.5.4 reflects how character codes for the uppercase letters are grouped within the ASCII coding
table. For example, the character 'A' has the code 65, the character 'B' the code 66. The codes for uppercase letter
characters run in a sequence that matches the sequence of uppercase character letters, 65 ↦ 'A', 66 ↦ 'B', 67 ↦ 'C',
etc.
This means that the codes for characters digits 'B' to 'Z' can be calculated once the code for character 'A' is known.

Questions
9 The ASCII character code for the decimal character digit '0' is 48.
Without using an ASCII code table, calculate what the ASCII character code is for the decimal character
digit '3'.

10 The ASCII character code for the character 'A' is 65.


Without using an ASCII code table, show how you would calculate the ASCII character code for the
character ‘D’.

11 Show by calculation how to convert the following ASCII codes to their equivalent decimal digit value
(not their equivalent decimal character digit), given that decimal character digit '0' has ASCII code 48 and
decimal digit value 0.
(a) 51 (b) 53 (c) 57

12 What is the ASCII character code form of the following decimal digits and combination of decimal digits
(note that 6 is not the same as '6', 34 is not the same as '34', etc)
(a) 6 (b) 34 (c) 908 (d) 444?

13 Why is it difficult to do arithmetic with the character form of a decimal number?


What would need to be done with the character form of a decimal numeral in order to do arithmetic in the
conventional way?

14 What is the ASCII character code form of the following characters and character strings
(a) '6' (b) '54'?

In this chapter you have covered:


■ What a character set is and the following character encoding methods:
• 7-bit ASCII
• Unicode
■ That character codes are commonly grouped and run in sequence within coding tables
■ The purpose of Unicode and the advantages of Unicode over ASCII
■ That Unicode uses the same codes as ASCII up to 127.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Understand what a pixel is
■ 3.6 Representing images
and be able to describe how What is a pixel?
pixels relate to an image and Light reflected by an object may be captured by a digital camera as shown in
the way images are displayed Figure 3.6.1. The digitised image is made up of pixels.
A pixel is the smallest addressable region (“point”) or element of a digital
■ Describe the following for
image. The term pixel is short for picture element.
bitmaps:
Each pixel is a sample of the original image. A pixel is a single dot of colour.
• size in pixels
• colour depth
■ Know that the size of a bitmap Real world object

image is measured in pixels


(width x height)
■ Describe how a bitmap Output (digitised image)

represents an image using


pixels and colour depth (Internal) image

■ Describe using examples how Light source

the number of pixels and Figure 3.6.1 Digital camera imaging system
colour depth can effect the file Each “square” in the pixel grid of rows and columns shown in Figure 3.6.2 is
known as a pixel or picture element.
size of a bitmap image
The pixel at the row position 12 and column position 17 in Figure 3.6.2 is a
■ Calculate bitmap image file mix of red, green and blue.
sizes based on the number of Column
0 3 17 27
pixels and colour depth 0

■ Convert binary data into a Pixel


at
bitmap image Column = 17, Row = 12

■ Convert a bitmap image into


Colour = A8231616
Row
binary data. 12
14

19
Key concept Pixel
or Picture element
at position Column = 3, Row = 14
Pixel: Colour = FFFFFF16

A pixel is the smallest Figure 3.6.2 Pixel grid made up of 28 x 20 = 560 pixels
addressable region or element of ■ the red component has an 8-bit value representing its intensity of
a digital image or dot of colour. A816 or 16810 (measured on a scale that ranges from 0 to 255)
Each pixel is a sample of the
■ the green component (8-bits) has an intensity of 2316 or 3510
original image.
■ the blue component (8-bits) has an intensity of 1616 or 2210
At position Row = 14 and Column = 3, the corresponding red, green and blue
intensities are each represented by FF16 or 25510, the maximum value.
3 Fundamentals of data representation

Questions
1 Figure 3.6.3 shows an image captured and saved with three different settings of a digital camera.
Give one reason why the quality of the three images appears to improve from image (a) to image (c).

(a) (b) (c)


Figure 3.6.3

Displaying an image
Visual Display Units (VDUs ) display pictures (images) by dividing the display screen into thousands (or millions)
of pixels, arranged into rows and columns as shown in Figure 3.6.4.
1920 pixels
Small magnified
20” area of screen
1080 pixels 11.25”

Pixel

Figure 3.6.4 Visual Display Unit of 1080 x 1920 pixels

Questions 1024 pixels

2 The dimensions of a VDU screen in pixels are shown opposite.


How many pixels in total does the screen of this VDU have 768 pixels

available to display images?

Image size of a bitmap


The pixel grid shown in Figure 3.6.2 is made up of 28 x 20 = 560 pixels. Key concept
The colour of each pixel is recorded in 24 bits, 8 bits per primary colour (the Bitmap size in pixels:
primary colours are red, green and blue). Bitmap size = W x H
where
The total collection of bits for the entire 560 pixels making up the digitised image W = width of image in pixels
is called a bitmap and the digitised image, a bitmap image. To store a digitised H = width of image in pixels
image we store its bitmap.
The size of a bitmap image is expressed directly as width of image in pixels by height of image in pixels using the
notation width x height, e.g. 28 x 20. A bitmap image’s resolution can be expressed in terms of its image size in
pixels, i.e. image resolution = width in pixels x height in pixels.
3.6 Representing images

Colour depth of a bitmap Key concept


Colour depth, also known as bit depth, is expressed as the number of bits used
to indicate the colour of a single pixel in a digitised image, e.g. 24 bits. Colour depth or bit depth:
Colour depth, also known as
The bitmap of an image records for each pixel a whole number (integer) bit depth, is expressed as the
encoded in the given bit depth. number of bits used to indicate
the colour of a single pixel in a
Visual Display Units use each integer in the bitmap when displaying the image to digitised image, e.g. 24 bits.
select the corresponding colour to display for each pixel.
Suppose the colour depth of each pixel is recorded using 8 bits per pixel, then the
possible whole numbers (integers) that can be represented lie in the range 0 to 255 in decimal.
If instead 16 bits are used per pixel then the range is greater and from 0 to 65535.
More bits means more colours can be represented, a different colour can be chosen for each
integer in this range. 255
If the colour depth of each pixel is recorded using 2 bits per pixel, then the possible whole
numbers (integers) that can be represented lie in the range 0 to 3 in decimal. 192
Fewer bits means fewer colours can be represented.
128
Given a colour depth of 24 bits allocated as follows:
■ 8 bits to represent red intensity 64
■ 8 bits to green and
0
■ 8 bits to blue,

The integer values for each primary colour can range from 0 to 255 in decimal. Figure 3.6.5

Ignoring the 8 bits for green and the 8 bits for blue and focussing just on the 8 bits allocated to red, Figure 3.6.5
shows some selected values from the possible range 0 to 255 for red intensity and their corresponding “redness”.
Note that when the value is 0 the redness manifests itself as black, an absence of colour.
Each possible combination of the coded red, green and blue intensities represents a different resultant colour.
The number of different bit patterns of 24 bits is 224 = 16777216.
Thus a colour depth of 24 bits allows for 16777216 different colours.

Questions

3 State the maximum number of different colours that can be encoded when using two bits for each pixel.

4 What is meant by colour depth?

5 State the minimum number of bits need to encode 256 different colours.
3 Fundamentals of data representation

How does a bitmap represent an image? MEMORY


If we wish to store a digitised image, such as the
one shown in Figure 3.6.2, then information
about the colour of each element of the image, i.e. MAPPED TO
each pixel, must be stored. DIGITISED 308 FFFFFF
309 FFFFFF
This is done by recording for each pixel, the SAMPLES 310 FFFFFF
311 FFFFFF
number (from the range allowed by the chosen 312 FFFFFF
313 FFFFFF
colour depth) representing its digitised intensity. 314 FFFFFF
Figure 3.6.6 shows a section of memory from 315 FFFFFF
316 FFFFFF
locations 308 to 335 and the corresponding row of 317 FFFFFF
318 A82316
pixels that it maps to in Figure 3.6.2. 319 A82316
320 A82316
321 CA1719
Note that the white pixels in this row are stored 322 F29476
as FFFFFF and the non-white pixels as either 323 A82316
324 A82316
A82316, CA1719, or F29476. 325 FFFFFF
326 FFFFFF
We say that the image is mapped to bits in 327 FFFFFF
Figure 3.6.6 shows a section 328 FFFFFF
memory. of memory from locations 308 329 FFFFFF
330 FFFFFF
The stored bits in memory are a digital 331 FFFFFF
to 335 and the corresponding 332 FFFFFF
representation of this image, a bitmap. 333 FFFFFF
row of pixels that they map to. 334 FFFFFF
Any bitmap image is a pixel-based digital image. 335 FFFFFF

Bitmap image file sizes


The digitised image shown in Figure 3.6.2 consists
of 28 x 20 = 560 pixels.
The colour information for each pixel requires 24 bits of storage space because Key concept
the colour depth is 24 bits.
Therefore, the size in bits of this digitised image is as follows Bitmap image or bitmap:
Size in bits = Width x Height x Colour depth A bitmap image is a pixel-based
digital image.
Size in bits = 28 x 20 x 24
The digitised image is mapped
= 13440 to bits in memory representing
The size in bytes of this digitised image is as follows the intensity and colour of each
Size in bytes = (Width x Height x Colour depth)/8 pixel.
= 13440/8
= 1680
For this image, a minimum file size of 1680 bytes will be required to store the image’s bitmap.
If colour depth was changed to 8 bits then the minimum file size will be (28 x 20 x 8)/8 = 560 bytes.
Example
Width = 1920 pixels
Key point
Height = 1080 pixels
Colour depth = 24 bits Bitmap image file sizes:
Size in bits = Width x Height x Colour depth Size (in bits) = W x H x D
Size in bits = 1920 x 1080 x 24 Size (in bytes) = (W x H x D)/8
= 49766400 where
The size in bytes of this digitised image is as follows W = width of image in pixels
Size in bytes = (Width x Height x Colour depth)/8 H = height of image in pixels
= 49766400/8 D = colour depth in bits
= 6220800
Size in megabytes = 6220800/1000000
= 6.2208 MB
For this image, a minimum file size of 6.2208 MB will be required to store the image’s bitmap.
3.6 Representing images

Questions
6 The 640 x 480 digitised image shown in Figure 3.6.7 uses a
colour depth of 24 bits.
How would the size of its bitmap be affected if colour depth was
changed to 8 bits?

7 Calculate the size in bytes of the bitmap for the 640 x 480
digitised image of colour depth 24 bits shown in Figure 3.6.7.

Figure 3.6.7

Converting a digitised black and white image1 into binary data


The image shown in Figure 3.6.8 is made up of a 5 by 5 pattern of black and white squares.
Digitising this image onto a 5 x 5 grid of pixels results in the grid shown in Figure 3.6.9.
If we use a colour depth of 1 bit and encode black with the bit value 0 and white with the bit value 1 then the
binary encoding of each row of the digitised image shown in Figure 3.6.9 is as shown in Figure 3.6.10.

01110
10101
11011
10101
10001
Figure 3.6.8 Figure 3.6.9 Figure 3.6.10
It would be wasteful but perfectly possible to use a colour depth of 2 bits and encode black with the bit value 00
and white with the bit value 11.
The binary encoding of each row would then be as shown 0011111100
in Figure 3.6.11.
1100110011
With a colour depth of 1 bit the bitmap for the digitised 1111001111
image shown in Figure 3.6.10 is 01110

10101 1100110011
11011 1100000011
10101 Figure 3.6.11
10001
With a colour depth of 2 bits the bitmap for the digitised image shown in Figure 3.6.11 is 0011111100
The displayed image appears the same (Figure 3.6.9) but its bitmap requires more storage 1100110011
space. However, the unused bit patterns 01 and 10 could be used for two different shades 1111001111
of grey.
1100110011
1 AQA’s 8525 specification refers to this task as converting a bitmap image into binary data
1100000011
3 Fundamentals of data representation

Questions
8 The grid shown in Figure 3.6.12 represents a bitmap
image of colour depth 1 bit.
The corresponding bitmap uses bit value 0 to encode
a black pixel and bit value 1 to encode a white pixel.
Copy Figure 3.6.13 and write the bit patterns
corresponding to each row of pixels shown in Figure
3.6.12. Figure 3.6.12 Figure 3.6.13

Converting binary data into a bitmap image Reading direction


Using a colour depth of 1 bit to encode black with the bit value 0 and white with the bit value 1,
the following binary encoding of each row of a digitised image was produced as shown in Figure
0101
3.6.14. 1010
From the bitmap of 0s and 1s shown in Figure 3.6.14 it is
possible to deduce that the digitised image has
0101
4 columns and 5 rows of pixels. 1010
Figure 3.6.15 shows a reconstruction of the 5 x 4 grid. 0101
To recreate the digitised image we read the bitmap data row by Figure 3.6.14
row, from left to right, starting with the first row.
When a 0 is encountered the corresponding pixel is made
black and when a 1 is encountered the corresponding pixel is
made white as shown in Figure 3.6.16. Figure 3.6.15

Questions Image Encoding


9 Figure 3.6.17 shows three digitised black and white 0011
images. The corresponding bitmaps use bit value 0 0110
to encode a black pixel and bit value 1 to encode a
1100
white pixel. B Figure 3.6.16
1001
Only one bitmap is correctly encoded.
State which bitmap is correctly encoded. 1001
C
1010
Figure 3.6.17

In this chapter you have covered:


■ What a pixel is and describing how pixels relate to an image and the way images are displayed
■ The following for bitmaps:
• size in pixels
• colour depth
■ Know that the size of a bitmap image is measured in pixels (width x height)
■ How a bitmap represents an image using pixels and colour depth
■ Describing using examples how the number of pixels and colour depth can affect the file size of a bitmap image
■ Calculating bitmap image file sizes based on the number of pixels and colour depth
■ Converting binary data into a bitmap image
■ Converting a bitmap image into binary data.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Understand that sound is
analogue and that it must be
■ 3.7 Representing sound
converted to a digital form Sound is analogue
for storage and processing in a When the forks of a tuning fork vibrate naturally, the oscillations
computer caused in the surrounding air are perceived as a pure sound tone
by the brain “hearing them”.
■ Understand that analogue
signals are sampled to create The ear of the listener converts the tuning-fork-induced air
the digital version of sound pressure fluctuations into an equivalent oscillating electrical signal that then
travels to the brain for processing.
■ Describe the digital
representation of sound in We can see the shape of these
terms of: oscillations by converting
the smooth and continuous
• sampling rate
fluctuations in air pressure
• sample resolution into an equivalent oscillating
■ Calculate sound file sizes based electrical voltage by using a
on the sampling rate and the microphone and displaying
sample resolution. this voltage as a function
of time on the screen of an
oscilloscope, a sophisticated
kind of voltmeter, as shown Figure 3.7.1 Oscilloscope displaying the
oscillations of a tuning fork via a microphone
in Figure 3.7.1.
The fluctuations in air pressure that we experience as
sound vary in a continuous manner.
Pressure/Pa

For the vibrating tuning fork, we get a smooth and


Time/milliseconds continuous variation in air pressure as shown in Figure
3.7.2, which travels as a sound wave to the microphone.
The voltage (and current) the microphone generates in
Figure 3.7.2 Fluctuations in air pressure caused
response also varies in a smooth and continuous manner
by a vibrating tuning fork as a function of time
and is similar in shape to the sound vibrations picked up
by the microphone.
By shape is meant waveform - see Figure 3.7.3.
Voltage/volts

Sound is analogue in form because it (the air pressure


Time/milliseconds
fluctuations) varies in a continuous manner.
The voltage (or current) generated by the microphone
is an electrical signal.
Figure 3.7.3 Fluctuations in voltage induced
This electrical signal (voltage or current) is also
in a microphone by a vibrating tuning fork as a
analogue because it too varies in a continuous manner
function of time
and its variation is similar in shape to that of the sound.
3 Fundamentals of data representation

Recording sound in digital form


The language of digital computers is binary. Therefore, if we want to record sound in a digital computer we must
represent the sound as a sequence of bit patterns, i.e. a sequence of numbers.
To get these numbers, we must first sample the analogue waveform of the sound, or more correctly its electrical
equivalent - an analogue signal.
We must do this at regular points in time and when we sample, we must also measure the height (amplitude) of the
analogue waveform as shown in Figure 3.7.4. Key term
Sample:
Positions marked | on clockface A sample is a measure of
when waveform sampled Sample point amplitude at a point in time.

C Figure 3.7.4 Measuring the height of the


C B D waveform at regular points in time
D B
E Time
E A Measured
A Binary
sample in volts
F H Number
G lies between
F H
-0.5 to +0.5 0000
G
Sampling clock +0.5 to +1.5 0001
+1.5 to +2.5 0010
A conversion table such as shown in Table 3.7.1 is then used to decide which
+2.5 to +3.5 0011
binary number (bit pattern) to use for the measured height.
+3.5 to +4.5 0100
Table 3.7.1 assumes that the binary numbers are restricted to using 4 bits.
If greater measurement precision is required then more bits must be used, e.g. if Table 3.7.1 Part of conversion
voltage measurement ranges for samples of, say, -0.25 to + 0.25 volts, +0.25 to + table used when measuring a
0.5 volts, etc, are required then more than 4 bits must be used. sample and assigning a binary
number
If less precision is acceptable then fewer bits can be used as shown in Figure 3.7.6.
Figure 3.7.5 shows an enlargement of a measurement ruler that corresponds to Table 3.7.1. The voltage interval
between consecutive binary numbers is 1 volt.
Figure 3.7.6 shows an enlargement of a measurement ruler that uses three bits for sample height measurement and
therefore less precision - difference between consecutive binary numbers is now 2.25 volts.

Figure 3.7.5 Enlargement of a measurement ruler that encodes sampled waveform height using 4 bits

Figure 3.7.6 Enlargement of a measurement ruler that encodes sampled waveform height using 3 bits
3.7 Representing sound

Questions
1 What is meant by saying that sound is analogue in form? Label Stage
Amplitude of waveform measured at a
2 Table 3.7.2 shows five stages in converting sound into A
specific point in time
a digital form.
Converted to an electrical analogue
State the correct order for the five stages using the B
signal
C Binary representation stored
D Microphone picks up sound waves
Amplitude measurement assigned a
E
binary number
Table 3.7.2

Sampling rate
The sampling rate is the number of samples taken in a second and is usually Information
measured in Hertz (1 Hertz = 1 sample per second).
Sound:
For example, the sampling rate used in audio recordings on a Compact Disc
In physics, sound is a
(CD) is 44.1 kHz, i.e. 44100 samples per second (1 kHz = 1000 Hz). vibration that travels as a
This is approximately twice the maximum analogue frequency of 20 kHz of any mechanical wave of pressure
audio signal. (and displacement), through a
medium such as air or water.
A raw, uncompressed, sampling of sound lasting 60 seconds will consist of
In physiology and psychology,
60 x 44100 samples or 2646000 samples.
sound is the reception of such
Digital telephone lines are sampled at a rate of 8 kHz or 8000 samples per waves and their perception by
second, and assume that the maximum analogue frequency present in speech the brain.
carried by a digital telephone line is 4 kHz. Humans can hear sound waves
Therefore, one minute of sampled speech sent along a digital telephone line will with frequencies between about
consist of 20 Hz and 20 kHz. Sound
above 20 kHz is ultrasound.
60 x 8000 samples or 480000 samples.

Questions
3 Digital Audio Tapes (DAT) used a sample rate of 48 kHz to record
sampled audio on magnetic tape. Information
How many samples are taken per second? Audio:
4 Figure 3.7.7 shows 4
Red lines
Audio is sound within the range
sampling of an 3 indicate of frequencies that humans
when can hear. The limits of human
analogue electrical 2 amplitude
is sampled hearing fall within the range, 20
signal from a 1
Voltage/volts

to 20000 Hz.
microphone. 0
11 12 13 14 15 Time/milliseconds
Samples are taken at -1 Audio signal:

time = 0 and every -2 Figure 3.7.7 An audio signal is a


-3 representation of sound,
millisecond from
typically as an electrical voltage.
thereon.
What is the sampling frequency in Hertz?
What is the measured voltage at time = 1 millisecond?
Convert this voltage to binary using Table 3.7.1.
3 Fundamentals of data representation

Sample resolution
Sample resolution is the number of bits allocated to each sample (number of bits per sample).
Each sample sent along a digital telephone line is encoded in 8 bits.
Therefore, a minute of sampled speech will consist of the following number of bits
60 x 8000 x 8 = 3840000 bits
= 480000 bytes
= 480 kB
The audio recorded on CD is of higher quality than speech audio sent along a telephone line. This higher quality is
achieved by allocating more bits per sample, 16 bits, in fact. We say that the sample resolution of audio CDs is 16
bits.
Therefore, a minute of uncompressed sampled sound will consist of the following number of bits
60 x 44100 x 16 = 42336000 bits
Key term
= 5292000 bytes
Sample resolution:
= 5292 kB Sample resolution is the number
= 5.292 MB of bits allocated to each sample
(number of bits per sample).
Questions Sampling rate:
Sampling rate is the number of
5 The sample resolution of a DVD-Audio is 24 bits. samples taken in a second and is
What does this mean? usually measured in Hertz
(1 Hertz = 1 sample per
second).

Calculating sound file sizes


Uncompressed sampled sound may be stored in a file with a format such as Wave or AIFF.
Wave files have the extension WAV (.wav). The Wave file format was created by Microsoft.
Audio Interchange File Format (AIFF) is an audio file format standard developed by Apple Inc and used for storing
sound. The file extension for the standard AIFF format is .aiff or .aif.
To calculate the file size of a Wave or AIFF file (ignoring any metadata) we may use
file size (bits) = sampling rate x sample resolution x number of seconds of recorded sound
For a WAV audio file,
Sampling rate = 44.1 kHz
Sample resolution = 16 bits
Therefore, the file size of a WAV file that stores 5 minutes of sampled sound is calculated as follows
File size (bits) = 44100 x 16 x 5 x 60
= 211680000
File size (bytes) = (44100 x 16 x 5 x 60)/8
= 26460000
File size (megabytes) = (44100 x 16 x 5 x 60)/(8 x 1000000)
= 26.46
3.7 Representing sound

Questions
6 Calculate the file size in bits for a three minute sound recording that has used a sample rate of 1000 Hertz
(Hz) and a sample resolution of 6 bits.

7 The sample resolution of a DVD-Audio is 24 bits. The sampling rate is 48 kHz.


10 minutes of sound recorded in uncompressed sampled form is stored in a file on a DVD-Audio disc.
What is the size in bits of this file?
What is the size in bytes of this file?
What is the size in kilobytes of this file?

In this chapter you have covered:


■ That sound is analogue and that it must be converted to a digital form for storage and processing in a computer
■ That analogue signals are sampled to create the digital version of sound
■ Describing the digital representation of sound in terms of:
• sampling rate
• sample resolution
■ Calculating sound file sizes based on the sampling rate and the sample resolution.
3 Fundamentals of data representation
3 Fundamentals of data representation
Learning objectives:
■ Explain what data
compression is ■ 3.8 Data compression
■ Understand why data may be What is data compression and why compress?
compressed and that there are
different ways to compress data Essentially, data compression squeezes data into a
■ Explain how data can be smaller number of bytes than the data would occupy if
compressed using Huffman not compressed.
coding
There are two main reasons why data are compressed:
■ Be able to interpret/create
Huffman trees • To reduce the amount of storage space required
■ Be able to calculate the to store the data
number of bits required to • To reduce the time taken to transmit the data
store a piece of data compressed because fewer bytes need to be transmitted.
using Huffman coding
For example, text may be compressed by replacing each common character/
■ Be able to calculate the
letter combination with a single byte-coded integer number as in Table 3.8.1.
number of bits required to
store a piece of uncompressed Character
data in ASCII Integer Code
■ Explain how data can be
Combination
compressed using run length
1 ‘TH’
encoding (RLE) 2 ‘BL’
■ Represent data in RLE 3 ‘CK’
frequency/data pairs. 4 ‘AT’
5 ‘ON’
Key principle Table 3.8.1 Codes for common character combinations
Compression:
Data can be compressed because Uncompressed text = "THE BLACK CAT SAT ON A MAT."
its original representation is
Compressed text = "1E 2A3 C4 S4 5 A M4."
not the shortest possible. The
original data has redundancies If each character in the uncompressed text is coded in one byte (including
(redundancy = not needed) and spaces and full stop) then this text requires 27 bytes of storage.
compressing the data reduces or For the compressed text the storage requirement is just 20 bytes, a saving of
eliminates these redundancies,
seven bytes. This represents a 26% saving, approximately.
e.g. "AT" is replicated three
times in the text “THE BLACK This example is just one way that data may be compressed.
CAT SAT ON A MAT.”. There are other ways depending on the type of data (text, images, audio, etc).
Non-random data is non- Each method of data compression works best with a particular data type.
random because it has structure
Although we used the term “squeeze”, compressing data is not actually done
in the form of regular patterns.
It is this structure that is the by squeezing data, but by removing any redundancy (unnecessary data
cause of redundancy in the duplication).
data. Random data has no Data with redundancy can be compressed by removing some or all of the
structure and therefore has no
redundancy.
redundancy. Therefore, random
Data without any redundancy cannot be compressed without loss of
data cannot be compressed.
information.
3 Fundamentals of data representation

Questions
1 What does it mean to compress data?
2 Give two reasons why data are compressed.
3 Why is it possible to compress data that has structure without losing information?
4 Give two reasons why it is desirable to compress data.

Huffman coding
Fixed-size coding versus variable-size coding
Before a computer can store and process data, the data must be expressed in the
language of the computer, i.e. binary (0s and 1s).
Figure 3.8.1 shows an upside down tree which can be used to encode data in
numeral form chosen from the range 0 to 7.
For example, the numeral 3, is encoded as 011 as shown in Figure 3.8.3 by
following the instructions
Figure 3.8.2 Upside down Root
• Start at root 0 1
tree with root at top, and
leaves at the bottom • Take route along branches to 0 1 0 1
numeral 0 1 0 1 0 1 0 1
Numeral Code
• Note each red numeral in the order 0 1 2 3 4 5 6 7
0 000 encountered, 011. Leaves
1 001 Figure 3.8.1 Coding tree
2 010 Table 3.8.2 shows the codes for the Root
3 011 numerals 0 to 7. 0 1
4 100
This is a fixed-size coding scheme with 0 1 0 1
5 101
each numeral encoded using a binary 0 1 0 1 0 1 0 1
6 110
7 111
digit string of length 3. 0 1 2 3 4 5 6 7
Leaves
Table 3.8.2 Codes for the Using a fixed-size code is a natural choice Figure 3.8.3 Coding tree
numerals 0 to 7 because it makes it easy for software
applications to handle.
For example, we could use this encoding scheme to encode strings such as
22220000011116634557711112222000
Numeral Code
0 00 However, this is not normally the best option for encoding strings in which
1 01 some numerals occur more often than others.
2 10 In such cases, it is normally better to use a variable-size coding scheme.
3 11000
4 11001
Suppose the numerals 0, 1, 2 occur with the same frequency but more
5 1101 frequently than the numerals 3, 4, 5, 6, 7 and numerals 5, 6 and 7 occur with
6 1110 the same frequency but more frequently than 3 and 4 which occur with the
7 1111 same frequency as each other.
Table 3.8.3 Codes for the To take into account the difference and similarity in frequency of occurrence, a
numerals 0 to 7 shorter code can be allocated to 0, 1 and 2 as shown in Table 3.8.3 and longer
codes for 3, 4, 5, 6 and 7 according to their comparative frequency.
3.8 Data compression

Figure 3.8.4 shows the coding tree for this variable-size coding scheme.
Table 3.8.4 shows that fewer bits are required to encode the given numeral strings when the coding tree for
variable-size codes is used instead of the coding tree for fixed-size codes.

Coding Root
Numeral string Binary-coded strings 0 1
scheme
1010101000000000000101010111 1
2222000001111663 Variable-size 0 1 0
101110110001100111011101111111
4557711112222000 coding
110101010110101010000000 0 1 2 0 1
0100100100100000000000000000
0 1 0 1
2222000001111663 Fixed-size 01001001001110110011100101101
0 1 5 6 7
4557711112222000 coding 11111100100100100101001001001
0000000000 3 4

Table 3.8.4 Comparison of fixed-size and variable-size coding Figure 3.8.4 Coding tree for
scheme that uses variable-size
Compressing text
codes
A common form of data is text.
In meaningful English text, some letters such as “e”, “a”, and “t” occur often, whilst some letters such as “q” and “z”
occur less often. This suggests that text could be compressed by using variable-size coding.
One binary coding scheme commonly used by computers is ASCII, a fixed-size code of 7 bits. Unicode is another.
Text encoded in ASCII is likely to contain redundancy because it assigns to each character, common or rare, the
same number of bits.
The solution is to remove this redundancy by assigning variable-size binary codes to the characters.
Common characters are assigned short binary codes and less common characters, long binary codes.
This is precisely how Huffman coding works.
We have seen Huffman coding in action already in the coding scheme shown in Figure 3.8.4.
To understand how short codes and long codes can be assigned to text consider the following simple example.
The words referee, freeze, reefer suggest a possible Huffman coding tree as
shown in Figure 3.8.5. Figure 3.8.6 shows a tree built for fixed-size coding. 0 1

Table 3.8.5 shows that Huffman coding produces fewer bits than fixed-size e
0 1
coding when coding these words. Later you will see that this saving in bits
can be considerable when the fixed-size coding uses ASCII coding.
0 1

Word Coding scheme Binary-code f z


referee Huffman coding 10 0 110 0 10 0 0 Figure 3.8.5 Huffman coding tree
referee Fixed-size coding 01 00 10 00 01 00 00
freeze Huffman coding 110 10 0 0 111 0
0 1
freeze Fixed-size coding 10 01 00 00 11 00
reefer Huffman coding 10 0 0 110 0 10
reefer Fixed-size coding 01 00 00 10 00 01 0 1 0 1
Table 3.8.5 Comparison of fixed-size and Huffman coding
e r f z
Figure 3.8.6 Fixed-size coding tree
3 Fundamentals of data representation

Questions
5 By definition, random data is data in which each datum occurs just as often as any other datum.
Can random data be compressed?

6 Using the Huffman coding tree shown in Figure 3.8.5, encode the following words
(a) reef (b) freer (c) refreeze
7 Using the Huffman coding tree shown in Figure 3.8.5, decode the binary code 110100010.

Table 3.8.6 shows a Huffman code based on statistical analysis of English language texts for the 26 letters of the
alphabet.
The length of the code depends upon how often the letter appears in English text. The shortest code (3 bits) is
assigned to the letter "e", the most common letter, and the longest code (7 bits) is assigned to the least common,
letters "q" and "z".

Letter Huffman Code Letter Huffman Code Letter Huffman code


a 0011 j 111100 s 10001
b 11010 k 111101 t 0010
c 10100 l 10011 u 10101
d 10010 m 10110 v 11101
e 000 n 0101 w 11011
f 10111 o 0100 x 111110
g 11100 p 11000 y 11001
h 10000 q 1111110 z 1111111
i 0111 r 0110

Table 3.8.6 A Huffman code for the 26 letters of the alphabet

Questions
8 (a) Using 7-bit ASCII, calculate the number of bits required to encode the vowel string "aeiou".
Using the Huffman code in Table 3.8.6, calculate the number of bits required to encode the vowel
string “aeiou”.
Calculate the difference in number of bits between the two coding methods.

Worked example of a Huffman tree constructed from specific text


Context
Figure 3.8.7 shows a Huffman tree for the text TESS SAW A RAT UP A
TREE. SPACE

Each character of this text has been placed at a position in the tree determined A E S T

by how often the character is used in the text. R P U W


Using this Huffman tree, the Huffman coding for the character E would be Figure 3.8.7 Huffman tree
the bit pattern 010 because from the top of the tree E is to the left, then right and then left.
The character S is represented by the bit pattern 110 because from the top of the tree S is to the right, then right
again and then left.
3.8 Data compression

Question Huffman
Word
Using Huffman code defined by the tree in Figure 3.8.7, complete Table 3.8.7 to coding
show the Huffman coding for the characters A, SPACE and U. A
SPACE
Solution U
Starting from the top of the tree, the character A is reached by going left, then left Table 3.8.7 Huffman coding
again and left again. A is therefore represented by 000.
Starting from the top of the tree, the SPACE character is reached by going right, then left.
SPACE is therefore represented by 10. Huffman
Word
coding
Starting from the top of the tree, the character U is reached by going left, then right,
A 000
then right again and finally left. U is therefore represented by 0110.
SPACE 10
Question U 0110
Using Huffman coding, the text TESS SAW A RAT UP A TREE can be stored in Table 3.8.8 Huffman coding
71 bits. solution

Calculate how many additional bits are needed to store the same text using ASCII. Show your working.
Solution
Each character is coded in 7 bits using 7-bit ASCII.
There are 24 characters in the text including the SPACE character.
Therefore, using ASCII, the total number of bits = 24 x 7 = 168 bits
An additional 97 bits are therefore required.

Questions
9 Figure 3.8.8 shows a Huffman tree for the text MY PET BEE HAS NAME MANNY.
Each character of this text has been placed at a position in the
tree determined by how often the character is used in the text.
Using this Huffman tree, the Huffman coding for the
character E would be the bit pattern 010 because from the top SPACE
of the tree E is to the left, then right and then left. A E M N
The character M is represented by the bit pattern 110 because
from the top of the tree M is to the right, then right again and S Y Figure 3.8.8
then left. B H P T
(a) Using Huffman code defined by the tree in Figure 3.8.8, complete the Huffman
Word
table to show the Huffman coding for the characters N, SPACE and P. coding
N
(b) Using Huffman coding, the text MY PET BEE HAS NAME MANNY SPACE
can be stored in 81 bits. P

Calculate how many additional bits are needed to store the same text using ASCII. Show your working.
3 Fundamentals of data representation

Constructing a Huffman tree (this section is not in 8525 specification but has been included for interest)
For the word refreeze the letters occur with the frequencies shown in Table 3.8.9.
Letter Frequency
Table 3.8.10 shows these frequencies expressed as a fraction of the total number (4
e 4
+ 2 + 1 + 1 = 8). We call this the probability of a particular letter appearing in the
r 2
set of words, e.g. the letter 'e' has probability 0.5. f 1
To create a Huffman coding tree for the letters with the probabilities shown in z 1
Table 3.8.10, we arrange the letters in descending order of probability as shown in Table 3.8.9 Letter frequencies
Figure 3.8.9.
Letter Frequency
We then start from the left with the two letters with the lowest probabilities.
e 4/8 = 0.5
We link these as shown into a new node 'fz' and from now on, we ignore nodes 'f'
r 2/8 = 0.25
and 'z'.
f 1/8 = 0.125
We also note that the probability of finding 'f' or 'z' is 0.125 + 0.125 = 0.25. z 1/8 = 0.125
We now combine the nodes with the two
Table 3.8.10 Letter frequencies
lowest probabilities, i.e. 'r' and 'fz' into a
e
new node ‘rfz'.
We note that the probability of finding 'r' 0
or ‘f ’ or 'z' is 0.25 + 0.25 = 0.5. 1
0.25
From now on, we ignore nodes 'r' and 'fz'.
0 1
We now combine the nodes with the two
lowest probabilities, i.e. 'rfz' and 'e' into a
0.125
new node 'erfz'.
0 1
We note that the probability of finding 'e' 0.25
or 'r' or 'f' or 'z' is 0.5 + 0.5 = 1.
1 in text shown in black
0.125
Now, we assign 0 to each upper branch
and 1 to each lower branch as shown
z
in Figure 3.8.9. We could equally have Figure 3.8.9 Construction of Huffman tree from letter probablities
chosen to do the opposite and assigned 1 to the upper branch and 0 to
0 1
the lower. It is quite arbitrary which labelling is used. Figure 3.8.9 now
translates into the Huffman coding tree shown in Figure 3.8.10. e
0 1
We could have set up Figure 3.8.9 with 'f' and 'z' swapped around since
both have letter probability 0.125. This would mean that 'f' and 'z' would 0 1
have to swap positions in the Huffman tree in Figure 3.8.10.
However, this would make no difference to the average size of the code f z
which is given by the following calculation: Figure 3.8.10 Huffman coding tree

Letter 'e' occurs with probability 0.5 and requires 1 bit to encode, so contributes 0.5 x 1.
Letter 'r' occurs with probability 0.25 and requires 2 bits to encode, so contributes 0.25 x 2.
Letter 'f' occurs with probability 0.125 and requires 3 bits to encode, so contributes 0.125 x 3.
Letter 'z' occurs with probability 0.125 and requires 3 bits to encode, so contributes 0.125 x 3.
Therefore, average size of code = 0.5 x 1 + 0.25 x 2 + 0.125 x 3 + 0.125 x 3 = 1.75 bits/letter.
With four letters, the minimum uncompressed code would require 2 bits/letter.
3.8 Data compression

Questions Letter Frequency


10 (a) Create a Huffman coding tree for the letters shown in Table 3.8.11. e 1/3
(b) What is the average size of code? Show your working. a 1/4
d 1/6
11 (a) Create a Huffman coding tree for the letters Letter Frequency
n 1/6
shown in Table 3.8.12. A 1/30
b 1/12
B 1/30
(Note that there is more than one possible tree).
C 1/30 Table 3.8.11 Letter frequencies
(b) What is the average size of code? D 2/30
Show your working. E 3/30
Candidates are not required F 5/30
G 5/30
to know how to create a
H 12/30
Huffman tree.
Table 3.8.12 Letter frequencies

Run length encoding (RLE)


In run length encoding a run of contiguous bytes all with the same value can be condensed into two bytes, one
byte that stores the count (or run length) and a second byte that stores the value in the run.
These two bytes are sometimes called a frequency/data pair.
Figure 3.8.11 shows run length Run of 6 bytes 2 bytes
encoding applied to a run of six 128 128 128 128 128 128 6 128
contiguous bytes each of value 128. The
Figure 3.8.11 Run length encoding compression of 6 bytes into 2 bytes
amount of data stored is reduced from 6
bytes to 2 bytes by this data compression method. Information
RLE can be used to compress bitmap images. Contiguous:
Means next to each other or
Each run of pixels of the same colour is encoded as a frequency/data pair (run together in sequence.
length/pixel colour value).
The following example shows how RLE could be applied to a bitmap that encodes the intensity of each pixel in 8
bits and that starts with the sequence
15, 15, 15, 15, 15, 15, 15, 15, 46, 81, 123, 58, 98, 98, 98, 98, 7, 7, 7, 8, ...
The compressed sequence of bytes is
8, 15, 1, 46, 1, 81, 1, 123, 1, 58, 4, 98, 3, 7, 1, 8, ...
where the red values indicate counts.
The original 20 bytes in the example have been reduced to 16 bytes.
Example
Black and white images such as shown in outline in Figure 3.8.12 can be
encoded using 1 to represent a white pixel and 0 to represent a black pixel.
The two-dimensional grid of pixels making up a black and white image may then
be represented in a bitmap by rows of 0s and 1s, one row per pixel row.
The ellipsis symbol ⃛ indicates more black or white pixels. Figure 3.8.12 Part of a black
Suppose a row of this bitmap consists of the following run of 0s and 1s and white image made up of
00000001111111111110000001111111 rows of pixels
3 Fundamentals of data representation

Using run length encoding this row becomes


7 0 12 1 6 0 7 1

This is a simplification because the amount of storage space allocated to each frequency/data pair has been ignored.

Questions
12 Bit patterns are often compressed.
Compress the following bit pattern using run length encoding.
1111 0000 0111 0000 0001 1111

In this chapter you have covered:


■ What data compression is
■ Why data may be compressed and that there are different ways to compress data
■ How data can be compressed using Huffman coding
■ Interpreting and creating Huffman trees
■ Calculating the number of bits required to store a piece of data compressed using Huffman coding
■ Calculating the number of bits required to store a piece of uncompressed data in ASCII
■ How data can be compressed using run length encoding (RLE)
■ Representing data in RLE frequency/data pairs.
4 Computer systems
4 Computer systems
Learning objectives:
■ Define the terms hardware
and software and understand
■ 4.1 Hardware and software
the relationship between them. What is hardware?
The hardware of a computer is the physical components, electronic and
electrical, that it is assembled from. It is the platform on which software
Key concept executes.

Hardware:
What is software?
The hardware of a computer Software consists of sequences of instructions called programs which can be
is the physical components, understood and executed by the hardware in its digital electronic circuits or a
electronic and electrical, that virtual machine equivalent.
it is assembled from. It is the
platform on which software
executes.
Questions
1 What is meant by hardware?

2 What is meant by
Key concept
Software:
Consists of sequences of
instructions called programs
which can be understood and
In this chapter you have covered:
executed by the hardware in its
digital electronic circuits or a ■ The terms hardware and software and the relationship between them.
virtual machine equivalent.
4 Computer systems
4 Computer systems


Learning objectives:
■ Construct truth tables for the 4.2 Boolean logic
following logic gates: Background to logic gates
• NOT An electrical circuit such as shown in Figure 4.2.1 is made with wires, a switch,
batteries and lamps.
• AND
When the switch labelled X is closed the lamp Q is lit (ON) and when X is
• OR
open, the lamp Q is not lit (OFF).
• XOR
■ Construct truth tables for Switches Q
simple logic circuits using
combinations of NOT, AND, X
Lamp
OR and XOR gates

■ Interpret the results of simple


truth tables
Battery
■ Create, modify and interpret
Figure 4.2.1 Simple electrical circuit
simple logic diagrams

■ Create and interpret simple Questions


Boolean expressions made up
1 Switch X has two possible positions, open or closed.
of NOT, AND, OR and XOR
What position must the switch be in for the lamp Q to be lit?
operations

■ Create the Boolean expression


for a simple logic circuit Table 4.2.1 shows the possible states of lamp Q for the two possible states of
■ Create a logic circuit from a switch X.
simple Boolean expression.
State of switch X State of lamp Q
OPEN OFF
CLOSED ON
Table 4.2.1 Possible states of switch X and lamp Q

It is more convenient to express the possible states of switch X by answering


the question: “Is switch X closed?”. Table 4.2.2 shows the possible answers
expressed using values NO and YES.

Is switch X closed? Meaning


NO Switch X is not closed
YES Switch X is closed
Table 4.2.2 Possible answers to the question
4 Computer systems

The corresponding question for lamp Q is “Is lamp Q on?”. Is lamp Q on? Meaning
Table 4.2.3 shows the possible answers expressed using values NO Lamp Q is not on
NO and YES. YES Lamp Q is on
Table 4.2.3 Possible answers to the question

Questions
2 Figure 4.2.2 shows an electrical circuit with two switches X
and Y, and one lamp Q.
Copy and complete Table 4.2.4 by writing YES or NO in
the blank rows.
Is switch X closed? Is switch Y closed? Is lamp Q on?
NO NO NO

Figure 4.2.2
Table 4.2.4

Truth tables
Now we move from questions to statements which are either true or false.
If the statement “Switch X Closed” is true for the circuit shown in Figure 4.2.1 then the statement “Lamp Q On”
is true.
If the statement “Switch X Closed” is false for the circuit shown in Figure 4.2.1 then the statement “Lamp Q On”
is false.
Switch X Closed Lamp Q On
This is summarised for the circuit if Figure 4.2.1 in a truth table as
FALSE FALSE
shown in Table 4.2.5.
TRUE TRUE
Truth tables deal with statements considered either true or false.
Table 4.2.5

Questions
3 Figure 4.2.3 shows an electrical circuit with two switches X
and Y, and one lamp Q.
Copy and complete Table 4.2.6 by writing TRUE or
FALSE in the blank rows.
Switch X Closed Switch Y Closed Lamp Q On Lamp
FALSE FALSE FALSE

Figure 4.2.3

Table 4.2.6
4.2 Boolean logic

Logic gates
Output
You must be able to construct truth tables for NOT, AND, OR and XOR logic gates circuit

and simple logic gate circuits as well as be able to create, modify and interpret simple 1
2
logic gate circuit diagrams. However, you are not required to know or understand the 3
4
various technologies from which logic gates are constructed. Input
circuit Electromagnet
NOT logic gate 5

Consideration of one technology from the past may, however, make the use of logic Relay
gates easier to accept. For this reason, we will consider how a particular logic gate called Figure 4.2.4
a NOT gate can be made using relay technology.
A relay uses an electromagnet to close or open a switch in an “output” circuit depending on how the output circuit
is wired to the relay. Figure 4.2.4 shows a relay in which the output circuit is wired between poles 1 and 2 of the
relay. The output circuit could equally well have been wired between poles 1 and 3.
If the electromagnet is energised, its iron core becomes magnetic, which in turn pulls on the flexible metal contact
moving it away from pole 2 and into contact with pole 3. Whereupon, the output circuit becomes disconnected if
connected between poles 1 and 2 and vice versa if connected between poles 1 and 3.
Figure 4.2.5 shows an output circuit which is connected between poles 1 and 2. On the input circuit side, poles 4
and 5 connect the electromagnet of the relay to a battery and a single switch X.

Battery Lamp Battery Lamp


Q

Battery energised
Battery

(a) (b)
Figure 4.2.5

In Figure 4.2.5(a), switch X is open in the input circuit and switch Y in the output circuit is in the position which
connects the battery to lamp Q. The lamp is lit.
In Figure 4.2.5(b), switch X is closed in the input circuit and switch Y in the output circuit is in the position which
disconnects the battery from lamp Q. The lamp is not lit.
Table 4.2.7 shows the truth table for the operation of the circuit shown in Figure 4.2.5.

Switch X Closed Lamp Q On


FALSE TRUE
TRUE FALSE
Table 4.2.7 Truth table for circuit shown in Figure 4.2.5
We simplify this truth table as shown in Table 4.2.8. What is of interest is whether there is current flowing in the
input circuit (TRUE or FALSE) and similarly, whether there is current flowing in the output circuit (TRUE or
FALSE.
Input Output
FALSE TRUE
TRUE FALSE
Table 4.2.8 Simplified truth table for circuit shown in Figure 4.2.5
4 Computer systems

Figure 4.2.6 shows the relay circuit used in Figure 4.2.5 rejigged with the relay and battery used in the output
circuit partially obscured in a red/blue box. Switch X has been replaced by a switch that can connect to the 5 volts
terminal of a battery used to energise the electromagnet or its 0 volts terminal to remove its energy supply.

1 1
2 2
3 3
4 4
5 volts 5 volts Q 5 volts 5 volts Q
Input Output Input Output
0 volts 0 volts circuit 0 volts 0 volts circuit
5 5

(a) (b)
Figure 4.2.6
Table 4.2.9 shows an alternative representation within the truth table,
Input Output
one which uses voltages with 5 volts corresponding to TRUE and 0 volts
0 volts 5 volts
corresponding to FALSE (the two voltages just have to be sufficiently 5 volts 0 volts
different to be distinguishable).
Table 4.2.9 Truth table for circuit
If we let binary 1 stand for 5 volts or any energising voltage and binary 0 for shown in Figure 4.2.6
0 volts then Table 4.2.9 can be simplified to the representation shown in Table 4.2.10.

The circuit at the heart of Figure 4.2.6 is called a NOT logic gate. It is also shown Input Output
in Figure 4.2.7(a). 0 1
1 0
Table 4.2.10 is the truth table for this NOT gate.
Table 4.2.10 Truth table for
Figure 4.2.7(b) shows the equivalent ANSI/IEEE standard 91-1984 standard circuit shown in Figure 4.2.6
symbol for a NOT gate.
Figure 4.2.8 shows this NOT gate symbol being used in a circuit. Figure 4.2.9 shows all that is needed to
understand the effect of the NOT gate on its input. Figure 4.2.10 shows the input generalised to X and the output
to Q. Table 4.2.11 shows the truth table for a NOT gate in terms of input X and output Q.

1
2 5 volts
3
4

0 volts
5

(a) (b)
Figure 4.2.7

0 1 5 volts

0 volts
Figure 4.2.9
1 0
X Q Figure 4.2.8

X Q
Figure 4.2.10 NOT gate with input 0 1
X and output Q 1 0
Table 4.2.11 Truth table for NOT gate
4.2 Boolean logic

AND logic gate 5 volts


Another logic gate is the AND gate. This has two inputs and one AND gate
output as shown in Figure 4.2.11. The lamp is lit because both
inputs are connected to 5 volts otherwise the lamp would not be lit. 0 volts

Its truth table is shown in Table 4.2.12 with one particular ordering
of rows. Figure 4.2.12 shows its IEEE logic gate symbol. 5 volts

0 volts
X Y X AND Y
0 0 0 0 volts
0 1 0 Figure 4.2.11 AND logic gate with
1 0 0 inputs X and Y, and output Q
1 1 1
Figure 4.2.12 AND logic gate
Table 4.2.12 Truth table for AND logic gate IEEE symbol
with inputs X and Y and output X AND Y
5 volts
OR logic gate
OR
Another logic gate is the OR gate. This has two inputs and one output
as shown in Figure 4.2.13. The lamp is lit because at least one input is 0 volts
connected to 5 volts otherwise the lamp would not be lit.
5 volts
Its truth table is shown in Table 4.2.13 with one particular ordering of
rows. Figure 4.2.14 shows its IEEE logic gate symbol. 0 volts

0 volts
X Y X OR Y
Figure 4.2.13 OR logic gate with
0 0 0
0 1 1
inputs X and Y, and output Q
1 0 1 Figure 4.2.14 OR logic gate
1 1 1 IEEE symbol
Information
Table 4.2.13 Truth table for OR logic gate You may experiment with virtual logic gates
with inputs X and Y, and output X OR Y using an online simulator at
[Link]
XOR logic gate
Another logic gate is the eXclusive-OR or XOR gate. This has two 5 volts

inputs and one output as shown in Figure 4.2.15. The lamp is lit if X is
connected to 5 volts and Y is connected to 0 volts or if X is connected
0 volts
to 0 volts and Y is connected to 5 volts. However, if both X and Y are 0
volts or 5 volts, the lamp is not lit. 5 volts
Its truth table is shown in Table 4.2.14 with one particular ordering of
0 volts
rows. Figure 4.2.16 shows the logic gate symbol used by AQA.
0 volts
X Y X XOR Y Figure 4.2.15 XOR logic gate with
0 0 0 inputs X and Y, and output Q
0 1 1
Information
1 0 1
1 1 0 Figure 4.2.16 XOR logic gate
Table 4.2.14 Truth table for XOR logic gate AQA symbol
with inputs X and Y, and output X XOR Y
4 Computer systems

Questions
X Y Q X Y Q
4 Identify the logic gate with inputs X and Y, and output Q
1 1 1 1 1 1
whose truth table is shown in Table 4.2.15. 0 0 0 0 0 0
1 0 0 1 0 1
5 Identify the logic gate with inputs X and Y, and output Q 0 1 0 0 1 1
whose truth table is shown in Table 4.2.16.
Table 4.2.15 Table 4.2.16
X Y Q
6 Identify the logic gate with inputs X and Y, and output Q 1 1 0
whose truth table is shown in Table 4.2.17. 0 0 1
1 0 1
0 1 0

Table 4.2.17

Constructing truth tables for simple logic circuits


Figure 4.2.17 shows a simple logic gate circuit consisting of an AND gate
X Q
and a NOT gate.
You are required to be able to construct truth tables which contain up to B
three inputs. In Figure 4.2.17, A and B are inputs, X is an intermediate Figure 4.2.17 Logic gate circuit
value which forms the input to the NOT gate.
A B X Q
Its truth table is shown in Table 4.2.18. The inputs to the AND gate are A and B. The 0 0 0 1
output X from the AND gate forms the input X to the NOT gate. The output from 0 1 0 1
the NOT gate is labelled Q. 1 0 0 1
1 1 1 0
Figure 4.2.18 shows another logic gate circuit consisting of an OR gate, an AND gate
and a NOT gate. A Table 4.2.18
X
Its truth table is shown in Table 4.2.19. The inputs Y Q
to the OR gate are A and B. The output X from
the OR gate forms the first input to the AND gate. Figure 4.2.18 Logic gate circuit
B
The second input to this AND gate comes from B.
A B X Y Q
The output from the AND gate is labelled Y.
0 0 0 0 1
This forms the input Y to the NOT gate. 0 1 1 1 0
The output from the NOT gate is labelled Q. 1 0 1 0 1
A B C X Q
1 1 1 1 0
Figure 4.2.19 shows a logic gate 0 0 0 0 0
Table 4.2.19 0 0 1 0 0
circuit with three inputs A, B and X 0 1 0 0 0
C. B Q
0 1 1 0 0
Its truth table is shown in Table C 1 0 0 0 0
4.2.20. It has eight rows since there Figure 4.2.19 Logic gate circuit 1 0 1 0 0
are eight possible different combinations of 1 1 0 1 0
three inputs, each input consisting of 0 or 1. 1 1 1 1 1

The inputs to the first AND gate are A and B. The output X from this AND gate forms Table 4.2.20
the first input to the second AND gate. The second input to this AND gate is C. Its output is Q.
4 Computer systems

Questions
7 Complete the truth table shown in Table 4.2.21 for the logic gate circuit shown in Figure 4.2.20.

A B X Y Q
X Y
Q 0 0
0 1
1 0
B 1 1
Table 4.2.21
Figure 4.2.20 Logic gate circuit

Creating logic gate circuits


You are expected to be able to construct simple logic circuit diagrams which contain up to three inputs.
Consider the following example for which the specification is as follows:

A logic circuit is being developed for an automatic alarm system protecting a store room:
The alarm system has two sensors, sensor A and sensor B. Sensor A is activated if the front door to the store
room is open. Sensor B is activated if the back door to the store room is open.
The alarm system can be turned on/off using a manual switch, S. The alarm system is not enabled unless S is
on.
The alarm is to sound if either door or both are open and the manual switch is on otherwise the alarm is to be
silent.
The output from this logic circuit is Q.

Complete the logic circuit diagram shown in Figure 4.2.21 for this system:

B Q

S
Figure 4.2.21 Logic gate circuit

The way to tackle a logic circuit design problem is to


• identify the inputs
• identify the output
• look for the following keywords/key phrases
♦ Either ... or
♦ Or both
♦ But not both
♦ And
♦ And both
♦ Not
4.2 Boolean logic

In the given alarm system specification we can identify:

“The alarm is to sound if either door or both are open”,


“Sensor A is activated if the front door to the store room is opened”,
B
“Sensor B is activated if the back door to the store room is opened”.
Figure 4.2.22
This suggests an OR logic gate with inputs A and B as shown in Figure 4.2.22.
When sensor A is activated its output is 1 otherwise its output is 0.
When sensor B is activated its output is 1 otherwise its output is 0.
X
“The alarm is to sound if either door or both are open and the manual switch is on
otherwise the alarm is to be silent”. S Q
When the switch S is on its output is 1 otherwise its output is 0.
Figure 4.2.23
This suggests an AND logic gate with inputs X and S as shown in Figure 4.2.23.

The solution is therefore obtained by combining these two logic circuits as shown in Figure 4.2.24.

A
B Q
S
Figure 4.2.24

Questions
8 A logic circuit is being developed for an automatic plant watering system:
• The plant watering system has two sensors, sensor A and sensor B. Sensor A is activated when the
soil in the plant pot is dry. Sensor B is activated when the light level is above a threshold value.
• The plant watering system can be turned on/off using a manual switch, S. Plant watering will not
occur unless S is on.
• Plant watering is to occur when the soil is dry and the light level is above the threshold value and the
manual switch is on.
• The output from this logic circuit, for whether plant watering occurs or not, is Q.
Complete a copy of the logic circuit diagram for this system:
A

B Q

S
9 In a cockpit warning system for an aircraft’s landing gear, a warning lamp is lit if the left landing wheel is
up and the right landing wheel is down, or vice versa, otherwise the warning lamp is not lit. Each landing
wheel has its own sensor which senses the wheel’s state and outputs a 0 if the landing wheel is up and a 1 if
it is down. The left landing wheel’s sensor is labelled A and the right wheel’s sensor B. The output from the
logic circuit which performs the warning function is Q.
Complete a copy of the logic circuit diagram for this system:
A
Q
B
4 Computer systems

Questions
10 A logic circuit is being developed to control a motor system:
• The motor can be in one of three possible states at any one moment in time:
♦ Rotating forwards
♦ Rotating backwards
♦ Stopped
• The electric motor system has two sensors, sensor A and sensor B. Sensor A is activated when a
control paddle is in the down position. Sensor B is activated when the control paddle is in the up
position. When the control paddle is in the neutral position, sensor A and sensor B are deactivated.
• The electric motor system can also be turned on/off using a manual switch, S. The electric motor
cannot be on if S is off.
• The motor is to rotate forwards when the control paddle is in the down position and S is on.
• The motor is to rotate backwards when the control paddle is in the up position and S is on.
• The motor is to be stopped if the control paddle is in the neutral position.
• There are two outputs from this logic circuit, U and D. Output U is connected to one side of the
motor and output D is connected to the other side. If U = 1 and D = 0 then the motor rotates
forwards. If U = 0 and D = 1 then the motor rotates backwards. If U and D are both the same, the
motor is stopped. U
Complete a copy of the logic circuit diagram
A
for this system:
S Motor

B
D

11 The following logic circuit consists of inputs X and Y and output Z. X Y Q


X 0 0 1
Z 0 1 1
Y
1 0 1
Modify this circuit so that its new output Q is as shown in Table 1 1 0
4.2.22. Table 4.2.22
12 A logic circuit is being developed for a room protected by an interlocked door system:
• The room is entered by passing through two doors in succession, door A and door B.
• The system must prevent door A and door B from being open at the same time.
• The system has two sensors, sensor X and sensor Y. Sensor X is activated when door A is open.
Sensor Y is activated when door B is open.
• The output from this logic circuit, Q, when activated is used to prevent both doors from being open
at the same time. This is done by making Q active if door A is open and door B is closed or if door B
is open and door A is closed.
• Activated corresponds to logic value 1 and not activated to logic value 0.
Complete a copy of the logic circuit diagram for this system:

Sensor X
Q
Sensor Y
4.2 Boolean logic

Boolean variables
In 1847 George Boole, an English mathematician, introduced a shorthand notation for a system of logic originally
set forth by Aristotle. Aristotle’s system dealt with statements considered either true or false. Here are two examples:
It is sunny today.
Today is Tuesday.
Quite clearly these two statements are either True or False. If today is Wednesday then the statement “Today is
Tuesday” is False. Table 4.2.23 shows the possible outcomes of examining the truth of each statement.
Statement Outcome
It is sunny today False True
Today is Tuesday False True
Table 4.2.23 Possible outcomes for truth of statements
Just as we might use an integer variable G to record the number of goats in a farmer’s field so we can use variable
X as shorthand for “It is sunny today”, and Y for “Today is Tuesday”. The values that G can be assigned are the
natural or counting numbers. For X and Y, we have only two possible values, True or False, to assign. We call X and
Y Boolean variables, after George Boole who introduced this form of algebra called Boolean algebra. Table 4.2.24
shows the Boolean variable equivalent of Table 4.2.23 for “It is sunny today” expressed as Boolean variable X.
Boolean algebra deals with Boolean values that are typically labelled True/False (or 1/0, Yes/No, On/Off).

X
Meaning
(It is sunny today)
False It is not sunny today
True It is sunny today
Table 4.2.24 Boolean variable representation of truth statements
As digital computers rely for their operation on using the binary number system, Boolean algebra can be applied
usefully in the design of the electronic circuits of a digital computer. Using Boolean values 1 and 0 instead of True
and False, True in Table 4.2.24 becomes 1 and False becomes 0 as shown in Table 4.2.25. X = 1 now means that “It
is true that it is sunny today” and X = 0 means “It is not true that it is sunny today”.

X Meaning
0 It is not sunny today
1 It is sunny today
Table 4.2.25 Boolean variable representation of truth statements using
0 in place of False and 1 in place of True

It is then a small step to use Boolean variables to represent the state of components such as switches and indicator
lamps as follows:
• a switch can be either closed (1) or open (0) and
• an indicator lamp can be either on (1) or off (0).
4 Computer systems

Boolean expressions 5 volts

In Figure 4.2.25, the output Q is determined by the operation of the OR OR gate


X
gate on the two Boolean inputs X and Y which may be 0 volts (binary 0) or Q
0 volts
5 volts (binary 1). Y
We can write this as OR(X, Y) or (X OR Y) where OR denotes the 5 volts

operation performed by the OR gate on inputs X and Y. The outcome is Q. 0 volts

However, we can write this another way as a Boolean expression using the 0 volts

Boolean variables X and Y and the OR operator symbol + as follows Figure 4.2.25 OR logic gate with
X+Y inputs X and Y, and output Q

The evaluation of this expression by the OR logic gate produces output X Y X+Y
Q. Writing Q as a Boolean variable we obtain 0 0 0
0 1 1
Q=X+Y
1 0 1
The truth table for this expression is shown in Table 4.2.26. 1 1 1

For AND(X, Y) or (X AND Y) where AND denotes the operation Table 4.2.26 Truth table for the Boolean
performed by the AND gate on inputs X and Y (Figure 4.2.26), we expression X + Y
can write the equivalent expression using the Boolean variables X and 5 volts

Y and the AND operator symbol • as follows AND gate

X•Y
0 volts
The evaluation of this expression by the AND logic gate produces output
Q. Writing Q as a Boolean variable we obtain 5 volts

Q=X•Y 0 volts

The truth table for this expression is shown in Table 4.2.27. 0 volts

In Figure 4.2.27, the output Q is determined by the operation of the Figure 4.2.26 AND logic gate with
inputs X and Y, and output Q
NOT gate on the Boolean input X.
For NOT(X) or (NOT X) where NOT denotes the operation performed by the NOT gate on input X, we can
write the equivalent expression using the Boolean variable X and the NOT operator symbol as X.
The evaluation of this expression by the NOT logic gate produces output Q. Writing Q as a Boolean variable we
obtain
Q=X
The truth table for this expression is shown in Table 4.2.28. X Y X•Y

X 0 0 0
0 1 0
5 volts Q 1 0 0
1 1 1
0 volts Table 4.2.27 Truth table for the Boolean
Figure 4.2.27 NOT logic gate expression X • Y
with input X and output Q
X X
0 1
5 volts
1 0

0 volts Table 4.2.28 Truth table for the


Boolean expression X
4.2 Boolean logic

For XOR(X, Y) or (X XOR Y) where XOR denotes the operation 5 volts

performed by the XOR gate on inputs X and Y (Figure 4.2.28), we can XOR gate
X
write the equivalent expression using the Boolean variables X and Y and Q
0 volts
the XOR operator symbol ⊕ as follows Y
X⊕Y
5 volts
The evaluation of this expression by the XOR logic gate produces output 0 volts
Q. Writing Q as a Boolean variable we obtain
0 volts
Q=X⊕Y Figure 4.2.28 XOR logic gate with
The truth table for this expression is shown in Table 4.2.29. inputs X and Y, and output Q

X Y X⊕Y
0 0 0
Examples 0 1 1
Ex1: We may write the expression (NOT A) AND (NOT B) using operator notation 1 0 1
as follows 1 1 0
A.B
Table 4.2.29 Truth table for
(For convenience, the • operator is just written as .) Boolean expression X ⊕ Y

Figure 4.2.29 shows the equivalent logic gate circuit for the Boolean expression A . B

Information
A Writing A • B as A.B or AB
We can write A • B as A.B
A B We can even omit the •
operator and write the Boolean
variables one after another, e.g.
B B A • B as AB.

Figure 4.2.29 The equivalent logic circuit for the Boolean expression A . B

Ex 2: We may write the expression (A AND B) OR (NOT C ) using operator notation as follows

(A . B) + C
Figure 4.2.30 shows the equivalent logic gate circuit for this Boolean expression

A
B
Q

Figure 4.2.30 The equivalent logic circuit for the Boolean expression (A . B) + C
4 Computer systems

Ex 3: We may write the expression (A AND B) OR (A AND C ) using operator notation as follows
A.B + A.C
Figure 4.2.31 shows the equivalent logic gate circuit for this Boolean expression

A
B
Q
A
C
Figure 4.2.31 The equivalent logic circuit for the Boolean expression A.B + A.C

Ex 4: We may write the expression (A AND (NOT B)) OR ((NOT A) AND B ) using operator notation as follows
(A • B) + (A • B)
Figure 4.2.32 shows the equivalent logic gate circuit for this Boolean expression

A
B
Q

Figure 4.2.32 The equivalent logic circuit for the Boolean expression A • B + A • B

Questions
13 Write the Boolean expression for the following
(a) ((NOT A) OR B) AND (A OR (NOT B) ) (b) ((NOT A) AND (NOT B)) OR (A AND B)

(c) (A XOR B) AND C (d) NOT(A AND B)

(e) NOT((A AND B) OR (A AND C))

14 Write the Boolean expression for the logic circuit B


C
shown in Figure 4.2.33.
AB Figure 4.2.33 Logic circuit
15 Write the Boolean expression for the logic circuit
shown in Figure 4.2.34.

16 Draw the logic circuit for the Boolean expression


(a) A ⊕ B (b) A + (B + C)

(c) (A . B) + (A . C) (d) (A + B) . (A + C)

Figure 4.2.34 Logic circuit


4.2 Boolean logic

In this chapter you have covered:


Logic gate Symbol Truth table
■ Truth tables for the following logic gates:
• NOT X NOT X
• AND 0 1
• OR 1 0

• XOR
X Y X AND Y
■ Constructing truth tables for simple logic 0 0 0
circuits using combinations of NOT, AND 0 1 0
AND, OR and XOR gates 1 0 0
■ Interpreting the results of simple truth 1 1 1

tables
X Y X OR Y
■ Creating, modifying and interpreting
0 0 0
simple logic diagrams.
0 1 1
■ Creating and interpreting simple Boolean 1 0 1
expressions made up of NOT, AND, OR 1 1 1
and XOR operations. Using the following
symbols X Y X XOR Y
• • or . to represent AND gate 0 0 0

• + to represent OR gate XOR 0 1 1


1 0 1
• ⊕ to represent XOR gate
1 1 0
• Overbar or to represent the NOT gate
■ Creating the Boolean expression for a simple logic circuit
■ Creating a logic circuit from a simple Boolean expression.
4 Computer systems
4 Computer systems
Learning objectives:
■ Explain what is meant by:
• system software ■ 4.3 Software classification
• application software Computer software may be classified as follows:
■ Give examples of both types of 1. The system programs (or system software), which control the operation of
software the computer itself, e.g. the operating system.
■ Understand the need for, and 2. The application programs (or application software), which solve problems
functions of, operating systems
for their users, e.g. constructing a letter using word processing software for
(OS) and utility programs
printing and sending to someone.
■ Understand that the OS
What is system software?
handles management of the:
• processor(s) A computer system uses a layer or layers of software to enable users to operate
the computer without having to be familiar with its internal workings. This
• memory
layer or layers is called systems software and includes the operating system and
• I/O devices
other forms of systems software such as anti-virus software, disk defragmenters,
• applications
backup software.
• security.
What is application software?
Key concept Applications software is an application program or programs designed to
System software: support user-oriented tasks which would need to be carried out even if
A layer or layers of software
computers did not exist. For example, communicating in written form, placing
which enables users to operate
the computer without having orders for goods, looking up information.
to be familiar with its internal Application software cannot execute unless it has been first translated into
workings.
the language of the computer, machine code, or a form that is executable by a
computer.
Key concept
Application software: It needs to be loaded into main memory and it needs to obtain input from
Application software is an input devices such as keyboards and to write output to output devices such as
application program or printers and it may need to communicate with other computers.
programs designed to support
user-oriented tasks which would Application software may need to store information permanently and to
need to be carried out even if subsequently access stored information. The stored information should be
computers did not exist. backed up so, if necessary, it may be restored from a back-up copy. These
services are provided by the operating system and utility software without
Key concept which it would not be possible to run application software.
Software:
Consists of sequences of
Application software may be classified as
instructions called programs • General purpose application software: software that is appropriate
which can be understood and
for many application areas is described as general-purpose application
executed by the hardware in its
digital electronic circuits or a
software. For example, word processing can be applied in writing-up
virtual machine equivalent. project work, in personal correspondence, writing memos, writing a
book, creating standard business letters. The software is relatively cheap
4 Computer systems

because its development costs are spread among all the purchasers of the
software, which in the case of popular application software will be a large
number. It is likely to be very reliable because it has been produced by an
experienced team of programmers and tested on a large customer base.
• Special purpose applications software: special purpose application
software is used for a particular application. For example, a dentist might
use application software written specifically to record and process dental
treatments, a task that every dentist needs to do. A business might use an
accounting package for its accounts of sales. It is likely to be very reliable
because it has been produced by an experienced team of programmers
and tested on a large but specialised customer base.
Key concept • Bespoke software: when no general purpose or special purpose software
Different types of application exists that could do the job, software must be written from scratch
software: to solve the specific problem or to support the required task. This
1. General purpose
software is called bespoke (tailor-made) software. For example, a teacher
2. purpose
3. Bespoke. interested in finding out how frequently his students logged on to the
college’s computer network and for how long, wrote a program using
the programming language C to handle this task because no application
program existed which could do this job.

Questions
1 Explain what is meant by:
(a) system software (b) application software.
2 Give one example of system software and one example of application
software.

Understand the need for, and functions of, operating systems


Key concept (OS) and utility programs
System software classification: Systems software can be classified as follows:
1. Operating systems • Operating system software: an operating system is a program or suite of
2. Utility programs.
programs which controls the entire operation of a computer
• Utility programs: a utility program is a systems program designed to
perform a common place task, for example, formatting and partitioning
a disk or checking a disk for viruses. Some utility programs are supplied
with the operating system, others can be installed at a later time.
4.3 Software classification

Key concept
The most fundamental of all the system programs is the operating system. Functions of an operating
An operating system performs several major functions: system:
1. Hiding the complexities of
• Hiding the complexities of the hardware from the user so that the user the hardware from the user so
is presented with a machine which is much easier to use. that the user is presented with
a machine which is much easier
• Managing the hardware resources to give an orderly and controlled
to use.
allocation of the processors and processor time, memories and input/ 2. Managing the hardware
output (I/O) devices among the various programs competing for them, resources to give an orderly
and manage data storage. and controlled allocation of the
processors and processor time,
 The operating system (OS) will need to schedule processor time memories and input/output
for each executing program loaded into RAM. In a single processor (I/O) devices among the various
system, this may be done on a round robin basis or some other programs competing for them,
way of allocating processor time fairly and appropriately. The and manage data storage.
3. Managing the loading
task becomes a little more challenging if there is more than one
and unloading of application
processor. software.
 The OS will need to manage the allocation of space in RAM to 4. Managing user accounts,
passwords and access to the
programs and unload programs that have finished their execution -
system in order to secure the
memory management. system against unauthorised
 The OS will need to manage the allocation and release of areas of access, alteration and deletion
of data.
storage, e.g. disk blocks - disk management.
 It will also need to manage the file/directory system which structures
storage into files and directories - file management.
 The OS will need to respond to I/O devices that need attention, e.g.
when a key on the keyboard has been pressed or when a disk block
of file data has finished being transferred into RAM. It will need to
know how to "drive" I/O devices because the OS will be responsible
for handling the transfer of data between the processor/RAM and
I/O devices, e.g. writing a disk block of data to a disk file. The
OS will rely on pieces of software to do this called device drivers.
Their software will have been written for a specific device or type of
device, e.g. a disk device driver.
• Managing the loading, unloading of application software.
• Managing user accounts, passwords and access to the system in order
to secure the system against unauthorised access, alteration and deletion
of data.
Questions
3 Explain the purpose of an operating system.

4 Give one example of a utility program.


4 Computer systems

In this chapter you have covered:


■ What is meant by:
• system software
• application software
■ Examples of both types of software
■ The need for, and functions of, operating systems (OS) and utility programs
■ That the OS handles management of the:
• processor(s)
• memory
• I/O devices
• applications
• security.
4 Computer systems
4 Computer systems
Learning objectives:
■ Know that there are different
levels of programming ■ 4.4 Classification of programming languages and translators
language: Levels of programming language
• low level language
• high-level language There are two levels of programming language:
■ Explain the main differences • low-level language
between low-level and high-
level languages • high-level language.
■ Know that machine code Low-level programming languages
and assembly language are There are two levels of low-level programming languages:
considered to be low-level
languages and explain the • machine code
differences between them • assembly language.
■ Understand that ultimately
all programming code written EDSAC and machine code
in high-level or assembly On May 6th, 1949, EDSAC ran its first program which printed a table of
languages must be translated squares for integers in the range 0 to 99. The program took two minutes to
into machine code run. The program of order codes had been punched on paper tape as 5-bit
■ Understand that machine code
binary codes (see Figure [Link] in Chapter 4.5.1).
is expressed in binary and is
specific to a processor or family The order codes represented arithmetic and logical orders, shifts, jumps, data
of processors transfer orders, input and output orders and stop orders.
■ Understand the advantages The word “order” was literally an order for EDSAC to do something.
and disadvantages of low- These order codes were the first programming language, a low-level language
level language programming
compared with high-level known as machine code that was interpreted directly by the hardware of
language programming EDSAC.
■ Understand that there are Two examples of these order codes are shown in Table 4.4.1 where each 5-bit
three common types of program order code is expressed as a single letter.
translator:
The single letter order codes were typed on a machine that punched the
• interpreter
• compiler corresponding 5-bit code directly onto paper tape (see Information panel
• assembler opposite for the 1951 film on how EDSAC was used in practice).
■ Explain the main differences Addresses were also expressed in decimal and then translated into binary.
between these three types of
translator Letter form 5-bit binary
■ Understand when it would be of order equivalent of Address Description
appropriate to use each type of code order code
translator. Add the content of location n
Information A 11100 n
to the accumulator.
EDSAC film:
[Link] Subtract the content of location
S 01100 n
watch?v=6v4Juzn10gM n from the accumulator.
Maurice Wilkes’ 1976 commentary
on the 1951 film about how EDSAC
Table 4.4.1 Examples of EDSAC order codes
was used in practice.
4 Computer systems

Key concept Figure 4.4.1 shows a snippet of an EDSAC order code program. Each
character represents a 5-bit code.
Machine code:
Machine code is a language T123SE84SPSPSP10000SP1000SP100SP10SP1S
consisting of bit patterns/ QS#SA40S!S&S@SO43SO33SPSA46S
binary codes that a machine can
interpret, i.e. execute. For this T65ST129SA35ST34SE61ST48SA47ST65SA33SA40S
reason, machine code is referred Figure 4.4.1 EDSAC order code
to as executable binary code.
Machine code is a language consisting of bit patterns/binary codes that a
machine can interpret, i.e. execute. For this reason, machine code is referred to
as executable binary code. For example, the EDSAC executable binary code
instruction
Key concept 0010100000010101
means “transfer the content of the accumulator to storage location 21.”
Machine code instruction:
A machine code instruction is A machine code instruction is an operation which a machine is capable
an operation which a machine is of carrying out, i.e. the processor in the central processing unit. This direct
capable of carrying out.
relationship with the hardware gives machine code instructions their low-level
classification. Therefore, higher-level operations for which there is no direct
Key concept machine counterpart have to be broken down into a sequence of machine code
Low-level programming instructions.
language: Each type of processor or family of processors, e.g. ARM Cortex, has its own
The direct relationship with the
specific machine code instruction set. Today, the set of order codes of the
hardware gives machine code
instructions their low-level EDSAC would be called its instruction set.
classification. What is a machine code program?
A machine code language program is a program consisting of executable
binary codes.

Questions
1 What is machine code?
2 What is a machine code instruction?

3 Why is machine code classified as a low-level programming language?

Assembly language
Writing programs directly in machine code is challenging.
The EDSAC programmers wrote their programs using letters for the operation
to be performed and addresses in decimal using the digit characters ‘0’..’9’.
The hardware on which they typed these letters and digit characters was wired
to punch paper tape with the 5-bit equivalent of each.
We would call the form of the program shown in Figure 4.4.1 which uses
letters, an assembly language program.
In assembly language, a (symbolic) name is assigned to each operation/
instruction code.
The operation/instruction code name is called a mnemonic or memory jogger.
4.4 Classification of programming languages and translators

The operation code mnemonic should describe in some way what the
instruction does, e.g. LDR means LoaD a Register, ADD means add - see
Table 4.4.2. The address field &1234 is expressed in hexadecimal (& is used to
indicate this).
Key concept
Assembly language Description
LDR means LoaD a Register with content of a language:
memory location or word, Rd is the symbolic name Assembly language is the
LDR Rd, &1234 symbolic form of machine code.
for the register, &1234 is the memory location’s
Each operation/instruction code
address expressed in hexadecimal.
of machine code is assigned a
ADD means add content of registers Rn and Rm, symbolic name or mnemonic
ADD Rd, Rn, Rm describing what the instruction
store result in register Rd.
does, e.g. ADD.
STR means STore the content of the specified
STR Rd, &4321 There is a ONE-to-ONE
Register in a memory location or word. mapping between an assembly
Table 4.4.2 Some assembly language instructions language instruction and
its equivalent machine code
language instruction.
There is a ONE-to-ONE mapping between an assembly language instruction
and its equivalent machine code language instruction.
For example,
LDR Rd, &1234 might be assembled to 000000 0001 01001000110100
The one-to-one mapping makes translating instruction mnemonics into the
binary of machine code a simple task that can be assigned to a computer. The
translator is called an assembler.
Assembly language is often used to develop software for embedded systems and
for controlling specific hardware components.
Questions
An embedded computer system is loosely defined as any device that includes
a programmable computer but which is not intended to be a general purpose 4 What is assembly
computer like a desktop PC. Cars are full of embedded computer systems language code?
such as an antilock brake system (ABS) and an engine management system.
Embedded systems interface with sensors and actuators (a device for controlling 5 What is the mapping
a mechanism) at a very low level. Hence, the need to program at a low level. between assembly
language instructions
The Internet of Things (IoT) is connecting to more and more remote devices
and machine code?
consisting of sensors and actuators in embedded systems. This has resulted in a
rising demand for assembly language programmers to program these systems. 6 What language
The input/output hardware controllers of devices such as hard disks operate at a translator is required
low level. It is therefore appropriate to use assembly language for programming to translate assembly
these components of a computer system. These programs are called device language into machine
drivers. code?
4 Computer systems

Key concept High-level languages (HLL)


As the 1951 EDSAC film showed, a problem had to be recast by hand into
High-level programming
language (HLL): a form that could use the machine code language of EDSAC. Wouldn’t it be
High-level programming much better if the problem could be expressed in a programming language
languages are problem-oriented much closer to the problem space (i.e. in a language easier for programmers to
and therefore closer to English understand), leaving the task of translating to machine code to the computer?
than they are to the machine.
This thought led to the development in the 1950s of high-level languages, some
This means that the mapping
from a high-level language of which are still used. For example, Fortran (1957) was designed for numerical
statement to machine code will applications and is still used by mathematicians, scientists and engineers, today.
be a one-to-many mapping
High-level languages (HLL) are closer to English than they are to the machine.
because each high-level
language statement will need This means that the mapping from a high-level language statement to machine
to be broken down into several code will be a one-to-many mapping because each high-level language
machine code operations. statement will need to be broken down into several machine code operations.
For example, the assignment statement
x = y + z
Information
when translated could become in the assembly language form of machine code
LDR R0, &1234
GNU Fortran is the primary
open source version of the LDR R1, &1235
Fortran compiler widely used
ADD R2, R0, R1
both in and out of academia. It
is one of the Fortran compilers STR R2, &1236
available for the Raspberry Pi.
Questions
Key fact 7 What is meant by the term high-level programming language?
Advantages of programming
8 What is the mapping between high-level language statements and
in machine code and assembly
machine code?
language:
Hand-coded assembly language Advantages of programming in machine code and assembly
when assembled can
language compared with HLL programming
achieve a smaller memory
footprint in machine code High-level language programs are converted into machine code by a translator
than compiled high-level called a compiler. Most compilers attempt to optimise the machine code which
language code is produced. The compiler scans the machine code to see if it contains any
achieve better code unnecessary code which it then attempts to remove or adapt. Fewer machine
optimisation than compiled
code instructions means the code will take up less memory (smaller footprint)
high-level language code
and therefore code that will as well as running more quickly when executed. However, the process is
run faster not perfect, for example, where floating-point operations are concerned.
directly access registers In embedded computer systems, where speed of execution is paramount or
and low-level operating
memory is at a premium, the compiled code can be examined by hand and
system routines which is
not possible with most
sections that are not already optimised replaced by hand-coded assembly
high-level programming language code, which is then assembled into machine code.
languages.
For short sections of code which need to run quickly or take up little space,
it may be better to code directly in assembly language. Some high-level
4.4 Classification of programming languages and translators

programming languages allow assembly language code to be embedded (inline)


in the HLL program to take advantage of the time and space efficiency of
assembly language coding.
Assembly language and machine code programming allow direct access
to registers and low-level operating system routines which is not generally
possible with most high-level language programming languages.

Questions Key fact


9 State three advantages of programming in assembly language Disadv. of programming in
compared with programming in a high-level language. machine code and assembly
language:
Code written in assembly
language or machine code is less
Disadvantages of programming in machine code and assembly readable than code written in a
language compared with HLL programming high-level language and so more
Code written in assembly language or machine code is less readable than code difficult to
understand and maintain
written in a high-level language and therefore more difficult to understand
debug
and maintain, debug and write without making errors. Code written in write without making
assembly language or machine code uses the instruction set of a particular errors
processor (processor family). It is therefore machine dependent and will Code written in assembly
only execute on processors that use this instruction set. High-level languages language or machine code is
are machine independent. An HLL program is expressed in an English- machine dependent making it
like language which is turned into machine code by a compiler. As long difficult to port to a different
instruction set processor
as a compiler exists for a particular instruction set, the HLL program may
compared with code written
be ported to and its compiled version run on a computer with a different using high-level languages
instruction set processor from the one it was written on. HLL programs are which do port readily because
easier to understand and therefore maintain than assembly language programs they are not machine-oriented.

because they are written using statements that are close to English. They are
less error-prone when writing for the same reason.

Questions
10 State three disadvantages of programming in assembly language
compared with programming in a high-level language.
4 Computer systems

Types of program translator


There are three types of program translator:
• Assembler
• Compiler
• Interpreter.
Role of an assembler
Key principle Programs written in assembly language have to be translated into machine code
Assembler: before they can be executed. This is done with an assembler.
An assembler translates Machine code is a language that the machine can execute, i.e. it is executable
assembly language into machine
binary code (binary patterns for which machine operations are defined).
code.
One assembly language Assembly language is the mnemonic form of these executable binary codes.
statement maps to one machine Thus there is a one-to-one correspondence between an assembly language
code statement.
statement and its machine code equivalent: one assembly language statement
maps to one machine code statement. This is in contrast to a high-level
language statement which typically maps to several machine code statements.
Role of a compiler
A compiler is a program that reads a program (the source code) written in
Key principle a high-level programming language (the source language) and translates it
into an equivalent program (the object code) in another language - the target
Compiler:
A compiler translates a high- language. As an important part of this translation process, the compiler reports
level programming language the presence of errors in the source code program.
source code program into a
A compiler translates (compiles) a high-level programming language source
separate and independently
executable object code target code program into a separate and independently executable object code
language program. Object code target language program. The target language program or object code
is typically machine code. produced by the process could be

A compiler translates one high- • Machine code of an actual machine ( in which case the compiler is
level language statement into called a native language compiler)
several machine code or target
• Intermediate code which can, if necessary, be interpreted by an
language statements.
interpreter, e.g. Java bytecode is an intermediate language produced by
a Java compiler
• Executable code for execution by a virtual machine.
A compiler translates one high-level language statement into several machine
code or target language statements.
A compiler only translates a high-level language program (the whole of the
program), it does not execute it.
The process that the compiler engages in is called compiling.
4.4 Classification of programming languages and translators

Did you know? Key principle


A compiler consists of several stages:
Interpreter:
Lexical analysis – splits the source into user-defined “words”,
An interpreter is a program
e.g. variable identifiers and language-defined “words”, e.g. While
that executes a high level
Syntax analysis – checks that statements are grammatically correct
programming language
Semantic analysis – e.g. type checking, "A" + 3.142 is incorrect as you can’t add a
program, statement by
real to a string
statement, by recognising the
Intermediate code generation
statement type of a statement
Code optimising
and then calling a pre-written
Code generation
procedure/function for the
Role of an interpreter statement type, to execute the
statement.
An interpreter is a program that executes a high-level programming language
program, statement by statement, by recognising the statement type of a
statement, e.g. X = X + 1, and then calling a pre-written procedure/function Key principle
for the statement type, to execute the statement. Therefore, an interpreter does
not, unlike a compiler, produce an independently executable target language An interpreter both “translates”
equivalent of the source language program. The application of interpreter to a and executes whereas a
compiler only translates.
source code program is called interpreting.
The differences between compilation and interpretation
The major differences between the compilation and interpretation are: Key principle
• An interpreter both “translates” and executes whereas a compiler only
A compiler produces a separate
translates. independently executable form
• A compiler produces a separate independently executable form of the of the source code program
source code program whereas an interpreter does not. whereas an interpreter does not.
• A compiler is not needed when target form of source program is
executed whereas in the case of the interpreter, execution requires the
source code form of the program together with the interpreter, i.e. Key point
the interpreter needs to be available on the machine where the program Ultimately all programming
code written in high-level or
is being run.
assembly languages must be
• If an interpreter is used then only the source code form of program is translated into machine code:
needed to execute the program whereas, if a compiler is used then the An electronic digital computer
object code form of program is needed in order to execute the program. can only execute machine code
• Interpreters are usually easier to write than compilers. instructions. Therefore assembly
and High Level Languages
• With the compiler approach, if an error is discovered while the
(HLL) cannot be executed
program is executing, the source form of program must be located. directly without the use of a
An editor and the source form of the program must be loaded. The translator.
error must be pin-pointed which is not always easy and then corrected. A HLL may be executed
The compiler must be loaded and a compilation carried out. The new indirectly by using an
interpreter but the interpreter
target form of program must then be loaded and executed. With an
in order to execute must be
interpreter, the execution is halted at the point where the error occurs. presented to the computer in
The interpreter gives precise details of location of error. The error is machine code form.
corrected with an editor which may be co-located with interpreter. If Remember that the language of
an electronic digital computer
it isn’t, an editor will have to be loaded. However, no time-consuming
is binary.
compilation is involved and execution can resume immediately.
4 Computer systems

Key principle Questions


When to use assembly
language: 11 Explain the role of each of the following:
Where speed of execution and/ (a) assembler (b) compiler (c) interpreter
or direct access to hardware is
12 State three differences between compilation and interpretation.
required, use assembly language
and an assembler.

Situations in which assemblers, compilers and interpreters


Key principle would be appropriate
Interpreter vs compiler: Assemblers
Compiled code which has been For time-critical sections of code where execution speed is important, e.g.
compiled into machine code of
interrupt service routines, assembly language still has a role to play because in
the computer will execute a lot
faster than its interpreted source
the hands of a skilled programmer, assembly language code can be written that
code equivalent (i.e. interpreter is highly optimised for speed. As an assembler simply translates one assembly
+ the source code equivalent of language statement into one machine code statement, that optimisation is
the compiled code). preserved. Compilers can optimise code but the result cannot be guaranteed
to be fully optimised for the given hardware. In the pecking order of execution
Key principle speed, interpreters come after compilers.
Interpreter vs compiler: Assembly language is still used where direct access to hardware is required e.g.
Where rapid debugging and
processor registers or I/O controller registers. This is the case when writing
immediate feedback on errors is
required including pinpointing
device drivers, e.g. a screen driver. In this instance an assembler would be
the location of both syntax required to translate the assembly language program into machine code.
and runtime errors, use an
Compilers and interpreters
interpreter.
It is considerably more productive to write programs in high-level languages
than in assembly language. There are relatively few programmers who are
Key principle skilled in writing assembly language programs compared with the number
Interpreter vs compiler: of programmers skilled in writing in one or more high-level programming
Where a separate executable
languages.
that can execute independently
of its source code equivalent is Compiled code which has been compiled into machine code of the computer
required, use a compiler. will execute a lot faster than its interpreted source code equivalent (i.e.
interpreter + the source code equivalent of the compiled code).
Questions The immediate feedback and ease of locating errors in source code give
13 Give two reasons why interpreters an advantage over compilers when developing programs. This
programs are still written advantage is particularly beneficial for novice programmers or when programs
in assembly language. are being prototyped and the write, compile, debug, edit cycle can be too time
consuming.
14 Given a choice, under
what circumstances Compiling has an advantage over interpreting because it produces a separate
would it be preferable to executable which means that the source code program does not have to be
use: distributed. There are plenty of situations where this is desirable such as when
a compiler; producing commercial software or where there is a requirement is to protect the
an interpreter? algorithm or coding technique used.
4.4 Classification of programming languages and translators

Questions
15 Two computer programs that add two integers are shown
High-level program Low-level program
in Table 4.4.3. r = 5 0100 0101
One is written in a high-level language and one is written s = 3 0100 0011
in a low-level language. t = r + t 1000 0000
Table 4.4.4 gives three correct reasons why computer 0001 0010
1100 0011
programs are most commonly written in high-level
1110 1100
languages (HLL) instead of low-level languages are
Table 4.4.3
true. Tick these three correct reasons.
Reason Tick three boxes
A HLL programs are easier to debug.
B HLL programs always run faster.
C Less time-consuming for a programmer to write a HLL program.
D HLL program code can be easier for humans to understand.
E Computers understand only HLL programs.
Table 4.4.4
16 The low-level program shown in Table 4.4.3 is written in machine code.
Give two reasons why it would have been better for the programmer to have used assembly language instead
of machine code.

In this chapter you have covered:


■ That there are different levels of programming language:
• low level language
• high-level language
■ The main differences between low-level and high-level languages
■ That machine code and assembly language are considered to be low-level
languages
■ The differences between machine code and assembly language
■ That ultimately all programming code written in high-level or assembly
languages must be translated into machine code
■ That machine code is expressed in binary and is specific to a processor or
family of processors
■ The advantages and disadvantages of low-level language programming
compared with high-level language programming
■ That there are three common types of program translator:
• interpreter
• compiler
• assembler
■ The main differences between these three types of translator
■ When it would be appropriate to use each type of translator.
4 Computer systems
4 Computer systems


Learning objectives:
■ Explain the von Neumann 4.5.1 Systems architecture
architecture.
Von Neumann architecture
Between 1945 and 1951 John von Neumann (Figure [Link]) created a design
for a digital electronic computer as a system consisting of
• a memory called Main Memory, containing instructions and data
• a calculating unit called the Arithmetic and Logic Unit (ALU), for
performing arithmetic and logical operations
• a Control Unit, to fetch and interpret (decode and execute)
instructions stored in main memory
• an input device and an output device
Figure [Link] John von Neumann • a method of connecting these together called a bus consisting of a
collection of wires (this bus is called the System Bus).
Figure [Link] shows the basic architecture of John von Neumann’s computer.
The combination of Control Unit + Arithmetic and Logic Unit (ALU) is
called the Central Processing Unit (CPU) in modern computer systems.

Bus
Main Memory
Store for both data and Input
device
program instructions

Memory module
Control Unit
Interface
Keyboard

Keyboard
system
including fetching, decoding and
Central executing instructions

Processing
Unit
Interface
Display

Performs arithmetic and logical Display


operations

Modern CPU CPU Output


device

Figure [Link] Von Neumann architecture

Lesson activity
1 Download Activity 1 from [Link]/GCSE/Ch4.5.1/[Link].
This activity consists of the six people engaging in executing a list of numbered instructions.
The six people are required to perform the following roles
1. Memory 2. Control Unit 3. Arithmetic and Logic Unit
4. Keyboard 5. Display 6. Bus
4 Computer systems

The von Neumann architecture was an improvement over the program-controlled computers of the 1940s, such as
Colossus and ENIAC, which had no memory so had to be programmed by inserting patch leads (cables) to route
data and control signals between various functional units - Figure [Link].
In the ENIAC, patch leads needed to be unplugged and then re-plugged in a new position to reprogram the
computer to complete a different task.
Von Neumann’s design is much more flexible because it can be reprogrammed by simple loading a different
program, as well as the program’s data, into read-write main memory (random access memory (RAM)).
Programs and their data are kept ready to be loaded into main memory from another storage medium called
backing store (or secondary storage to differentiate this type of storage from main memory (primary memory)).
Punched paper tape was used for secondary storage in the early days (Figure [Link]).
A paper-tape reader attached to the keyboard
was used to input a program and its data from
the paper tape on which the program and its
data were represented by a series of punched
holes.
Computers based on von Neumann’s
architecture are sometimes called stored-
program computers because their programs
and data, if necessary, can be loaded into main
Figure [Link] Paper tape used to store data and computer memory from a secondary storage medium,
programs in the 1950’s e.g. magnetic disk.
Once finished with they are unloaded
Information (removed from main memory) and replaced in main memory by another
program until needed again.
The University of Manchester’s
Small-Scale Experimental Loading and unloading are operations carried out by the stored-program
Machine is generally recognised computer.
as the world’s first electronic
computer that ran a stored
program - an event that
occurred on 21st June 1948.
However, the EDSAC (designed
and built at Cambridge
University) is considered
the first complete and fully
operational electronic digital
stored program computer. It ran
its first program on 6th May
1949. The design was inspired
by John von Neumann’s First
Draft of a Report on the Patch cables
EDVAC.
EDVAC, America’s first
electronic digital stored program
computer wasn’t available to run
until August 1949. Figure [Link] ENIAC computer being reprogrammed by changing the wiring
(U.S. Army photo, [Link]
4.5.1 Systems architecture

Questions
1 Von Neumann’s design for a digital electronic computer consisted of an input device, an output device
and four other components. Name these four other components.

Lesson activity
2 Download Activity 2 from [Link]/GCSE/Ch4.5.1/[Link].
This activity is similar to Activity 1 in using six people to perform the roles of the parts of a computer
system but differs in the way that the two integers are obtained. This time the two integers are fetched
from memory.

Characteristics of the von Neumann architecture


A computer system with a von Neumann architecture is characterised by
• Memory (common name Main Memory) which is used to store both program instructions and data
• Data from Main Memory and from devices are accessed in the same way via the bus system
• Data and instructions in Main Memory are indistinguishable from each other.
In a digital computer, instructions and data are represented internally by numbers.
Instructions and Data
If these numbers are stored together in Main Memory then it becomes difficult without
guidance to distinguish numbers which represent instructions from numbers which
represent data.
For example,
• The instruction INPUT might be represented internally by the number 234 and
• A datum (value) which is to be interpreted as the integer 234 might also be
represented internally by the number 234
• The contents of Main Memory from beginning to end just consists of Main Memory
numbers - Figure [Link] 65535 96
65534 4 Memory
65533 245 location
• Some numbers represent instructions 65532 56
65531 100 The content
• Some numbers represent data (values to be manipulated by 65530 231 of Main
65529 25 Memory
instructions or values which are the results of such manipulation or 65528 230 locations
65527 234 can be
values from input devices) treated as
Addresses numbers
• Some numbers represent memory addresses, and representing
9 112 different
• Some numbers are simply rubbish left over from previous computer 7 0 things
6 200
activities. 5 16
4 42
3 145
It is the logic in computer programs that instructs a computer to treat one 2 253
1 0
number as an instruction and another as a value. 0 131
Sometimes the logic of a computer program is faulty and the computer tries
Figure [Link] Main Memory
erroneously to execute data. This situation is exploited by computer viruses
consisting of consecutively
which are first downloaded as data but then, by a bit of trickery, can be treated
numbered storage locations
as programs and executed.
4 Computer systems

Questions
2 Select the letter from the list below which labels the answer which you think best describes what Main
Memory stores temporarily in a digital electronic computer based on von Neumann’s architecture
Instructions
B Data
C Data or instructions, but not both
D Data and instructions
3 Explain what is meant by “Data and instructions in Main Memory are indistinguishable from each other”.

4 Select the letter from the list below which labels the answer which you think best describes how data from
Main Memory and from devices are accessed in von Neumann’s architecture
A Via the keyboard
B Via the bus system
C Via the control unit
D Via the Arithmetic and Logic Unit

Lesson activity
3 Download Activity 3 from [Link]/GCSE/Ch4.5.1/[Link].
In both Activity 1 and Activity 2, the operations performed by six people were coordinated by
arrangement but not by time. If the operations are to be coordinated by time then a clock is required.

Von Neumann computer system as a collection of subsystems


Figure [Link] shows the major subsystems (components) of a computer system based on the von Neumann
architecture.
The subsystems are classified as either internal or external.

Processor
Bus
(comonly
Main memory known as the
or System Bus)
immediate access store
(RAM or RAM & ROM)

Visual
Keyboard VDU
Display
Keyboard input output
Unit
controller controller
(VDU)

(Disk) I/O controller

Secondary store or backing


store
(e.g. magnetic disk)

Figure [Link] Block diagram of the von Neumann architecture


4.5.1 Systems architecture

Internal subsystems
The internal components are
• Processor or Central Processing Unit (CPU) - contains the control
unit, the arithmetic and logic unit, registers (a register is a store with its
own identity used for storing a single number temporarily which could
represent an address, a value, an instruction or the status of something),
and a clock for sequencing operations within the computer system
• Main memory (normally a mix of RAM and ROM)
Key concept
• I/O controllers - input only, output only, both input and output - Peripheral:
which connect the CPU to input and output devices, and secondary A peripheral is a device that
storage is connected to the computer
system but which is not under
• Bus - a collection of wires connecting the internal components, data/ the direct control of the
signals are transmitted along the bus from one component to another. processor. Instead the processor
External components interacts with the peripheral
indirectly via the peripheral’s
The external components do not interact directly with the CPU but are
I/O controller which sits
largely on the periphery of the computer system and are known, therefore, as electrically between the
peripherals or peripheral devices - for example, the keyboard, visual display unit peripheral and the system bus.
(e.g. flat screen monitor), printer, magnetic disk drive. Examples of peripherals are
Interaction between CPU and peripherals keyboard, VDU, mouse, printer.

The main processor, or CPU, exchanges data with a peripheral device through
an I/O controller.
Peripheral devices are not connected directly to the CPU because the former
often operate with signal levels, protocols and power requirements which are
different from those used by a CPU.
Therefore, peripherals are not under the direct control of the CPU instead they
are controlled indirectly through an I/O controller.

In this chapter you have covered:


■ The von Neumann architecture
• internal components
 processor or Central Processing Unit (CPU)
 main memory (RAM or a mix of RAM and ROM)
 I/O controllers - input only, output only, both input and output
 bus - collections of wires connecting components
• external subsystems
 components not connected directly to the processor (CPU)
 they are called peripherals, e.g. keyboard, printer, flat screen
monitor, magnetic disk drive.
4 Computer systems
4 Computer systems


Learning objectives:
■ Explain the role and operation 4.5.2 Systems architecture
of main memory and the
following major components Main memory
of a central processing unit The basic requirement of memory is to be able to write some information into
(CPU) within the von it, leave it there, and return later to read it.
Neumann architecture:
• arithmetic logic unit ■ Main memory serves this purpose in 0 1

• control unit von Neumann’s architecture.


Memory Storing Storing
• clock cell binary 0 binary 1

Figure [Link] Single memory cell


• register
■ It consists of a collection of individual
• bus.
storage cells, each capable of storing a single bit - Figure [Link].

These are grouped together into rows of a fixed size, e.g. 8 cells, and called
Information memory locations. Figure [Link] shows a single row or memory location
with contents 01011100.
Magnetic core memory was the
predominant form of random
0 1 0 1 1 1 0 0
access main memory (RAM) for
20 years between about 1955 Figure [Link] Single memory location consisting of eight memory cells
and 1975. Such memory was
often just called core memory, or, ■ Each memory location is assigned a unique physical address and the
informally, core.
memory locations are organised together as shown in Figure [Link] with
Magnetic-core memory uses the
magnetisation of tiny magnetic addresses from 0 upwards.
rings, the cores, to write and read In Figure [Link], addresses are expressed in 8-bit binary.
information. 1 bit
Address Contents
The lowest memory location is assigned the
11111111 11101010
unique memory address 00000000, the next
00000001, and so on, with the memory
10001101 11101010
address increasing by one each time. 10001100 11101010
10001011 11101010
10001010 11101010
The highest memory location is assigned the 10001001 01011100 Memory
Each core represents one bit location
10001000 11101010
of information. When not last possible address in 8-bit binary, 11111111. 11101010
10000111
being read or written, the cores 10000110 11101010
In this example, there are 256 memory
maintain the last value they had,
even when power is turned off. locations.
00000100 11101010
This made them non-volatile. 00000011 11101010
The size in bits of a memory location is 00000010 11101010
00000001 11101010
normally a power of 2, e.g. 23 = 8 bits as shown 00000000 11101010
in Figure [Link]. Figure [Link] Shows the
current contents of a block
of 256 memory locations,
with each location designed
to store 8 bits
4 Computer systems

Key concept A memory location is the smallest addressable unit of memory:


Memory location: ■ Nothing smaller than a memory location can be accessed directly
A memory location is the
smallest addressable unit of
■ The contents of a memory location are read by selecting it by address and
memory. copying the contents,
e.g. the memory location in Figure [Link] with address 10001001 has
contents 01011100 expressed in binary
■ The contents of a memory location are changed by selecting it by address
and replacing its current contents by another value.

Figure [Link] shows a single location selected by address when the CPU sends
the location’s address, encoded as on and off signals, along the bus connecting
the CPU to the main memory. This bus is called the system bus.
If the requested action is reading from memory then the contents of the
memory location shown in Figure [Link] appear on the bus wires connecting
main memory to CPU.
8 wires for an
8-bit address

Read control
Write control 0 1 0 1 1 1 0 0

8 wires
for 8-bits Address
of data decoder

10001001

Figure [Link] Single memory location consisting of eight memory cells

In von Neumann’s architecture, reading from and writing to main memory


is made possible by dividing the system bus1 into address bus, data bus and
control bus as shown in Figure [Link].

Visual Magnetic
Keyboard Processor
display disk
controller (CPU)
controller controller

Address bus

Figure [Link] Von Neumann architecture showing the


subdivision of the system bus into data bus, address
bus and control bus

1 You do not need to know that the system bus is divided into address, data and
control bus.
4.5.2 Systems architecture

Reading from main memory


The 256 main memory locations shown in Figure [Link] are address Main Memory data

shown in Figure [Link] packaged into a single memory chip 256


BYTES
(integrated circuit) of 256 locations each capable of storing one
byte of data which can be any of the following Write Read
• an instruction
• a number 139 Instruction
• an address Main Memory
• a letter. 255 Number
From CPU To CPU
For a program to be executed it must first be loaded into the
main memory of the computer. The computer can then start the
142 Address e.g. 245
execution as follows2:
141 Instruction
■ The CPU sends an address to main memory to start
140 Number
retrieving the program Instruction
139
■ This address just consists of a series of 1s and 0s encoded 138 Number e.g. 25
as on and off signals on the address bus wires connecting 137 Instruction
the CPU to the main memory 136 Letter e.g. ’A’
■ The main memory doesn’t do anything with this address 135 Instruction
until the CPU turns on the Read wire
■ When the Read wire is turned on by the CPU, the main 4 Instruction
memory automatically sends whatever is in the addressed 3 Instruction
main memory location back to the CPU via the data 2 Number e.g. -32
bus wires connecting the main memory to the CPU. 1 Instruction
The Read wire connects the CPU to the Read pin on the 0 Instruction
Address
memory chip. Contents
in
For example, to fetch the instruction at memory address decimal decimal
Figure [Link] A 256 byte memory chip
139 (binary 10001011), the CPU sends 10001011 to the address
mounted on a circuit board
input of the memory chip (yellow pins connected to address for main memory
wires in Figure [Link]).
On turning on the Read wire connected to the read pin of
this memory chip, the addressed memory location’s contents,
11011010, appear on the data pins (yellow pins connected to the data wires in Figure [Link]).
This instruction is retrieved by the CPU from the data bus connected to the data pins and processed. Once the
CPU has dealt with this instruction it sends another address to main memory, turns on the Read wire and gets the
next addressed location’s contents. This process is repeated until the program has finished executing.

Writing to main memory


Writing to a memory location in main memory is done as follows
■ The CPU sends the address of the memory location from CPU to main memory along the address bus
wires of the system bus
■ The CPU sends what it wants to write to main memory along the data bus wires of the system bus
■ The Write wire is turned on and contents of the memory location are then changed.
2 The remainder of this “Reading from main memory” section whilst useful to know, covers more detail than
required for AQA’s GCSE specification 8525.
4 Computer systems

Questions
1 For each of the statements below indicate whether the statement is true or false by choosing the
appropriate letter.
The contents of a memory location are read by selecting it by address and copying the contents.
True
B False
A memory location is made up of a collection of memory cells each of which can store one bit.
True
B False
The contents of a memory location are changed by selecting it by address and replacing its current
contents by another value.
True
B False

Key term RAM


Random Access Memory Memory is labelled random access if
(RAM) ■ Cells can be accessed in any order
Memory that permits access
to any of its address locations ■ The time to access any cell is the same wherever it is in memory.
(cells) in any desired sequence
Today’s computers use a type of semiconductor memory for main memory
with similar access time to each
location. called dynamic RAM or DRAM.
The term, as commonly used, Information/data stored in modern RAM is lost when the power is removed.
denotes a read/write memory Therefore, modern RAM is said to be volatile.
with unlimited data rewrite
capability and similar read and
ROM
write times.
■ There is another type of random-access memory called Read Only
Memory or ROM that can also be present in main memory, i.e. its
Key term
memory locations can be addressed by the processor (CPU) in any
Volatile memory:
order.
A memory in which the data
content is lost when electrical ■ This is memory that can be read from but not written to (during
power is removed. normal operation).
It is also non-volatile which means that information/data stored in
Key term ROM is retained when the power is removed.
Non-volatile memory:
ROM was used in early desktop computers (PCs) for the BIOS.
A memory in which the data
content is retained when Software stored in the BIOS
electrical power is removed. • initialises and tests the system hardware components
• loads a boot loader or an operating system from a storage device.
Information Information
Flash ROM:
Modern PCs, use a different technology called Flash ROM Technically, the ROMs in use today are actually non-volatile
for the BIOS. This is non-volatile random-access memory RAM because they can be written to or erased by the
which can be read from and, if necessary, written to. processor. However, the convention is to use the term ROM
because erasing and rewriting is expected to be rare.
4.5.2 Systems architecture

Key concept
Bus:
1 Download CPU-Z from [Link] A bus is a collection of wires
through which data/signals
Using CPU-Z record the following:
are transmitted from one
The CPU that your computer is using component to another.
The type of RAM your system is using. The external or system bus
in a computer consists of a
collections of wires providing
pathways between the CPU,
Questions
memory modules (RAM),
chipsets, secondary storage and
2 For each of the two statements below indicate whether the statement
peripherals.
is true or false by choosing the appropriate letter.
ROM is volatile memory.
True Key term
B False Bus width:
The number of bits that can be
RAM used in main memory can be read from and written to. placed on the bus in any one go.
True
B False
Information
The chipset is the link between
System bus the individual components of
A bus is a collection of wires through which data/signals are transmitted a computer, ensuring that all
from one component to another. components can communicate
successfully with each other.
The width of a bus is the number of bits that can be placed on the bus in one Different voltage levels, clock
go. frequencies and protocols
are taken into account and
The external or system bus in a computer consists of a collections of wires converted among each other so
providing pathways between the CPU, memory modules (RAM), chipsets, that the different components
secondary storage and peripherals. of the computer system work
together as intended.
The classic “system bus” is a shared bus.
It has largely disappeared from today’s computer architectures and been
replaced, instead, by different serial and parallel bus systems designed and
developed to meet specific
requirements - Figure [Link].
CPU Memory channel
Although no system-wide system
bus exists in today’s computer
Bus
systems, logically, the manner of
driving memory and peripherals Main Memory
Graphics
controller

controller
Memory

RAM module
has remained the same. Display Chipset
RAM module

Memory channel
Buses
Peripherals
Figure [Link] Shows main memory linked to the CPU via a memory controller located in a chipset module
4 Computer systems

Key term Arithmetic and Logic Unit (ALU)


(Beyond 8525 specification) The Arithmetic and Logic Unit (ALU) performs arithmetic and logical
Static RAM (SRAM): operations on data supplied in registers, storing any result in a register as shown
SRAM is semiconductor in Figure [Link].
memory in which memory
content is stored by means of It can perform, for example, addition and subtraction, fixed and floating point
flip-flops, a type of logic gate arithmetic, Boolean logic operations such as AND, OR, XOR and a range of
circuit with two stable states shift operations.
- flip and flop. Static RAM Information
holds its contents as long as
The ALU3 operation shown in Figure [Link] adds Knowledge of specific
power is available and doesn’t integer 3 to integer -5 to produce the result -2. registers is not required.
need refreshing. However, the
The Status Register indicates a negative result by
consequence is higher power
setting its N bit to 1. In addition to the Status Register three other registers are
consumption than DRAM and
therefore the generation of more used, RegisterA, RegisterB and RegisterC.
heat. ■ A register is a store with its own identity used for storing a single
SRAM is expensive compared
number temporarily.
with DRAM because fewer bits
can be stored per SRAM chip ■ It is usually constructed from the same semiconductor memory type as
than per DRAM chip. Therefore Static RAM or SRAM. This is semiconductor memory which is much
SRAM is restricted to storage of faster to read from and write to than DRAM.
low capacity size, i.e. L1, L2 and
L3 cache or buffer memory and RegisterA RegisterB
registers where its superior speed
of operation can be exploited.
3 5
DRAM is much slower than
32 32
SRAM.

Information
DRAM (beyond 8525 specification) consist
Control
of lots of tiny capacitors each of which store Operation Unit
an amount of electrical charge to represent a
ALU
single bit, more charge for 1 and less charge
for 0.
Even when connected to electrical power, any RegisterC 32
stored charge drains away from the cell quite
quickly so the cell needs to be refreshed every 2 6
few milliseconds to reliably store data. This ZNC OI S
refreshing with electrical charge gives the 32
memory its dynamic name. 0 1 0 010
Information/data stored in DRAM is lost Status Register
when the power is removed. Therefore, Figure [Link] ALU performing an ADD operation
DRAM is said to be volatile (RAM is not
necessarily volatile - see information panel on■ Key term
magnetic core memory on the first page of Register:
this chapter). A register is a store with its own identity used for storing a single number temporarily.
Nowadays, the term RAM has come to mean A central processing unit contains several registers performing different roles.
random-access memory that is both read and Registers are usually constructed from the same semiconductor memory
write. type as Static RAM or SRAM. This is semiconductor memory which is
much faster to read from and write to than DRAM.

3 The remainder of this “Arithmetic and Logic Unit” section whilst useful
to know, covers more detail than required for AQA’s GCSE specification 8525
with the exception of the general role of registers.
4.5.2 Systems architecture

Control Unit
The control unit of the processor shown in Figure [Link] controls fetching, loading and storing operations.4
It fetches an instruction into the Current Instruction Register via the Memory Buffer Register and the data bus.
The control unit also
• Decodes the instruction to determine if it is a load, store, arithmetic operation, or logic operation
• Executes the instruction by
 using the instruction’s operand fields as addresses to use in load or store operations, if required, or
 loading a memory word into a register, or
 changing a word of memory in a store operation, or
 controlling an arithmetic operation, e.g., ADD, or a logical operation, e.g., AND, in the Arithmetic and
Logic Unit (ALU) using as operands the instruction’s operand fields.

Memory Buffer 64 bits wide


RegisterA RegisterB Register
Data
Operand 1 Operand 2
64 64 bus
64 64
Control Unit

Current Instruction
Register

Operation Instruction 32 bits wide


ALU System
Program Counter Address bus
RegisterC 64 Address of 32 32 bus
Next Instruction
Result
6
Memory Address
System Register Control
Status Register Clock bus
Processing
Unit
Figure [Link] Simplified internal structure of a processor/central processing unit

4 The remainder of this “Control Unit” section following this sentence whilst useful to know, covers more
detail than required for AQA’s GCSE specification 8525.
4 Computer systems

Information Clock
Timing: The operations of all components on the motherboard are synchronised by
For the computer system to work the system clock.
properly things must happen at
This is an oscillator which is controlled by a quartz crystal so that it produces
the right time. This is achieved by
timing signals. For example, the very stable and unvarying timing signals similar to those produced by the
correct sequence for writing data quartz crystal controlled oscillator inside a wristwatch.
to memory is first to send out the
Chaos would reign if say, the CPU got out of step with main memory when
address on the address bus, and
then send out the data on the data fetching, decoding and executing instructions. The situation would be akin
bus a few clock ticks later. Finally to missing the bus to school because your alarm clock went off late because it
a pulse has to be sent out on the was running slow.
Write wire to actually write the data
into memory. This is an example of Each component on the motherboard takes the system clock’s timing signals
timing. (a continuous train of on-off pulses as shown in Figure [Link]) and derives
their own timing signals.
Information
ON Continuous train
Intel CPUs are sold to operate at a of ON-OFF pulses
specific, fixed CPU clock frequency
if locked. This clock frequency is set Clock OFF
well below the maximum frequency
at which the CPU can operate. Figure [Link] Continuous train of on-off pulses produced by clock
Therefore, Intel offer a variant for
sale which is unlocked, i.e. the The various buses in the system also need timing signals, their bus clocks are
CPU clock frequency may be varied also synchronised with the system clock and scaled as needed.
considerably. This unlocked variant
is indicated by adding a “k” to the Main memory needs timing signals as well and again these are synchronised
CPU’s identifier, e.g. Intel’s 7th with and derived from the system clock.
generation i7 processors have a fixed
CPU clock frequency version, Intel®
Core™ i7-7700 and an unlocked 1
version, Intel® Core™ i7-7700k. 2 Using CPU-Z obtained from [Link]
The locked CPU has a clock
[Link] record the following:
frequency of 3.6 GHz whilst the
unlocked CPU’s clock frequency The core speed in MHz
may be overclocked up to 4.9 GHz. The multiplier value
(Both displayed values, core speed and multiplier, may fluctuate in
Information CPU-Z, so take the steadiest)
Timing: Calculate core speed/multiplier value. This should be the system
The CPU needs to perform more clock frequency for the motherboard. This is also the frequency of
operations per second than the
the bus connecting CPU to RAM, which is called bus speed.
motherboard, its clock (the CPU
clock), is generated by taking the
system clock and multiplying it by
a number which is either fixed or
Key term
Clock:
if the CPU is unlocked, a number
The operations of all components on the motherboard are synchronised by the
which can be set by the user. If
system clock.
unlocked then the CPU’s clock can
This is an oscillator which is controlled by a quartz crystal so that it produces very
be overclocked by changing a BIOS
stable and unvarying timing signals similar to those produced by the quartz crystal
setting, to give a higher operating
controlled oscillator inside a wristwatch.
clock frequency.
4.5.2 Systems architecture

Questions
3 Four components of a CPU are given below. For each row in Table [Link], choose the letter A, B, C, or D
that best matches the description.
Description Letter
Clock
Decodes the current instruction
Control Unit
A store with its own identity used to store a small
Register
number of bits temporarily
Arithmetic Logic Unit
A source of a continuous train of electronic pulses
Performs a calculation
Table [Link]

In this chapter you have covered:


■ The role and operation of main memory and the following major
components of a central processing unit (CPU) within the Von Neumann
architecture:
• arithmetic logic unit
• control unit
• clock
• register
• bus.
4 Computer systems
4 Computer systems


Learning objectives:
■ Explain the effect of the 4.5.3 Systems architecture
following on the performance
of the CPU: Effect of clock speed on CPU performance
• clock speed To understand the effect of clock frequency on the performance of the CPU we
• number of processor cores need to study a little background first. The following background detail is for
• cache size
information only.
• cache type.
Figure [Link] shows a motherboard example in which
• 133 MHz SDRAM main memory is connected by a 133 MHz data bus to a
1 GHz CPU
Information • The motherboard’s system clock operates at a speed or frequency of 133
Synchronous: MHz
Synchronous means to be in • The motherboard’s BIOS contains configuration datum 7.5 for the CPU
step in time or occur at the same clock multiplier
time.
• The system clock actually oscillates at a frequency of 133.33 MHz, even
though its quoted frequency is 133 MHz.
• The data bus is clocked at a frequency/speed of 133 MHz (133.33 MHz),
the same as the system clock.
• The CPU obtains a value of 7.5 to use as its clock multiplier from the BIOS.
The CPU clock frequency is then generated by multiplying the system clock
frequency by 7.5 giving 1 GHz, a higher frequency than its external data
bus, but still synchronous with it.
The CPU clock frequency is calculated as follows
CPU clock frequency = 133.33 MHz x 7.5 = 1000 MHz = 1 GHz.

Motherboard
CPU

1 GHz
Data bus
CPU (Width 64 bits)
SDRAM
Cell
clock Array

Clock Memory clock


Data bus clock 133 MHz Figure [Link] 133 MHz
multiplier
133 MHz Motherboard with a 1 GHz CPU
and SDRAM main memory

System
clock
133 MHz
BIOS

Clock multiplier value 7.5


4 Computer systems

Clearly, if the system clock is up-rated to operate at a higher frequency then the
components that use the system clock will operate more quickly provided that
these components are also up-rated.
Figure [Link] shows some of these up-rated components on a motherboard
that operates with a system clock frequency of 200 MHz.
Information • The processor now operates at 2.4 GHz, a frequency derived from the
AQA’s specification does not
system clock frequency of 200 MHz multiplied by a clock multiplier of 12.
require you to know the detail
in Figure [Link]. This figure • The bus connecting this processor to the chipset of logic gates driving the
is included here to provide a memory controller and graphics controllers uses a clock frequency of 800
modern context for the theory. MHz. This is derived from the system clock.
• The memory bus uses a clock frequency of 400 MHz as the memory is now
double-rate, double frequency DRAM, DDR2 - see Figure [Link].

Intel LGA775 Processor


CPU clock 2400 MHz
System GHz ock multiplier = 12
Clock 200 MHz 800 MHz System clock x 12 = 2400 MHz
200 MHz
64 bits or
8 bytes
Memory
bus clock
RGB
Analogue Intel G31 400 MHz
video out Graphics 2x DDR2
and DIMM A memory
PCI Express x16
Memory word is 64
Transfer Modules
Card bits or
operations 8 bytes
5 GT/s
800
5 GHZ Direct Media MegaTransfers/s
Interface bus 2 GHz (800 MT/s) Memory
2 GT/s clock
SATA 200 MHz
Sata Intel ICH7
I/O Figure [Link] Up-rated processor,
USB memory and motherboard
USB hub The DDR in DDR2 stands for double-rate. DDR
means that two memory words can be placed on
Data clocked the memory bus in one memory bus clock cycle
onto bus rising SDRAM accessed at
clock signal and Data clocked
- one word on the rising edge and one word on
clock frequency f
falling clock onto bus at clock the falling edge . The 2 in DDR2 means that
signal frequency 2f
memory words are clocked onto the memory bus
I/O at twice the rate of the memory clock.
Cell
Memory Bus The latest DDR memory is DDR4. The meaning
2f
DDR 2 of DDR is as stated above. The 4 means that
Figure [Link] DDR2 main memory module 4 memory words are clocked onto the memory bus
transfers per memory clock, 2 per memory bus clock at four times the rate of the memory clock.
4.5.3 Systems architecture

• Let’s say that the CPU executes an instruction in 2 clock cycles of the Time
CPU clock, on average. ON
CPU
• If the CPU clock frequency is 1 GHz then one clock cycle lasts one clock OFF

nanosecond (1.0 x 10-9 seconds - light travels 30 cm in this time). One clock cycle
1 nanosecond
• A clock cycle is one on-off pulse of the clock signal as shown in Figure Figure [Link] CPU clock
[Link]. cycles for a CPU clock
• Therefore on average, an instruction in this 1 GHz CPU takes 2 frequency of 1 GHz
nanoseconds to execute.
• If the CPU clock frequency is changed to 2.4 GHz, not one but 2.4 Information
instructions are executed in 2 nanoseconds, all other things being
equal. 1 GHz = 1000 000 000 cycles
per second = 1.0 x 109 cycles
However, raw clock speed is not a good way to compare CPUs, unless they are
per second.
from the same manufacturer, model, and family.
The reason is that the average number of cycles per instruction varies between
manufacturer, model and family because CPU architecture can be different.
Information

For example, the first Pentium CPU executed about twice as many instructions Using the scenario from Figure
[Link], main memory is
in a given number of cycles as its predecessor, the 80486 CPU.
Synchronous Dynamic RAM
Therefore, given the same clock speed, a Pentium I is twice as fast as a 80486 (SDRAM) which operates
CPU. Consequently, a 133 MHz 486 CPU (such as the Intel 80486-133) is not synchronously with the data
bus clock signal which itself is
even as fast as a 75 MHz Pentium.
derived from the system clock,
say 133 MHz.
The DRAM’s internal clock, the
Cache Memory
memory clock, operates at the
As CPU processor speeds were increased (i.e. CPU clock frequency increased), bus speed 133 MHz.
memory speeds (memory bus clock frequencies) were unable to keep up. The clock cycle time for the
memory is therefore 7.5
Trying to run a CPU faster than the memory from which it gets instructions nanoseconds.
and data has an adverse effect on CPU performance. It takes several memory clock
Main memory and the memory bus cycles to set up a single read
became a bottleneck (Figure [Link]) access to memory. This set up
time could be as many as 8
that slowed the flow of data and
memory clock cycles or 8 x 7.5
instructions between main memory nanoseconds = 60 nanoseconds.
and the processor in the CPU. Figure [Link] A bottleneck So the total time to read a
single word from memory is
The solution is cache memory. slows the flow
60 + 7.5 nanoseconds = 67.5
In its simplest terms, cache memory nanoseconds.
is a high-speed memory that temporarily stores data/instructions, so that the In this time, the CPU can
execute approximately 34
processor does not have to go to the slower main memory to get every program
instructions on average.
instruction or datum individually. However, it will be held up
Instead the processor can access a whole block of instructions or data pre- waiting 67.5 nanoseconds
until the next word of memory
loaded from main memory into the cache.
arrives.
4 Computer systems

Information Cache memory sits between the processor in the CPU and main memory as
Kibibyte(KiB): shown in Figure [Link].
A kibibyte (a contraction of
kilo binary byte) is a unit Processor Cache Main
of information or computer memory
storage, symbol KiB.
Figure [Link] Cache memory situated between processor and main memory
1 KiB = 210 bytes = 1024 bytes.
However, a cache is more than a simple high-speed memory.
Mebibyte(MiB):
It is designed to hold the data/instructions the processor is most likely to
A mebibyte (a contraction of
mega binary byte) is a unit
need in advance of these actually being needed.
of information or computer This enables the processor to continue working at either full speed or close to it
storage, symbol MiB. without having to wait for the data/instructions to be retrieved from slower main
1 MiB = 220 bytes memory. For this to be achieved, a cache controller (the “brain”) is needed which
= 1048576 bytes
selects and fills the cache memory with just those data/instructions which it
= 1024 kibibytes.
anticipates the processor is most likely to need.
Key term Cache memory is usually made up of static RAM (SRAM).
Cache: SRAM is faster to access than the DRAM used for main memory.
A cache is a smaller, faster Nowadays cache memory is integrated into the CPU whereas a long time ago, it
memory, closer than main was provided in chipsets on the motherboard.
memory to a processor core,
which stores copies of data/
Effect of cache type and cache memory size on CPU
instructions the processor is performance (Cache type not in AQA specification 8525)
most likely to need in advance Typically, processors work with multi-level caches that are different in size and
of these actually being needed. speed - Figure [Link]. The closer the cache is to the processor in the CPU, the
smaller and faster it works.
CPU
If there is more cache, there is a higher probability that data and
Processor
instructions being fetched will be in the cache which is quicker to
Small access than main memory.
size and L1 cache
very fast If instructions and data processed by instructions can be fetched
directly from cache rather than the slower main memory then the
Larger in size
than L1 cache L2 cache time taken to execute a program can be reduced.
but slower
L1 cache / first-level cache
As a rule, L1 cache is not particularly large - 16 to 64 kibibytes1 -
Larger in size thus making it faster to access than L2 and L3 caches which are
than L2 cache L3 cache
but slower larger. This cache is often subdivided into two caches, one for
program instructions and one for data. It runs at the same speed
Cache controller as its CPU. The cache controller in modern CPUs usually has a
hit-rate of around 90%, i.e. 90% of the time the processor gets its
data/instructions from L1 cache.
Considerably
slower than L2 cache / second-level cache
Main memory
L3 cache L2 cache, is primarily used for data - typically 3 x 2048 kibibytes
in size. If in the CPU, it runs at the same speed as the CPU clock.
Figure [Link] Cache memory hierarchy
There is more of it than L1 cache but for this reason it is slightly
slower to access than L1 cache.
1 You are not required to know the units kibibyte and mebibyte. Both are similar but slightly different in magnitude from
the units kilobyte and megabyte which you are required to know.
4.5.3 Systems architecture

L3 cache / third-level cache


L3 cache is the slowest to access of the three types of cache because there is more of it than L1 and L2 cache. It is
used in multi-core CPUs, i.e. CPUs with more than one processor (core) - typically, 8 mebibytes in size. In multi-
core CPUs the L3 cache is often shared amongst the cores. If in the CPU it runs at the clock speed of the CPU.

Questions
1 You try out a newly opened noodles bar and order a bowl of Tom Yum soup which takes 10 minutes to
arrive. You get through this dish in two minutes by eating at the rate of one mouthful every 10 seconds. You
then order Singapore noodles which takes 10 minutes to arrive. You eat this dish at the same rate as before.
To summarise, your eating experience at the noodles bar consists of periods of waiting, followed by short
bursts of actual eating at full speed.
You return to the noodles bar at the same time, twice a week for the next nine weeks, to eat the same two
dishes at the same table. On the third week, your regular waiter anticipates your arrival and orders your
two dishes so that the first is on your table ready for you to eat immediately and the second is on your table
when you finish the first.
If this scenario is considered to model a processor requesting and operating on data from memory then main
memory is the kitchen where the food is prepared and you are the processor consuming data (the food).
To model L1 cache and the cache controller we need to involve the waiter and the table where you are seated.
What role would you allocate to
(a) the waiter?
(b) the table?
(c) Explain your choice for cache controller and L1 cache.

2 On the tenth week you arrive exactly on time and start with the usual Tom Yum soup which the waiter has
anticipated you will, so there is no waiting.
However, just as you finish the soup, and exactly as the waiter is placing the Singapore noodles on your
table, you ask for Penang Laksa. Oh calamity, the waiter has guessed wrong. For you the consequence is a
full ten minute wait as the kitchen prepares your Laksa. In the cache analogy of question 1 this is known as a
cache miss. Suggest how the noodles bar could reduce your waiting time for other dishes, e.g. Penang Laksa,
to significantly less than ten minutes.

3 Explain why having cache memory can improve the performance of the Central Processing Unit (CPU).

1 Download CPU-Z from [Link]


Using CPU-Z record the following for the CPU in your computer:
The size and type of each cache memory.
The CAS latency of DRAM main memory in clock cycles (CAS = delay time between the READ
command and the moment the data is available).
The DRAM clock speed (DRAM frequency).
Calculate the access time to a word of main memory in your computer using your answer to (b) / your
answer to (c).
4 Computer systems

Effect of Number of processor cores on CPU performance


CPU clock speeds cannot be increased indefinitely because of various problems, one of which is heat generation in
the CPU.
CPU manufacturers have settled on a limit of about 4 GHz for CPU clock speed.
In single-core CPUs the processing unit is a single core or processor (registers, control unit, ALU, internal buses).
The restriction imposed by an upper limit on clock speed has led to CPU manufacturers making CPUs with
multiple-cores or processing units. Figure [Link] shows a dual-core CPU in which each core has its own L1 and L2
cache whilst sharing the L3 cache.
With multiple cores, a running application can
spread its processing load (program instructions)
Core Core
across several processing units or cores.
Of course, this requires the executing application
L1 cache L1 cache
to be capable of being distributed across multiple
cores, plus the hardware in the CPU to support this
L2 cache L2 cache distribution.
Essentially, a single program instruction could be
distributed across multiple cores with each core
L3 cache applying this instruction to a different part of the
data to be processed, e.g. different pixels of a bitmap.
Alternatively, different instructions could be
Memory controller
executed in parallel on different parts of the data,
e.g. add, subtract, multiply.
Dual channel
main memory The outcome in both cases is an application that
Main memory
runs more quickly on multiple-cores than it would
channels
on a single core CPU.
Figure [Link] Multi-core CPU consisting of two cores

Not all applications lend themselves to distribution across multiple-cores.


Applications which can benefit from multiple-cores are those in which
a single instruction can be applied to a different part of the data to be
processed e.g. image processing including 3-D rendering (Figure [Link]),
video processing, and audio processing, or where the some of application’s
instructions can be executed in parallel, e.g. machine learning applications.
Many applications do not require considerable computing power, e.g. word
processing, or cannot be divided up in a way that can exploit multiple-
cores. In these types of application a single-core is sufficient. However, an
operating system designed to use multiple-cores can still bring about an
Figure [Link] 3-D scene rendering increase in performance by running more than one application at the same
time, with each application executing on its own CPU core.
4.5.3 Systems architecture

In the history of multi-core processors, the adoption of dual-core CPUs over


single-core CPUs immediately resulted in less power being consumed because
the cores ran at a lower clock rate then single-core CPUs. Performance also
increased especially for those applications able to exploit dual-cores. Having
dual-cores is like having two diesel locomotives pulling a train on a railway
track with an upper speed limit of 100 mph:
• overkill if the load being pulled doesn’t need two diesel locomotives to
achieve the maximum speed
• necessary when the load being pulled is heavy and the maximum track
speed needs to be achieved.
A multiple-core CPU still has to work with a single main memory but their
added complexity has led to the memory controller being integrated into the
CPU in the latest CPUs. The memory controller works with motherboards
that use dual-channel DIMM sockets for memory modules (the modules are
paired). Each channel transfers a 64 bit memory word at the same time. This
fits well with a dual-core CPU with the first channel’s memory word going to
one core and the second channel’s memory word to the other.

Questions
4 Give one reason why a CPU with two cores might perform faster than an equivalent CPU with only one
core.

2 Download PerfMonitor2 from [Link]


Using PerfMonitor2 record the following for the CPU in your computer:
The number of cores.
The L2 cache hit ratio which measures as a percentage the number of times the data required is present
in the cache.
How many cores are more than 5% active at the same time.

3 Run CPU-Z and PerfMonitor2 so that the windows of both are visible.
Switch to the Bench tab in CPU-Z. Leave the reference field unselected.
Click on the Stress CPU button in CPU-Z and note what you observe in the PerfMonitor2 window.
Click on the Stop button in CPU-Z and note what you observe in the PerfMonitor2 window.
4.5.3 Systems architecture

In this chapter you have covered:


■ The effect of the following on the performance of the CPU:
• clock speed
• number of processor cores
• cache size
• cache type.
4 Computer systems
4 Computer systems
Learning objectives:
■ Understand and explain the
Fetch-Execute cycle.
■ 4.5.4 Systems architecture
Fetch-Execute cycle
A machine code program is made up of machine code instructions which are
fetched from main memory, one at a time, and executed in the processor/CPU.
Key term A processor executes each machine code instruction by breaking its execution
into a three-step sequence with the execution synchronised by the system clock
A processor executes each and controlled by the control unit.
machine code instruction by
This sequence of three steps is called the Fetch-Execute cycle or instruction
breaking its execution into a
three-step sequence with the cycle. This cycle is repeated continuously until the CPU is instructed to halt or
execution synchronised by the the last machine code instruction is reached and executed.
system clock and controlled by
The first step is a fetch operation, the second a decode operation and the third
the control unit.
The three steps are: step is execution.
1. Fetch These steps are as follows:
2. Decode
3. Execute. (Fetch phase)
The next instruction to be executed is fetched to the CPU from main
memory
(Decode phase)
The instruction is decoded in order that the CPU knows what operation to
carry out.
(Execute phase)
The instruction is executed, i.e. carried out. This may include reading/
writing from/to main memory.

1 Run and observe the Fetch-Execute cycle at


[Link]
Describe how the machine code program is executed.

1 Processor (CPU) and main memory are two essential components of a computer system. Explain, with
reference to both processor and main memory, how a computer executes a machine code program.

In this chapter you have covered:


■ The Fetch-Execute cycle.
4 Computer systems
4 Computer systems
Learning objectives: ■ 4.5.5 Systems architecture
■ Understand the different types Different types of memory, what they are used for and why they
of memory within a computer: are required
• RAM RAM and ROM - see page 236.
• ROM Cache memory - see Page 244.
Register - see page 238.
• Cache
Differences between main memory and secondary storage
• Register Main memory is directly accessible by the processor (CPU) which is why it
■ Know what the different types once went by the name immediate access store.
of memory are used for and Secondary storage is persistent storage (non-volatile) that is not directly
why they are required. accessible by the processor. Instead the processor must place a request to read or
■ Understand the differences write data to secondary storage with an interface controller.
between main memory and RAM main memory is not persistent storage (volatile). Remove the power and
secondary storage the contents of RAM are lost. Although some parts of main memory may use
■ Understand the differences ROM which is persistent, non-volatile storage.
between RAM and ROM Main memory and secondary storage also differ in capacity and speed of access.
The cost per bit is generally lower for secondary storage than main memory
■ Understand why secondary so affordable secondary storage units can be built with storage capacities far
storage is required
exceeding what is affordable for main memory.
■ Be aware of different types of However, the technology of main memory and its direct accessibility mean it is
secondary storage (solid state, much faster to access than secondary storage.
optical and magnetic) The capacity of main memory is also limited by the fact that it is directly
■ Explain the operation of solid addressable by the processor and processors are designed with a limited address
state, optical and magnetic range.
storage The technology of RAM main memory is different from secondary storage
■ Discuss the advantages and technology.
disadvantages of solid state,
Differences between RAM and ROM
optical and magnetic storage See page 236.
Why is secondary storage used?
■ Explain the term ‘cloud
The technology that primary storage (RAM) is built from and which supports
storage’
read and write random access to individual words/locations requires a
■ Explain the advantages and continuous supply of electrical energy at the correct voltage level in order
disadvantages of cloud storage to work. Unfortunately, when the supply of electrical energy is removed or
when compared to local storage disrupted, the information stored in memory is lost. We say that read/write
■ Understand the term main memory is volatile (analogous to liquids which disappear by the process
‘embedded system’ and explain of evaporation). To retain information and programs after electrical power is
how an embedded system removed requires a different form of storage, one which is non-volatile. There
differs from a non-embedded are three technologies with which such storage is built currently:
system. 1. Magnetic
2. Optical
3. Solid-state.
4 Computer systems

If we want to retain a program we have created in RAM, or some information we have written to RAM, then we
must transfer both to a non-volatile secondary storage device. The commonest form of read/write secondary storage
is a magnetic hard disk encased in a magnetic hard disk drive (HDD) - Figure [Link].
A newer form of read/write secondary store that is now shipping in desktop PCs, laptops and tablets is a solid-state
disk (SSD).
Compact Disc (CD) and Digital Versatile Disc (DVD) storage are optical media that can be used for secondary
storage. There are read only (CD-ROM, DVD-ROM), write once read many times (CD-R, DVD-R) and read/
write versions (CD-RW, DVD-RW) of these.

Questions
1 Why is secondary storage needed?

Platter rotation
Magnetic storage
Magnetic storage comes in two forms:
Read-write
1. Magnetic tape
head
2. Magnetic disk. Read-write Spindle
head radial connected
Magnetic disks movement to motor
IBM developed magnetic disk drives in the late 1950s. The disk drive
allows rapid random (direct) access to large amounts of data.
All disk drives use a thin circular platter made of non-ferrous metal or Platter
plastic which is rotated at up to 10,000 revolutions per minute beneath
a read-write head that moves radially across the surface of the platter.
Figure [Link] Hard disk drive
Figure [Link] shows a hard disk drive with the cover removed. with cover removed
The platter and read-write head can be clearly seen as well as the
photographer’s reflection in the platter. Stepper
motor
The platter is coated with an emulsion of iron or cobalt oxide
Read-write
(or a cobalt-based alloy) particles that act as tiny magnets. head

Binary data is recorded by aligning these tiny magnets in


one direction to represent a binary 0 and in the opposite Sector Track

direction to represent a binary 1. Binary data is recorded in


concentric rings, or tracks, subdivided into sectors that hold a
fixed number of bytes, such as 512. A hard disk can store and Disk block
(one sector
retrieve a large volume of data. of a track)

To read data stored on the hard disk, the read-write head


moves to the desired track and waits for the relevant sector to
Platter
pass beneath it. When data is transferred from the hard disk
to the computer and vice versa, a whole sector of a track is
read or written each time. A whole sector of a track is often Part of one
sector
called a disk block or a block. For this reason, a magnetic Magnetic particle of a track
each encoding a 1 or 0

Figure [Link] Hard disk platter showing


concentric tracks and sectors
4.5.5 Systems architecture

hard disk drive is known as a block-oriented storage device. The smallest unit Key concept
of transfer is a block which is typically 512 bytes. Track:
The top and bottom surfaces of a platter may be used to store data. One of the concentric rings on a
platter of a hard disk.
A block address for a single-platter system is composed of a surface address,
Sector:
a track address and a sector address. Typically, the surfaces are numbered 0
A subdivision of a track.
and 1, the tracks 0 to 7,000 and the sectors 0 to 63. Figure [Link] shows a Disk block:
schematic for one surface of a magnetic hard disk. The smallest unit of transfer
between a computer and a disk.
Modern hard disks for a PC system are sealed units, called Winchester disks,
A disk block is one sector of a
containing several platters mounted on a common spindle. The platters are track.
sealed inside an assembly which allows the disk to operate with minimal risk of
damage from contaminants. The read-write heads are built into the assembly Did you know?
with one head per surface. The greater the number of platters, the greater the In 2015, the fastest rotation
storage capacity. speeds of consumer disk drives
was 10,000 revolutions per
Questions minute.

2 Explain the principle of operation of a magnetic disk drive. Background


Disk buffer:
Executing programs do not
Magnetic tape write directly to magnetic hard
Figure [Link] shows a magnetic tape disks. Instead, they write to an
area of main memory (RAM)
cartridge used to store backup data
called a disk buffer. Before a
or archived data. In late 2017 IBM, program can write to a file,
using a new magnetic tape prototype, it has first to open the file, if
achieved a storage capacity of 330 TB it exists, or create the file if it
of uncompressed data on a palm-sized doesn’t. This open/create action
creates a disk buffer in main
cartridge, breaking the world record and
memory (RAM) which is then
far exceeding any single magnetic hard Figure [Link] Magnetic tape associated with the file. The
drive solution. data cartridge program writes to this buffer.
When the buffer becomes
The information that needs to be stored doubles every two years, tape storage
full or the program closes the
offers the most cost-effective solution. corresponding file, the operating
Tape storage is used extensively in today’s modern data centres for backup and system writes the buffer to disk.
archiving. Numerous studies confirm that the Total Cost of Ownership (TCO) The size of the buffer matches
for tape is much lower than disk when it comes to backup and data archiving the size of a disk block or a
multiple of this.
applications.
To read a file it must first be
opened. This creates a disk
Did you know? buffer which receives a block
Backing up data means taking a copy of data and storing it somewhere safe, e.g. in at a time belonging to the file.
a fireproof safe or off-site. Archiving data means removing it from the online storage The program that opened the
medium, usually to free up space. Data qualifies for archiving if it has not been file then reads from this buffer.
accessed recently and will not be accessed regularly in the future. Programs and data When the buffer becomes
may be backed up and archived. empty, the operating system
transfers the next disk block
IBM obtained the technology for making magnetic disks from Manchester University belonging to the file into this
where a one kilobyte magnetic disk had been made on a one metre-wide platter. buffer.
4 Computer systems

Key fact Optical storage


Optical disc: An optical disc is a flat, usually circular disc which encodes binary data
An optical disc is a flat, usually circular (bits) in a special reflective layer. In one form of optical disc, binary data
disc which encodes binary data (bits) in
is encoded in the form of pits (binary value of 0 due to lack of reflection
a special reflective layer. In one form of
optical disc, binary data is encoded in
when read) and lands (binary value of 1 due to a reflection when read) on
the form of pits and lands on a reflective a reflective material, usually metallic, on one of its flat surfaces as shown
material, usually metallic, on one of its in Figure [Link].
flat surfaces. The pits reflect less light
than the lands and this is used to encode
CD-ROM
0s and 1s. The success of compact discs (CDs) for storing audio led to a new format,
CD Read-Only Memory (CD-ROM). Introduced early in 1985, this
Did you know? format was initially used to publish encyclopedias, reference works,
professional directories and other large databases. CD-ROMs were
Write Once, Read Many (WORM) times ideal for this because they had (for the time) a high storage capacity of
optical disc.
600–700 million bytes, offered fast data access and were portable, rugged
CD-R can record about 650 - 900 MiB
of data. and read-only. Today, CD-ROMs are also used for software distribution.
Magnified view
CD-ReWritable disc that can be read and showing pits in

written to over and over again. layer

Digital versatile disc or digital video disc


(DVD) is an optical standard offering
Label
much greater storage capacity than CDs. layer
Storage capacity of a single-layer DVD-
ROM is 4.3 GiB (4.7 GB).
ective
1.2 mm met al layer
thick
DVD-R is a WORM format similar to
CD-R.

Polycarbonate
The DVD-RW format provides a disc
rewritable optical disc with a typical
capacity of 4.3 GiB (4.7 GB).

A competing rewritable format to


Figure [Link] CD-ROM cross-section through its layers
DVR-RW.
The data is written on the discs using disc-mastering machinery that
DVD-RAM is a rewritable format impresses pits (physical depressions) into a continuous spiral track. The
that has built-in error control and a
defect management system, so it is silvery data surface contains pits in a single track 3.5 miles (5.6 km) long.
considered to be better than the other The disc spins at 200-500 revolutions per minute depending on which
DVD technologies for tasks such as data part of the track is being read.
storage, backup and archiving. The on-
disc structure of DVD-RAM is closely A data bit is read by focusing a laser beam onto a point in the reflective
related to hard disk technology, as it metal layer where the pits are impressed (Figure [Link]).
stores data in concentric tracks.
Blu-ray disc: More laser light is reflected from the unpitted surface than from
A Blu-ray disc (BD) is a high-density the pitted surface. This is detected by a photodiode that outputs an
optical disc capable of storing 23.3
equivalent electrical signal. After some conditioning, the result is a digital
GiB (25 GB) in a single-layer which is
considerably more than a DVD can store. signal representing a single data bit. Without going into the fine detail,
the amount of reflection is used to encode a data bit as 0 or 1.
4.5.5 Systems architecture

Solid state storage


Solid state storage relies on a technology called flash memory derived from EEPROM
technology (electrically eraseable ROM). SD
Flash memory falls into four categories:
memory
1. SD (used in cameras), MMC (used in video cameras), compact flash (used card
in video cameras) and Sony® memory stick (used in Sony cameras and other
products) (Figure [Link])
2. USB flash/stick/pen/thumb drive (Figures [Link] and [Link])
3. Embedded flash (eMMC, UFS)
4. Flash-based solid state drives (SSDs) designed to replace conventional hard
drives (Figure [Link]).
Flash is a type of non-volatile semiconductor memory designed to provide individual
memory cells in an addressable matrix similar to DRAM memory (see Chapter 4.5.2).
The fundamental flash memory cell is based on the floating-gate MOSFET transistor.
A cell stores a bit as a level of electrical charge.
Unlike a DRAM cell, this charge may be stored in a flash storage cell for up to 100
years, it is claimed, and without the need to be connected to any form of electrical
power - hence the label, non-volatile - to retain data. Compact flash
Unfortunately flash memory cells have a limitation that is not present in
SRAM or DRAM memory cells (see Chapter 4.5.2): flash memory cells may
be written to and/or erased only a certain number of times. This may be as
little as 1000 write/erase cycles but it can be up to 100,000.
Writing data to flash memory is done in two stages. The first stage erases the
memory cells involved which consists of setting them all to 1. The second
stage consist of changing those cells that need to be 0. (© Ralf Roletschek [Link])
In general, the individual cells in flash devices all work the same way. Figure [Link]
The difference between flash devices depends to some extent on how these cells are Flash memory cards
arranged and interconnected on the silicon semiconductor chip from which the flash storage is created.

Figure [Link] USB thumb drive


Flash controller

NAND flash

© D-Kuru/
Figure [Link] USB thumb drive interior
Wikimedia
Commons

Figure [Link] Solid-state disk drive


4 Computer systems

Did you know?


There are currently two very different architectures:
• NOR flash: May be written and read down to a single memory word, which can be anywhere from 8 bits to
64 bits.
It is faster to read but slower to write and erase than NAND flash.
It can support in-place execution of code and is commonly used for storing firmware (software that is
retained when the power is removed) in embedded devices.
• NAND flash: has to be accessed in larger units called pages of 512 or 4096 bytes.
Pages are combined into blocks of typically 16 KB or more.
NAND flash is read and written in pages, but erased only in blocks. Fresh pages for writing to can only be
obtained from an erased block.
The smallest unit that may be read or written to in a single operation is a page.
However, to change a page a copy is altered, and then written to a page that has not been written to since
erasure (all bits will be set to 1 after erasure).
This means that NAND flash does not allow data to be rewritten "in place" which would be necessary for
operation as RAM.
Therefore, in-place execution of code is generally not possible due to lack of support for rapid random access
to the flash array of cells.
Instead, NAND flash was designed to act as mass storage (secondary storage) rather than non-volatile RAM.
Cameras use NAND flash memory in the form of SD cards. Cameras use the fact that NAND flash is faster
to write but is slower to read which is perfectly acceptable when storing photographic images for processing
later in image processing software such as Adobe® Photoshop.
eMMC
This type of flash storage is soldered to a circuit board for a smartphone
or a tablet and therefore is not removable storage. It goes under the name
embedded MMC or eMMC where MMC is short for Multi-Media
Controller which refers to a package consisting of flash memory and a
flash memory controller. Almost all mobile phones and tablets use this
form of flash for main storage. The latest version of the eMMC standard
eMMC flash memory
(released February 2015) has speeds rivalling discrete SATA-based Solid
State Drives (400 MB/s). Figure [Link] shows eMMC soldered to the Figure [Link] eMMC 512KB
Tiva microcontroller board.

Flash-based Solid-state disk (SSD)


The solid-state disk (SSD) in a solid-state disk drive (Figure [Link]) is a form of flash memory which operates by
trapping electrons in a wafer of semiconducting material. These electrons and their electric charge remain trapped
even when electric power is removed, i.e. SSD is non-volatile storage. Binary 0 is represented by trapped electrons
and binary 1 by absence of trapped electrons.
The sites (floating gate transistors) where these electrons are trapped are organized in a grid. The entire grid layout is
referred to as a block, while the individual rows that make up the grid are called a page.
Common page sizes are 2KiB, 4KiB, 8KiB, or 16KiB, with 128 to 256 pages per block. Block sizes are typically
between 256KiB and 4MiB. For example, the Samsung™ SSD 840 EVO has blocks of size 2MiB, and each block
contains 256 pages of 8 KiB each. The Samsung SSD 840 EVO comprises 8 NAND flash chips, each of capacity 64
GiB. Each Samsung flash chip contains 32 blocks.
4.5.5 Systems architecture

Unlike magnetic disk drives, solid-state drives contain no moving parts or spinning disks. The absence of moving
parts means that solid state disk drives can operate at speeds far above those of a typical hard disk drive.
Access time for a typical hard drive is on average 10-15 milliseconds whereas access time for an SSD drive is 25-100
microseconds (access time for RAM is typically 40 -100 nanoseconds).
The technology used is NAND flash memory.
A solid-state disk is a block-oriented storage device which has to erase a block first in order to rewrite it because
unlike magnetic hard disk drives, NAND flash memory can’t overwrite existing data. Erasing a block in the SDD
means “untrapping” electrons.
The solid-state disk drive requires an onboard controller which consists of an embedded microprocessor with RAM
buffer to perform reading and writing to the solid state disk (Figure [Link]). The controller is a very important
factor in determining the speed of the SSD drive.
Figure [Link] SSD drive printed SSD SSD
circuit board (PCB) showing the Controller PCB
controller and the NAND flash
memory chips

Image reproduced with


kind permission of
[Link]

SATA NAND
Interface Flash
Memory

To alter the contents of a particular memory location of SSD storage, an entire page must be constructed containing
the new information and written to a page which is in the "free" state, i.e. has not been used since erasure.
When data is changed, the content of the page is copied into an internal register, the data is updated, and the new
version is stored in a "free" page, an operation called "read-modify-write".
SSD secondary storage is increasingly being used in laptops, tablets and is an option now for desktop PCs. The
attraction is lower power consumption and faster booting of the operating system.
Pages cannot be overwritten, and once they become stale, i.e. used but data stored is no longer needed, the only way
to make them free again is to erase them. However, it is not possible to erase individual pages. It is only possible to
erase whole blocks at once. Erasure is triggered automatically by a garbage collection process in the SSD controller
when it needs to reclaim stale pages to make free space.
Questions
3 Explain how data is written to flash memory.

4 In what devices or systems are the following flash memories used:


(a) eMMC? (b) Compact flash? (c) SSD?
4 Computer systems

Advantages and disadvantages of solid state, optical and magnetic storage


A flash memory device is solid-state, i.e. has no moving parts, it is therefore less
Information
affected by shock than a spinning magnetic disk.
SSD vs other flash-based
Flash memory is ideal as non-volatile RAM (NVRAM) in tablets and mobile devices:
phones and can also store the devices’ operating system including the file system. SSDs are much faster than any
Wear-level management in flash NVRAM is now very good and operating of the other flash-based portable
drives, e.g. USB thumb drive.
systems used in most tablets and mobile phones are not a Windows-based design
which would soon wear out the flash memory by frequent writing of registry
settings to NVRAM (every second).
SSDs consume less power than magnetic disk drives but the latter offers a more cost effective storage solution. In
2017 SSDs are more expensive than hard drives in terms of pound sterling per gigabyte.
A PC or Mac with an SSD boots faster, launches and runs applications faster, and transfers files faster than magnetic
hard disk.
There is a limit to how small magnetic hard drives can be manufactured because they rely on spinning platters.
SSDs have no such limitation, so they can be made to fit a form factor much smaller than the smallest magnetic
hard disk form factor which is currently at 1.8 inches.
Even the quietest hard drive emits noise when it is in use from the drive spinning or the read arm moving back and
forth. Faster hard drives will make more noise than those that are slower. SSDs make virtually no noise at all, since
they are non-mechanical.
Both flash and optical storage are more portable than magnetic disk drives. The former are removable media
whereas the latter are not meant to be removed from a computer system.
Both magnetic disk and SSD storage have been optimised for high speed access, DVDs and CDs are fast enough to
play movies and music but are slower than magnetic disks and SSDs.
Optical media and their drives are considerably cheaper than magnetic disk drives and SSDs (but not when
compared per byte).
Magnetic disks and SSDs have storage capacities much greater than current optical media. Blu-ray optical disks can
store up to 50 billion bytes (25-50 GB) whereas magnetic disk drives and SSDs currently can store trillions of bytes
(TB). In 2017 Seagate® announced a 60 TB SSD.
Optical media can suffer damage from surface scratches which can render them useless. Magnetic disks and flash
devices have greater protection because they are located inside protective sealed units. However, unlike optical and
solid state media, magnetic disks can be damaged by strong magnetic fields.

Questions
5 An SSD device is a type of solid state storage.
State two advantages of solid state storage compared to magnetic storage.

6 Why are optical media not suitable as general purpose secondary storage but instead are used for backing up
data and distributing software?

7 Some desktop computers have both magnetic hard drives and solid state drives.
What would each be used for and why?

8 Describe how data is stored on, and read from


(a) a magnetic hard disk (b) a CD-ROM.
4.5.5 Systems architecture

Cloud storage
Figure [Link] shows the interior of one of
Google’s data centres which provides remote
storage for multiple users in racks of commodity
servers with hard disks or solid state disks
attached.
Users access this remote storage over the Internet
through a web-based interface.
An example of a web-based interface is shown in
Figure [Link] for CertainSafe®’s cloud storage
service.
Users pay only for the storage capacity used
Figure [Link] Racks of commodity servers with storage at
(beyond a certain capacity in the case of some
one of Google’s data centres (image Google/Connie Zhou)
providers, e.g. after 2GB).
Cloud storage is a storage service in
which data is stored on remote servers
accessed from the Internet, or "cloud", and
maintained, operated and managed by a
cloud storage service provider on storage
servers that are built on virtualisation
techniques (Figure [Link] shows some
of Google’s server racks in a data centre).
Cloud storage is scalable on demand
according to users’ needs and made possible
by virtualisation.
In virtualisation a single physical computer
is "broken" into smaller pieces, with each
Figure [Link] CertainSafe®’s Digital Safety Deposit Box
one able to act like a computer of its own,
web interface
a virtual computer. Cloud computing
enabled the building of large clusters of physical Block 1 Block 3’
computers, which could then be leased out as
smaller virtual ones by the hour. Block 3 Block 1’

Virtualisation enables storage hardware to Block 2’


appear as a single unit of local storage belonging
to one user or organisation when in fact the Block 2
storage hardware may be located across several
servers in different server racks as shown in
Figure [Link]. These servers and their storage Server +
Disk Drive
units store data belonging to many users and
organisations without the latter being aware that 1 2

this is happening. Figure [Link] The data blocks of a user’s file may be spread
and replicated three times over several hard disks or SSDs in
several servers in different racks
4 Computer systems

Each user gets a container to store their data. The container has a globally unique name and a few other options
which the user can set such as the type of disk required (SSD or magnetic) and where this disk should live (ie,
Europe or the US). The big difference is that this "disk" is extraordinarily large in that there’s no limit to how
many bytes can end up in a container. The only limit is that each file in the container can be up to 5 Terabytes. The
container itself is replicated and spread across many physical disks in order to maintain high levels of durability and
availability - see Figure [Link].
Some examples of cloud storage services available to the general public are Microsoft® OneDrive, Google® Drive,
Apple® iCloud, Dropbox, and CertainSafe Digital Safety Deposit Box.
Advantages and disadvantages of cloud storage compared with local storage
Advantages of cloud storage compared with local storage
1. Files stored in the cloud and accessible from the Internet:
(a) May be accessed from anywhere, e.g. from smartphone on the train, from tablet in your hotel room. With
local storage only, a file on a system at work or school cannot be accessed away from work/school without
taking a copy home. With no local storage a file may still be accessed, e.g. from smartphone with Internet
access.
(b) May be accessed from any computer with an Internet connection, e.g. smartphone, tablet, laptop,
desktop.
(c) Can be shared and worked on by more than one user making collaboration possible. The cloud service
manages the collaboration by queuing edits so that none are lost or overwritten.
(d) Avoids working with separate local copies instead users can jointly work on the cloud copy of the file,
e.g. a document, performing edits, adding comments etc, which all can see.
(e) Avoids having multiple out-of-sync copies scattered across local storage on different systems which on
merging can result in the loss of vital edits/changes if overwritten.
(f) Don’t have to rely on carrying files around on USB thumb drives/memory sticks which could
get lost or stolen easily or have to rely on email to send files to yourself. Instead, users undergo an
authentication process to secure access to the files in the cloud.
2. Files stored in the cloud:
(a) As a part of their support for collaboration some cloud providers also offer office productivity tools such
as word processing as part of the deal which otherwise would have to be paid for separately if processing is
done with files in local storage.
(b) If files are downloaded from the cloud to be worked on locally and offline (i.e. not connected to the
Internet), cloud storage services usually provide a mechanism by which the cloud copy can be
synchronised with the updated local copy when it comes back online. This relieves users from managing
the syncing of multiple local copies of the same file in a way that preserves all the edits/changes.
(c) Relieves the user of backup management. The cloud service provider usually offers this as part of the
service.
(d) Users of cloud storage services also do not have to worry about local hard disk crashes/damage due to
natural disasters such as fire or flooding because their files are now stored in redundant storage arrays in
the cloud, the maintenance of these being the responsibility of the cloud service provider.
(e) Users of cloud storage services do not have to worry about loss of data and loss of privacy from someone
breaking into their home, stealing their computer and then examining the contents of the local storage
unit.
(f) Cloud storage can be an exceptionally good fit for situations where you don’t know (or can’t know)
what your storage will look like, either many years in the future, or tomorrow. Anytime a situation
arises where more storage is needed the elastic nature of cloud storage will meet this need quickly and more
cheaply than purchasing more local storage capacity with attendant configuration issues.
4.5.5 Systems architecture

Disadvantages of cloud storage compared with local storage


1. When you use cloud storage you are relying on storage in a data centre which doesn’t belong to you unlike
local storage. This means giving up some control over your assets (such as data or program source code)
in exchange for other benefits (such as flexibility or lower costs).
You can expect your data to be stored in encrypted form in the Cloud. In one cloud storage scheme, the
cloud storage provider keeps a copy of the encryption key so when you ask for your data, it can be returned
to you decrypted. However, this also means if the cloud storage provider were to receive a court order, they
do have the technical ability to comply with it and decrypt your data without your consent.
2. Cloud service providers are high profile and subject to concerted and sophisticated attacks from
hackers. Several of the well-known providers have suffered security breaches. Dropbox had to fix a security
hole recently, and got breached a few years ago. Google Drive, OneDrive, and Dropbox accounts are
vulnerable to man-in-the-middle attacks.
3. Most cloud storage providers charge a subscription for storing users’ data with only a small amount of
storage being subscription-free. This is an ongoing cost which must be compared with the one-off cost of
local storage. Other factors need to be considered such as the cost of Internet access and the speed of access.
4. Without Internet access you will not be able to access your files in cloud storage.

Questions
9 What is cloud storage?

10 Discuss the advantages and disadvantages of cloud storage.

Embedded system
We can think of a laptop as a computer which can be used to do all sorts of things users want to do from surfing the
Web to word processing essays. For this reason a laptop is considered a general purpose computer system. But this is
not the only type of computer system.
Another type is an embedded computer system.
Loosely defined, an embedded computer system is any device that includes a programmable computer but
is not itself intended to be a general purpose computer. For example, a clock built from a microprocessor is an
embedded computing system as is a washing machine with a microprocessor-controlled washing cycle.
Many of today’s cars operate an embedded computer system with over 100 million lines of code running on 40 to
100 microprocessors monitoring whether seat belts are in use to managing and controlling the running of the car’s
engine.
Another example of an embedded system is a portable music player. The cheapest portable music players are
essentially USB thumb drives with a two-line LCD display, a headphone jack and a couple of buttons. To reduce
cost, the audio codecs and UI manager on such devices often run in the flash controller microprocessor alongside
the flash controller software. Music is saved to flash memory so that it is retained when the portable music player
is switched off. USB thumb drives need only about 512 bytes of volatile RAM for buffering a page to be written to
flash memory. Therefore, a portable music player will have much more non-volatile memory than volatile memory.
The programs to decode and play the stored music, and music data are stored in and accessed by the processor from
flash memory - Figure [Link].
4 Computer systems

SRAM Volatile RAM

Processor System bus Flash Non-volatile RAM


Memory

Figure [Link] Portable music player


Characteristics of embedded systems
An embedded system has a dedicated purpose, has a limited or non-existent user interface, and is designed to
operate completely or largely autonomously within other machinery, e.g. an engine management system. They
also have limited memory capacity.
Operating systems for embedded systems are designed to work with the constraints of limited memory size and
limited processor performance. In portable embedded systems, the operating system must also take account of
limited battery life.
Characteristics of non-embedded systems
Non-embedded systems do not suffer the constraints of embedded systems. They form the bedrock of general
purpose computers and as such have operating systems which are much more complex and powerful than
embedded operating systems. They will have more volatile RAM secondary storage, more powerful processors
(CPUs), probably multicore. They are also likely to have separate graphics processors (GPUs) and support to
plug expansion boards such as graphics cards into the motherboard. They will have a user interface, usually both
graphical and command line (text-based). They will support a wide range of peripherals from mice and keyboards
to printers, scanners and DVD players.
Questions
11 What is meant by an embedded system?
12 Explain how an embedded system differs from a non-embedded system.

13 Give one example of an embedded system and one example of a non-embedded system.
14 Embedded systems normally have less volatile RAM in main memory and more non-volatile RAM or
ROM than non-embedded systems. Explain why?

In this chapter you have covered:


■ The different types of memory within a computer: RAM; ROM; Cache; Register
■ What the different types of memory are used for and why they are required
■ The differences between main memory and secondary storage
■ The differences between RAM and ROM
■ Why secondary storage is required
■ That there are different types of secondary storage (solid state, optical and magnetic)
■ The operation of solid state, optical and magnetic storage
■ The advantages and disadvantages of solid state, optical and magnetic storage
■ The term ‘cloud storage’
■ The advantages and disadvantages of cloud storage when compared to local storage
■ The term ‘embedded system’ and how an embedded system differs from a non-embedded system.
5 Fundamentals of computer networks
5 Fundamentals of computer networks
Learning objectives:
■ Define what a computer
network is
■ Discuss the advantages and ■ 5a Computer networks
Key term
disadvantages of computer What is a computer network?
networks Computer network:
A computer network is a collection of connected
■ Describe the main types of computers.
A computer network is a
computer network including: collection of connected
Figure 5.1 shows three computers, labelled Host
• Personal Area Network A, Host B and Host C, connected together via a
computers.
(PAN)
switch and cabling. The switch could be an Ethernet switch such as the one
• Local Area Network (LAN) shown in Figure 5.3 operating as shown in Figure 5.4.
• Wide Area Network
(WAN)
■ Understand that networks can Cable
be wired or wireless
■ Discuss the advantages and
disadvantages of wireless
networks as opposed to wired Host A Host B Host C
networks
■ Describe the following
Figure 5.1 Wired computer network
common LAN topologies: The connection between computers can be done with cabling, in which case
• star the connection is said to be wired, or with radio waves, in which case the
• bus connection is said to be wireless.
■ Define the term network Computers on a network are called hosts or nodes.
protocol. Questions
1 What is a computer network?
Switch
Advantages of networking
Cable Computers are connected together in a network so that resources such as a
printer or a file server or a connection to the Internet may be shared amongst
computers in the network. Communication between computers is also
improved which means that updates and new software may be installed from
Figure 5.3 Ethernet switch a centrally managed server. The activities of computer users may be also be
with exposed CAT 5 cable
showing four wires, two per monitored centrally by observing network traffic. Users benefit because their
circuit (one outgoing, one work may be backed-up and managed centrally, and users will be able to store
incoming) and access their files centrally from any computer.
File
server

Switch File server


Print
server
Host A
Router
Internet

Print

B Switch Router

Figure 5.4 Internal operation Printer


of switch connects two nodes
Figure 5.2 Network
together temporarily so that they
which enables sharing of
can communicate with each other. Host B Host C
resources
5 Fundamentals of computer networks

Questions
2 Give three examples of the advantages of connecting computers in a network.

Disadvantages of networking
Local area networks (LANs) share data, processing and communication. Therefore they are at risk of the following:
1. As the geographical area spanned by a LAN increases, say from a single office to a building and then
a site, so does the chance of interception and leakage of information especially if the network is
wireless.
2. An unauthorised user gaining access to one computer may then have access to the whole network
including sensitive and confidential information stored on a file server.
3. A virus downloaded on one computer may then go on to infect other LAN-connected computers.
4. A single point of failure, e.g.
a. central switch failure may bring down the operation of the whole network denying all users
access to their data stored on a network file server.
b. failure of a domain server used to authenticate users will prevent users from logging in and
being able to use network resources.
c. file server failure will mean that users’ files will become inaccessible.

Questions
3 Give three examples of the disadvantages of networking.

Information
The main types of computer network PAN - Only Bluetooth
needs to be considered.
Personal Area Network (PAN)
A personal area network (PAN)
is a computer network organized
around an individual person, and
that’s set up for personal use only. A
PAN typically involves a computer,
mobile phone, tablet and/or some
other personal device like bluetooth
headphones. Figure 5.5 shows
an example of PANs in use at an
airport.
Personal area networks can be
wireless (Bluetooth, ZigBee,
Wireless USB, IrDA, an infrared
connection) or constructed with
cables (wired PAN using USB or
FireWire). Wireless PANs are called Figure 5.5 Use of PANs at an airport - for PDA read tablet computer
WPANs.
5a Computer networks

The reason PANs are classified apart from other network types like LANs, Key term
WLANs, and WANs (see later in chapter for a description of these network
types) is because they transmit information between devices that are nearby. Pan Area Network (PAN):
A personal area network (PAN)
For example, a Bluetooth enabled keyboard connects to a nearby tablet which is a computer network organized
itself may control a nearby smart light bulb. around an individual person,
and that’s set up for personal
A PAN might also consist of small, wearable or embedded devices that can
use only. A PAN typically
communicate upon nearby contact with other wireless devices.
involves a computer, mobile
The reach of a PAN varies from a few centimetres to several metres depending phone, tablet and/or some other
on the technology used. personal device like bluetooth
headphones.
Although PANs are personal, by definition, they can still access the Internet by A PAN transmits information
connecting to a LAN which has access to the Internet. between devices that are nearby,
e.g. a few centimetres or metres
Questions away.
4 What is a Personal Area Network (PAN)?

5 Give two examples of the use of a PAN.

Local Area Network (LAN)


Key term
Local area networks (LANs) emerged in the early 1970s when companies
realised that desktop computers could share peripherals, such as printers, and Local Area Network (LAN):
could share data, if all were interconnected. A Local Area network consists
of linked computers in close
The interconnections became the local area network.
proximity, e.g. a single building
A computer that is not interconnected is known as a stand-alone computer. or site occupying a relatively
A stand-alone computer needs its own printer, hard disk storage, and local small geographic area.
installation of application software whereas LAN-connected computers can
share printers, hard disk storage and download application software from an
application server.
Figure 5.2 shows an example of computers sharing the following resources via
Information
Difference between a wireless
a LAN: a printer and print server, a file server and a connection (router) to the
PAN and a wireless LAN:
Internet. Conceptually, the difference
LANs cover a relatively small geographic area such as a single building or a between a PAN and a wireless
school site. The close proximity of computers to each other in a LAN enables LAN is that a PAN tends to be
communication links to be used that have higher speeds and lower error rates centred around one person while
a wireless LAN is a local area
than in wide area networks (WANs).
network (LAN) that is connected
LAN ownership
without wires and which serves
LANs are usually owned and controlled/managed by a single person if it is a multiple users.
home network, or an organisation if it is, for example, a school network. Some other examples of wireless
PAN, or WPAN, devices
Questions include mobile phone headsets,
wireless mice, printers, bar code
6 What is a Local Area Network (LAN)? scanners and game consoles.
5 Fundamentals of computer networks

Wide Area Network (WAN)


Wide Area Networks (WANs) were invented to solve the problem of connecting a LAN to a distant computer or to
a remote LAN - Figure 5.6.
LANs are perfect for sharing Link
resources within a building
or over a single site, but they Router

cannot be used to connect


distant sites.
Wide Area Networks serve this
need.
Expressed simply, a wide area
network is a set of connections
Router Switch
between geographically remote
local area networks.

Key term
Wide Area Network (WAN):
Figure 5.6 A WAN linking computers in geographically remote locations
A set of links that connect
geographically remote
computers and local area Questions
networks. 7 What is a Wide Area Network (WAN)?

The Internet WAN


Key fact When two LANs are interconnected by a WAN so that computers or nodes
Internet:
on one network are able to communicate with computers or nodes on the
The Internet is the largest other network, and vice versa, the two LANs are said to be internetworked
example of a WAN. or to form an internet (note the use of lowercase “i”). The publicly accessible
internet known as the Internet is the largest example of a WAN.
WAN ownership
A WAN has to operate at high-speed, with high bandwidth connections and high-performance routers connecting
together LANs.
This connection infrastructure is sometimes referred to as the backbone of the WAN.
WAN backbones are expensive to install, operate and maintain.
For this reason WANs are often under collective or distributed ownership.
For example in the UK, Janet (Joint Academic NETwork) is the name of a high-speed network for the UK’s
research and education community. It is owned by JISC, a not-for-profit company that was originally set up and
funded directly by the British government. This WAN connects universities, Further Education (FE) colleges and
research establishments in the UK from Lands End to John O’Groats and everywhere in between.
It serves some 18 million users and has over 5,000 km of optical fibre capable of running at either 100 Gbit/s or 2
Tbit/s.
Each university, FE or research establishment owns and operates its own LANs but all rely on the JISC-owned
backbone to interconnect these LANs. They pay money to JISC for the privilege of being connected to Janet.
5a Computer networks

Questions
8 Give three reasons why WANs are often under collective or distributed ownership.

Who owns the largest WAN in the world, the Internet?


Global internetwork or the Internet
The physical network that carries Internet
traffic between different computer systems University
campus North Central and
is the Internet backbone system. America South America

It is split into continental and national


backbones - Figure 5.7.
These backbones are owned by a number Home
user
of different commercial companies or
state-owned companies (e.g. People’s Internet Far East and
Service Pacific
Republic of China) but these companies Provider

have restricted control and ownership over


Middle East Africa
the Internet because it was designed to: School
network Europe
1. Not rely on any form of central
control Continental and
Figure 5.7 The physical national backbones
2. Use global network policies structure of the Internet
determined by independent Information
public bodies not by companies There are many organizations,
corporations, governments,
3. Rely on the end-to-end principle, i.e. the hosts/nodes at each end of the schools, private citizens and
communication are given control of their communication. service providers that all own
For the above reasons, we say that ownership of the Internet is distributed. pieces of the infrastructure, but
there is no one body that owns
Wired and wireless networks it all.
Wired networks use different kinds of cabling to carry data depending on speed No one actually owns the
Internet, and no single person
and bandwidth requirements. The two main choices of material for the physical or organisation controls the
wiring of a wired network are Internet in its entirety.
1. Copper
2. Fibre optic.
Fibre optics refers to technology that transmits data through thin strands of a highly transparent material that
usually is either glass or plastic.
Fibre optic transmission is faster then copper wire and when Questions
travelling over a long distance, fibre optic cables experience 9 Give two reasons why wired networks
less signal loss than copper cabling. might be preferred to wireless networks and
Wireless networks use radio waves to carry data. two reasons why wireless networks might be
Advantages and disadvantages of wireless networks as preferred to wired networks.
opposed to wired networks
Wireless networks eliminate much of the cost of cabling that occurs with wired networks but may not provide as
much bandwidth as wired networks, i.e. wireless networks could be slower. However, it is usually much easier and
cheaper to add extra devices via Wi-Fi to a wireless network than to cable these devices to a wired network. Also, the
wired option is not always possible because some wireless devices don’t support a wired connection. Wireless devices
are more flexibly relocated because no re-cabling is involved, e.g. can be used outdoors, but depending on location
may suffer from an unreliable signal and therefore disruption to transmissions.
But care has to be taken because now that communication takes place via radio waves, transmissions are much
easier to intercept than is the case with wired networks.
In a wireless network without encryption, it is possible to eavesdrop on traffic intended for other computers.
5 Fundamentals of computer networks

Key term Star network topology


Topology: In the star network topology, cabling is configured as shown in Figure 5.8 as a
In the context of networking, star.
the shape, layout, configuration
The centre of the star is either a network switch or a central computer.
or structure of the connections
that connect devices to the
network.

In a traditional star network, each link from node to central switch


computer is an independent link. Each link is therefore secure
from eavesdropping by other nodes.
If a link to a node goes down, the other links and nodes are
unaffected. However, if the central computer / central switch goes
down, the whole network will fail.
Figure 5.8 Star network topology
In a true star-based network, the speed of each link to the central
computer should remain high, because the links are not shared. Computer
Bus network topology
Figure 5.9 shows the layout of a bus network.
Each computer “taps in” to the transmission medium, i.e. the bus.
Bus networks used to be cabled with coaxial cable, a form of copper cable.
Bus
Each computer was then physical attached to coaxial cable via taps called
T-piece connectors - Figure 5.10 and Figure 5.11.

Computer
Computer Computer

T-piece connector Linear transmission medium or bus Figure 5.10 Bus


network topology Figure 5.9 Bus network topology

A bus is a linear transmission medium.

The same linear behaviour is now achieved with a switch


Computer
and CAT 5 cabling as shown in Figure 5.3 and Figure at end of Computer
5.4, at the beginning of this chapter, even though the bus
wiring to the switch resembles a star network.
The bus transmission medium is a shared medium, only
one computer can send at a time. In the coaxial-cabled
bus network this means that every connected computer is
able to “see” each transmission. A computer then selects
the transmissions it should receive based on the address T-piece
information contained in the transmission. In a switch- cable connector
cabled network only two computers are ever connected as
Figure 5.11 Bus network using coaxial cable
a bus, at a time, so only these see their transmission.
5a Computer networks

Questions
10 Describe the network topologies star and bus.

When would each topology be used?


The wired bus system in which each computer on a network is connected directly Information
to the next computer in a linear fashion is now obsolete.
Ethernet bus and wired-as-a-
This network topology was originally used because running a single cable past
star network:
all the computers in the network was easier and used less wiring than other
Ethernet lives on in the wired-
topologies. as-a-star network that uses
The network connection would start at the server and end at the last computer in a switch at the centre of the
the network - see Figure 5.9. star configuration. The switch
creates a temporary and short
The original wired-as-a-bus network used a networking protocol called Ethernet.
duration linear Ethernet bus
Ethernet lives on in the wired-as-a-star network that uses a switch at the centre of connection/pathway between
the star configuration. two network computers that
The switch creates a temporary and short duration linear Ethernet bus wish to communicate.
connection/pathway between two network computers (Figure 5.4) that wish
to communicate. At the end of the communication, the connection is broken so that another two computers may
connect temporarily. The temporary linear connection behaves as a bus.
With the wired-as-a-star switch network, each sending client computer (host) is able to use the full bandwidth
of the network when transmitting because no data/packet collisions will occur with other sending computers (a
temporary link is made between sending and receiving computer).
It is also easy to connect new devices and the failure of one client computer will not affect others. Also,
eavesdropping (packet sniffing) is made difficult as the packets are only sent to the intended device.
In the now obsolete coaxial cable wired-as-a-bus networks, packets could be sniffed because the bus cabling was a
shared medium. Also, as the bandwidth was shared by all the computers, performance could be slower then wired-
as-star switched bus networks because data/packet collisions occur. There is a noticeable and significant gain in
performance of wired-as-star switched bus networks over wired-as-a-bus networks.
Coaxial cable bus networks were first replaced by hubs which effectively allowed the network to be wired as a star
but behaviour was equivalent to the shared bandwidth bus medium it replaced. It was only the transition from
Ethernet hubs to Ethernet switches that brought about the improved performance.

Questions
11 An Ethernet bus network is wired as a star using a switch.
Explain how this wired as a star network topology behaves as a bus network.

12 State two advantages of the wired-as-a-star Ethernet bus network over the wired-as-a-bus Ethernet bus
network.

Network protocol
A protocol provides agreed signals, codes and rules for data exchange between systems.
A network protocol makes possible communication between processes executing on different hosts whilst hiding the
complexities of the underlying network from these processes. (A process is an instance of a program in execution).
5 Fundamentals of computer networks

In this chapter you have covered:


Key term
■ Defining what a computer network is Network protocol:
■ The advantages and disadvantages of computer networks A network protocol makes
possible communication
■ The main types of computer network including:
between processes executing on
• Personal Area Network (PAN) different hosts whilst hiding the
• Local Area Network (LAN) complexities of the underlying
• Wide Area Network (WAN) network from these processes.
A process is an instance of a
■ That networks can be wired or wireless
program in execution.
■ The advantages and disadvantages of wireless networks as opposed to wired
networks
■ The following common LAN topologies:
• star
• bus
■ The definition of the term network protocol.
5 Fundamentals of computer networks
5 Fundamentals of computer networks
Learning objectives:
■ Define the term ‘network
protocol’
■ 5b Network protocols
What is a network protocol?
■ Explain the purpose and use All communication needs protocols so it goes smoothly and without errors. A
of common network protocols
protocol is a set of agreed signals, codes and rules for data exchange between
including:
systems. A network protocol makes possible communication between processes
• Ethernet executing on different hosts whilst hiding the complexities of the underlying
• Wi-Fi network from these processes. (A process is an instance of a program in execution).
• TCP (Transmission Control Questions
Protocol) 1 What is a network protocol?
• UDP (User Datagram
Protocol) Common network protocols
Ethernet
• IP (Internet Protocol)
A computer communicates on the network through a network interface card or
• HTTP (Hypertext Transfer
Protocol) network adapter. A network adapter plugs into the motherboard of a computer
and into a network cable or it may already be integrated into the motherboard.
• HTTPS (Hypertext
Network adapters perform all the functions required to communicate on a
Transfer Protocol Secure)
network. They convert data between the form stored in the computer and the
• FTP (File Transfer
form transmitted or received on the cable (Figure 5.12).
Protocol)
Serial data flows from the network
adapter card on to the network
• Email protocols: Network
 SMTP (Simple Mail adapter
card
Transfer Protocol)
 IMAP (Internet Parallel data flows from the
Message Access computer’s motherboard
to the network adapter card
Protocol).

Computer
motherboard

Figure 5.12 Network adapter or network interface card(NIC)


The data is transmitted in packets called frames. The format and size of a frame is defined by the Ethernet bus
protocol, a Local Area Network (LAN) protocol.
Figure 5.13 shows this frame structure. Note that the data part of the frame can be any number of bytes between
46 and 1500, inclusive. For error detection

Destination Source
Type Data CRC
address address

6 bytes 6 bytes 2 bytes 46 - 1500 bytes 4 bytes


Figure 5.13 Ethernet frame
5 Fundamentals of computer networks

Ethernet is a family of related protocols. The family supports three different transmission speeds:
• 10 Mbps (standard Ethernet)
• 100 Mbps (fast Ethernet)
• 1000 Mbps (gigabit Ethernet).
It uses 48-bit addresses for both destination (where the frame is going) and source (where it comes from).
Questions
2 “A computer communicates on a network through a network interface card or network adapter.”
Explain this statement with reference to the bus protocol, Ethernet.

3 Why is Ethernet referred to as a family of protocols?

Wi-Fi
Wi-Fi was invented to provide a wireless connection Internet
between computing devices and to enable these devices
to connect to the Internet via a bridge between a wireless
LAN (WLAN) and a wired LAN known as an access Modem
point - Figure 5.14.
WiFi or Wi-Fi® is officially called IEEE 802.11, because Router
of the naming scheme that the IEEE (Institute of
Electrical and Electronic Engineers) uses to name their
standards. The 802 part means a Local Area Network
(LAN), and the .11 part is for wireless. Thus Wi-Fi®
Figure 5.14 Wireless LAN
which is a trademark of the Wi-Fi Alliance is a WLAN. connected via a Wireless
It is a LAN because wireless is short-range. Access Point to a wired
The Wi-Fi channel through which the Wi-Fi signals LAN and the Internet
travel is a shared medium, shared between devices on
this channel, e.g. channel 36. For this reason, we say it is
multi-access or a multiple access medium. Access must LAN
be coordinated and controlled. Hence
the need for a Wi-Fi protocol.
Wi-Fi® is a family of protocols, e.g.
802.11a, 802.11b, 802.11g, etc.
Figure 5.15 shows a configuration
screen for setting up a WLAN. The
configuration allows the system to
negotiate the most appropriate Wi-Fi®
protocol for the WLAN.
Questions
4 What is the purpose of a
Wireless LAN (WLAN) and
what is its relationship with
Figure 5.15 Wireless radio frequency options for wireless networks
the term Wi-Fi? with identifier educational-computing
5b Network protocols

TCP (Transmission Control Protocol)


When two people make a land line telephone call, switches are closed in telephone exchanges to create a continuous
end-to-end connection between the telephone handsets used by the two people. This connection is not shared with
Original
anyone else and is held for the duration message Information
EDCBA Network
of the telephone call. When the call is Message Packet switching:
packets
finished the connection is broken. [Link]
E D C B A A A
1 3 5 watch?v=RhvKm0RdUY0
What happens when a person interacts
via a web browser with a web server Computer
X E B C
to download a web page is completely Computer
A Y
different. The web page must travel E E C B D A E C B
2 4 6
through a packet-switched network. This
requires that the web page is first split into
Figure 5.16 Routing of packets EDCBA
a number of smaller units called packets. Router node
A, B, C, D and E through a Re-assembled
message
Each packet is labelled with a sequence packet-switched network
number before being dispatched into the Let me not to the marriage of true minds
packet-switched network as shown in Figure 5.16. Admit impediments. Love is not love
Packets travelling through the packet-switched network do not Which alters when it alteration finds,
necessarily follow the same path which can result in some packets Or bends with the remover to remove:
arriving at their destination out of sequence. O, no! it is an ever-fixed mark,
To illustrate what happens, let’s consider a simple example of sending That looks on tempests and is never shaken;
the text shown in Table 5.1. It is first split into numbered packets as It is the star to every wandering bark,

shown in Table 5.2. Whose worth’s unknown, although his height be taken.

These are then sent independently of each other through a packet- Love’s not Time’s fool, though rosy lips and cheeks

switched network arriving at their destination out of order, possibly, Within his bending sickle’s compass come;
Love alters not with his brief hours and weeks,
as shown in Table 5.3.
But bears it out even to the edge of doom.
It is software implementing the Transmission Control Protocol
If this be error and upon me prov’d,
(TCP) which breaks text/long messages into shorter segments which
I never writ, nor no man ever lov’d.
are numbered before being sent as separate packets known as TCP
segments. Similar software implementing TCP at the destination Table 5.1 Shakespeare’s Sonnet 116
then uses the sequence number assigned to each
packet to reassemble them into the correct order.

Table 5.2 Shakespeare’s Sonnet 116


split into numbered packets Table 5.3 Shakespeare’s Sonnet 116 received out of sequence
5 Fundamentals of computer networks

Host B
The TCP software also provides reliable transport of Host A
packets by detecting and handling errors in packet
transmission.
If the destination’s TCP software receives a packet process
Socket API used by both client
and server processes to send process
and receive messages
containing error(s) it requests the packet to be Application

sent again. The sender’s TCP software expects the


Modules
destination’s TCP software to acknowledge successful within Client Server
operating socket pipe socket
receipt of each packet sent. If an acknowledgement is system or
library of TCP/IP protocol
connection pipe TCP/IP protocol
not received within a certain time period, the sender routines stack stack

sends the packet again. End-system End-system


To the web browser that requested the web page and
Figure 5.17 Sending and receiving messages using TCP
to the web server with that web page, TCP appears
to establish a reliable two-way connection for data flows in either direction between the two end-systems as
shown in Figure 5.17.
This connection appears to both web browser and web server to support a reliable byte-stream communication
channel (pipe).
This connection has to be set up and then at the end of the message transmission, broken down (this process is
called teardown).
In addition, TCP:
• Performs flow control by speed matching sender and receiver
• Provides congestion control when parts of the network are congested (packet acknowledgements
don’t arrive within the allotted time period). TCP will resend packets along a less congested route.

Questions
5 Explain the purpose of TCP (Transmission Control Protocol).

6 Give one example of network communication which involves the use of TCP.

UDP (User Datagram Protocol)


When you post a letter into a Post Office pillar box, you expect the letter to get to the address on the envelope,
eventually, but you have no control over the delivery part of the process only control over the writing and posting
part. The letter may get lost in the post or arrive so damaged (the dog chewed it up) that it goes straight into a bin.
You will just assume that your letter got through. UDP is a bit like this.
UDP, like TCP, breaks a message down into smaller-sized packets which end up being sent through a packet-
switched network to their destination. These packets are called datagrams.
However, unlike TCP, UDP does not establish end-to-end connections between communicating end systems.
Therefore, no check is made by the sender’s UDP software that the packets reach their destination.
Nor does the destination’s UDP software request a resend if an error is detected in a received packet. The
packet is simply discarded.
Also, UDP does not insert sequence numbers.
The packets are expected to arrive as a continuous stream or they are dropped. However, the receiver can signal the
sender to slow down.
5b Network protocols

UDP is used because it can offer a very efficient communication transport to


some applications, but it has no inherent reliability. Figure 5.18
For example, UDP is an ideal protocol for network applications in which Approximate
location of some
delay in receiving packets is critical such as gaming, voice and video
UK telephone
communications.
exchanges
These can cope with some data loss from lost or corrupted received packets
without adversely affecting perceived quality.
Questions
7 Explain the purpose of UDP (User Datagram Protocol).
8 Give one example of network communication which involves the use
of UDP.
Aylesbury Telephone Exchange High Wycombe Telephone Exchange
IP (Internet Protocol) 433014 433014

412345 487235 412345 487235


In order to understand the Internet Protocol and
IP addressing which is what this protocol is about,
467123 01296 411783 467123 01494 411783
we will first consider another system, the land line
telephone system in the UK, which like IP uses a
422995 455014 422995 455014
uniform addressing scheme of unique addresses to 455004 455004

identify devices. Figure 5.19 Example of UK telephone numbering


The map of the UK in Figure 5.18 shows the system
approximate location of some telephone exchanges in the network of
exchanges. Figure 5.19 shows the telephone numbers of some land
Twin
line telephones connected to local telephone exchanges in Aylesbury
Handset
and High Wycombe, Buckinghamshire.
1633082361
To phone High Wycombe land line number 433014 from Aylesbury
requires that 01494 433014 is dialled where 01494 is the area code
number for High Wycombe telephone exchange.
Figure 5.20 Base of telephone handset
To phone Aylesbury land line telephone 433014 from High showing serial number (S/N)
Wycombe requires that 01296 433014 is dialled where 01296 is the
area code number for Aylesbury telephone exchange. Key principle
Figure 5.20 shows a label stuck to the base of a telephone handset. End-to-end principle:
This label lists the serial number 1633082361 for this phone. The end-to-end principle of
Why are phone numbers used instead of phone serial numbers when dialling? the Internet requires that the
The answer is that it would be very inconvenient to use phone serial numbers two endpoints, the hosts, are
responsible for establishing,
because every time a household changes its phone for another, the phone number
supervising and maintaining
would have to change if it was based on phone serial number. a connection between two
It is much easier to manage call routing and telephone directories if the phone communicating processes,
network assigns logical telephone numbers, such as 433014, instead of physical one on each host. This is done
device serial numbers. by a piece of software in each
host known by the name
For example, the telephone number 433014 assigned to a phone linked to
Transmission Control Protocol
Aylesbury’s telephone exchange remains this household’s telephone number no (TCP).
matter how many times the household changes its phone.
5 Fundamentals of computer networks

The UK’s telephone numbering system uses a uniform numbering scheme in which each telephone number (area
code number + local number) is unique, e.g.
• 01494 433014 uniquely identifies a telephone (ignoring extension lines) located in High Wycombe
• 01296 433014 uniquely identifies a telephone (ignoring extension lines) located in Aylesbury.
The end-to-end principle requires that each computer using the Internet should be uniquely identified. Vint Cerf
and Robert Kahn proposed that each computer be labelled with a globally unique address known as an IP address.
Their numbering system, called IPv4, is used today and allows 232 different addresses. All these unique addresses
make up a single logical address space.
31 0
At the binary level, an IPv4 address consists of 32 bits (4 bytes).
NetID HostID
Cerf and Kahn split an IP address into two parts (Figure 5.21):
Figure 5.21 IPv4 address structure
• bits that identify the network connected to the Internet
(NetID)
• bits that identify a host (strictly speaking a network interface) connected to the network (HostID).
The thinking behind this was that since the Internet is made up of networks, being able to identify each
network would help routers (equivalent of telephone exchanges) Computer Network

enormously in the task of routing packets to the correct destination 26

network. 21 9

For example, the network shown in


Key concept Figure 5.22 has NetID 10.120.61. Computer
Host: 16 10.120.61 25
This network is shown as having eight
The end-systems, e.g.
computers, are referred to as
hosts with HostIDs:
hosts because they host (i.e. run) 5, 9, 10, 15, 16, 21, 25, 26.
5 15
application programs such as a
Web browser program, a Web An IP address is usually expressed in 10
server program, an email client dotted decimal notation, where each Figure 5.22 Network with network
program. byte of the 32-bit IP address is written ID (NetID) 10.120.61 and eight
in decimal, separated by a dot. hosts with HostIDs 5, 10, 15, etc
For example, the IP address of host with HostID 21 in Figure 5.22 is [Link] (NetID + HostID)
BYTE 4 BYTE 3 BYTE 2 BYTE 1
In binary this is 00001010 01111000 00111101 00010101
Every organisation that wishes to send and receive e-mail, or gain access to the Internet, needs at least one globally
unique IP address.
An organisation is typically assigned more than one unique IP address as a block of contiguous addresses.
The NetID part of the block of 32-bit IP addresses in IPv4 is indicated by
Key term
expressing it in dotted decimal notation form as follows a.b.c.d/x, where x
IPv4:
Internet numbering system of
indicates the number of bits for the NetID.
unique IP addresses that make For example, [Link]/16 means that the NetID is the first 16 bits, i.e.
up a single logical address space. 129.12. This happens to be the NetID for the University of Kent.
IPv6 will eventually replace [Link]/23 means that the NetID is the first 23 bits, i.e.
IPv4. IPv6 is also an Internet
numbering system like IPv4 but 11000000 11000011 00101010 00000000 = 11000000 11000011 0010101
it consists of 128 bits whereas
This leaves 9 bits for hostIDs.
IPv4 has only 32 bits.
5b Network protocols

Just like the telephone network, IP protocol software defines an addressing Key concept
scheme that is independent of the underlying physical addresses of the hosts. In
Uniform addressing scheme:
computer networks, the physical address is the “serial number” of the host/device’s A uniform addressing scheme
network adapter, a 48-bit number called its MAC address embedded within the is a logical addressing scheme,
adapter. It is a network adapter which enables a device to connect to a network. independent of the underlying
physical network. Each address
The network adapter shown in Figure 5.23 has MAC address 74:D4:35:94:AD:53
conforms to a common format
expressed in hexadecimal. defined by a standard, e.g. IPv4.
Figure 5.24 shows three LANs connected by routers. Routers are used because
it is not practical to connect every host directly to every other MAC address
host. Instead a few hosts connect to a router, which connects to
74:D4:35:94:AD:53
other routers, and so on, to form a network.
A router receives packets from one host or router and uses
the destination IP address that they contain to pass on the
packets, correctly formatted, to another host or router.
In the Internet, data packets flow essentially unaltered with
their source and destination addresses (IP addresses) that of the
Figure 5.23 Network adapter
endpoint systems (now referred to as end-systems) sending and
receiving the packets, respectively. The Internet is a distributed network of switch Key term
nodes (routers) resembling a ‘fishnet’ as shown in Figure 5.25.
Internet: A network of
Endpoint computer networks, computers
Y
and devices with computing
Local Area
Network capability using globally unique
(LAN)
Host IP addresses and TCP/IP.
Router

Link
Key term
Link
Router Endpoint Packet switching:
X Messages to be sent are split
Router Router
into a number of segments
called packets. The packets
Host Host
Figure 5.25 Distributed of a message are allowed to
Local Area Local Area network of switching nodes travel along independent paths
Network Network
(LAN) (LAN) (routers) resembling a through a network of routers.
‘fishnet’ Routers use a packet’s
Figure 5.24 Connecting three LANs by routers
destination IP address to route
the packet, taking account of
1 Visit [Link] to view the range of IP address how congested particular routes
are.
allocated to various organisations.
This network resembles a fishnet
Why do you think that Virgin Media Ltd, Sky UK Ltd have been of switching nodes called routers
allocated 9000000+ and 7000000+ IP addresses, respectively? connected by links in a way
2 Click on the hyperlink [Link] for Sky Ltd to view that allows multiple pathways
through the network between
how Sky’s IP addresses are organised into networks.
endpoints.
3 What is the IP address of a network computer that you have access to?
To find out go to Start>Run>Cmd>IPConfig<Return key>. on a On an Apple Mac or Linux machine
Windows machine. use ifconfig from a Terminal window
and look for inet.
5 Fundamentals of computer networks

Questions
9 Explain the purpose of IP addressing in the Internet Protocol.

10 What device or devices in network communication other than the sending and receiving hosts use IP
addresses?

HTTP (Hypertext Transfer Protocol) WEB BROWSER WEB SERVER MAGNETIC DISK/
BACKING STORE ON
Hypertext Transfer Protocol (HTTP) is a very Request
WEB SERVER

simple application-level protocol. In this protocol, a Message


Response [Link]
client computer sends a request message to the server Message
and the server responds with a response message
Figure 5.26 HTTP request-response messages
(Figure 5.26).
In the example in Figure 5.26 the file [Link] has been requested. The response message may contain many
forms of data. The most popular form of data is text formatted using Hypertext Markup Language (HTML).
TCP establishes a connection between the client computer and the server computer so that HTTP has a pathway
for its request and response messages.
The simplest request message is
GET / <Return key pressed>
<Return key pressed>
This gets the default web page, [Link], for the given site.
HTTP finishes with the connection after the response message is sent; the TCP connection is broken unless
specifically requested to stay connected.
A web page returned by an HTTP GET request is a text file containing content to be displayed together with
instructions on how to style and structure this content when displayed.
HTTPS (Hypertext Transfer Protocol Secure)
Hypertext Transfer Protocol over Secure Sockets (HTTPS) is a web protocol
Key term
that encrypts and decrypts user page requests as well as the pages that are
Port number:
returned by the web server. HTTPS uses the Secure Sockets Layer (SSL) beneath Two applications sending to
the HTTP application layer. HTTPS uses port 443 instead of port 80 in its and receiving from each other,
interactions with TCP/IP. Figure 5.27 shows the SSL sublayer which encrypts are identified by numbers called
port numbers (see Figure 5.28).
the HTTP GET / request before sending it through the TCP connection to the
Web server [Link]. Both the request and the response are encrypted.
HTTPS has CLIENT SERVER
been used for [Link]/

a long time for Web browser Web server <html>. .. </html>

securing payment <html>. ... </html> Application Application


transactions on the SSL socket SSL socket
Web but it is now SSL sublayer SSL sublayer

being more widely TCP socket Secure channel TCP socket

used for general TCP TCP

Web access. Internet Internet

Link Link

Figure 5.27 Fetching a Web page using HTTPS


5b Network protocols

FTP (File Transfer Protocol)


File Transfer Protocol (FTP) is an application layer protocol that enables files on one host, computer B, to be
copied to another host, computer A. One host runs an FTP client and the other an FTP server.
FTP servers use two ports: port 21 for commands and port 20 for data.
Figure 5.28 shows an FTP client connected to an FTP server via TCP so that it can send a command request
for a file [Link] located on the FTP server. The FTP response is to send file [Link] through the TCP
connection to the FTP client.
Port 57359 is bound to the TCP socket on the client side, whilst on the server side, port 21 is bound to the
command socket and port 20 to the data socket.
[Link] [Link] The Application
Computer A Computer B layer is the highest
FTP Client FTP Server abstraction layer of
the TCP/IP model/
stack. It provides
FTP protocol Application FTP protocol Application
the interfaces and
Port 21 Port 20
communication
Port 57359 protocols, e.g. FTP
commands data
TCP/IP protocol TCP
TCP TCP protocol, needed
stack
by the hosts and
layer layer
their users. Other
Link layer Source Destination Link layer Application layer
Command Address Address protocols are, for
Request Computer Computer
example, HTTP,
for A B HTTPS, SMTP,
[Link] 57359 21 IMAP.

Computer Computer
A B
57359 20

Destination Source Data


Address Address

Figure 5.28 FTP transfer of file [Link] from Computer B to Computer A

The client may need to navigate the directory structure of the server, create new directories, rename files and
directories, delete files and directories. These are
sent to the server as command requests.
Figure 5.29 shows FTP client software
(FileZilla) running on a computer with IP
address [Link] connected to an FTP
server running on a computer with IP address
[Link]. This server is located in the USA
whilst the client computer is in the UK.
The FTP client and FTP server software rely on the
FTP protocol embedded in the Application layer of
the TCP/IP protocol stack to communicate.

Questions
11 Explain the purpose of FTP (FileTransfer Figure 5.29 FTP client using FileZilla FTP client software
Protocol). connected to an FTP server
5 Fundamentals of computer networks

Email protocols
Simple Mail Transfer Protocol (SMTP)
Simple Mail Transfer Protocol (SMTP) is used by e-mail clients to send e-mail. It is a relatively simple text-based
protocol.
One or more recipients of a message are specified then SMTP is used by the email client to transfer the message text
to a mail server listening on port 25. The mail server takes care of delivering the mail to the ultimate destination
using SMTP.
For creating and sending email the SMTP protocol supports commands such as
• MAIL FROM: - defines the e-mail address of the sender of the message.
• RCPT TO: - defines the e-mail address of a recipient of the message. Repeating this command once for
each recipient means you can send one piece of mail to many users without having to repeat the entire
process over and over again.
• DATA marks the start of the data portion of the message, essentially everything that you would
consider “content”, this includes the “To:”, “From:”, “CC:” etc. as these are not commands but simple
informational components making up a header which the e-mail client picks out of the content and
displays in a far nicer format. Just as a reminder - anything which is in the content can be faked as it is
content and so consequently cannot be validated.

Internet Message Access Protocol (IMAP)


IMAP is a protocol that was designed to allow access to emails stored on a remote server. Users essentially connect
to an IMAP server to read and organise their emails. Remote access from any user device is supported, e.g. smart
phone, tablet, PC. New emails are cached locally so that they are available to read again without needing to contact
the server. The user may configured the emails stored on the server into folders, mark emails as read, etc. One can
think of the service provided by IMAP as a kind of cloud storage.

Questions
12 Which of the networking protocols labelled A .. E would be used to
(a) make a payment securely when purchasing goods from a website?
(b) send an email?
(c) view email stored on a server?
(d) transfer a file between hosts?
(e) retrieve a web page insecurely?
A FTP Layer Order (1-4)
B SMTP Server responds by sending web page
C IMAP Server receives request for web page
Web browser requests web page
D HTTPS
Web browser receives web page
E HTTP
Table 5.4

13 A user accesses a web page stored on a remote web server through a web browser. Table 5.4 shows the
actions that need to take place to make this possible. Put these actions in the correct order (1-4, where 1 is
the first action that needs to take place and 4 is the last). What application protocol could have been used
to obtain this web page?
5b Network protocols

In this chapter you have covered:


■ Defining the term ‘network protocol’
■ The purpose and use of common network protocols including:
• Ethernet
• Wi-Fi
• TCP (Transmission Control Protocol)
• UDP (User Datagram Protocol)
• IP (Internet Protocol)
• HTTP (Hypertext Transfer Protocol)
• HTTPS (Hypertext Transfer Protocol Secure)
• FTP (File Transfer Protocol)
• Email protocols:
 SMTP (Simple Mail Transfer Protocol)
 IMAP (Internet Message Access Protocol).
5 Fundamentals of computer networks
5 Fundamentals of computer networks
Learning objectives:
■ Understand the need for,
and importance of, network
■ 5c Network security
security The need for and importance of network security
In the physical world, locks are placed on doors and alarm systems are fitted to
■ Explain the following methods
property to protect against theft of assets and personal harm.
of network security:
In the digital world, every computer system needs similar protection especially
• authentication against the serious consequences of the loss of business or personal data
• encryption whether from theft or otherwise. Businesses can fail as a result. For example,

• firewall
according to SC Magazine, the company Code Spaces was closed down after its
Amazon Elastic Compute Cloud control panel was hacked and data, backups,
• MAC address filtering.
and off-site backups were erased.
Security breaches do not just affect businesses. The computer systems of
individuals are also vulnerable. Individuals can lose money if their online bank
Key term
details are stolen by hackers or if their identities are stolen.
Network security: Connecting a computer or computing device to a network increases the risk
Network security consists that the computer could be attacked and data stolen or damaged. In fact, poor
of the measures and policies
security on a network computer could allow unauthorised access to the whole
put in place by a network
administrator to prevent and network with potentially serious consequences. That is why network security is
monitor unauthorised access, important especially if connection to the Internet is supported because many of
denial of service, misuse, the protocols used in the Internet do not provide any security.
modification, and destruction
Tools to “sniff” passwords on the network are in common use by malicious
of network-accessible resources,
e.g data including network
hackers. Thus, applications which send an unencrypted password over the
password lists. network are extremely vulnerable.

Network security methods


Network security
Network security consists of the measures and policies put in place by a
Key term
network administrator to prevent and monitor unauthorised access, denial of
Data security: service, misuse, modification, and destruction of network-accessible resources,
Data security means protecting e.g data including network password lists.
against unauthorised access,
Where data is concerned security refers to the protection of data against
alteration or destruction.
A greater level of data security unauthorised access/disclosure, alteration, or destruction.
can be achieved by the use
of data security methods,
Questions
authentication, encryption, 1 Why is network security important?
firewall and MAC address
filtering, in combination.
2 What is meant by network security?
5 Fundamentals of computer networks

Authentication
Network security systems are designed to let authorised people into the network, and to keep unauthorised people
out. This involves three distinct steps:
1. Identification:
The identification step requires that a person identifies themselves,
e.g. by means of identification string such as an email address or userID.
2. Authentication:
Once identification has been provided, the person is required to provide evidence of
their identity which could be one or more of the following
 Something they know, e.g. a password or a PIN
 Something they have, e.g. a smart card or a token/security device
 Some aspect of a person’s physiology such as their fingerprint or iris pattern of
Figure 5.30
their eye. This is called biometrics.
Banking security
3. Authorisation: device token
 Allows an authenticated person access to the system with the authority
to carry out certain permitted operations such as read/write and delete Key term
specific data in an area of storage allocated to them. Authentication:
Authentication by password is considered vulnerable because humans find it The process or action of
verifying the identity of a user
difficult to remember a password that an attacker would find difficult to guess.
or process.
An improvement is to use a one-time-password (OTP) generated by a token or
security device such as the one shown in Figure 5.30.
Tokens are designed to generate seemingly random passwords that are synchronized with a token server.
When an OTP is combined with a Personal Identification Number (PIN), two-factor authentication is achieved
because the client needs to have something (the token) and know something (the PIN). The user enters their PIN
into the token (using keypad such as the one shown in Figure 5.30) they hold to get the next one-time password.
The token shown in Figure 5.30 has an internal clock which was synchronised with the bank’s token server clock
when the token was issued. The software in the token that generates the next password relies on this clock time to
set the time period for which the password is valid. This enables the token server to generate the corresponding
password so that submission of the next one-time password can be matched at the token server to authenticate the
user.
Biometric authentication uses the person’s body as their “password”.
Instead of the “password” being something that the person knows, it is something physical and unique that they
possess.
A user might use biometrics to authenticate themselves to a system or might use biometrics to authenticate
themselves to a local system (a smart card or token) The card/token then authenticates itself to a remote system.

Questions
3 What is authentication in the context of computer security?
4 Methods used separately or in combination to verify the identity of a user attempting to log in to a
computer network are classified as follows:
Something they know,
Something they have,
Something of the person
Give one example of each of these methods.
5c Network security

Encryption
Key point
If authentication uses cryptography, then an attacker listening to the network Encryption and
gains no information that would enable them to falsely claim another’s identity. authentication:
Passwords sent across the network in plain text form can be intercepted and If authentication uses
subsequently used by eavesdroppers to impersonate a user. cryptography, then an attacker
listening to the network gains
Encrypting data, including passwords, sent across a network can therefore
no information that would
improve network security. enable it to falsely claim
Encryption mathematically converts data into a form that is not directly another’s identity.
readable. Therefore, an attacker who is eavesdropping on the network will not
be able to decode passwords and data sent over the network in encrypted form.
Figure 5.31 shows part of a bank login screen that uses the secure web protocol Did you know?
HTTPS (Hypertext Transfer Protocol over Secure Sockets).
Securing wireless networks:
HTTPS is a web protocol that encrypts and decrypts user page requests as User’s data sent between two
well as the pages that are returned by the web server. A user’s username and devices, e.g. a wireless station
password will therefore be sent encrypted to HSBC®’s authentication server. and an access point needs
to be private to those two
devices, i.e. kept confidential by
securing against unauthorised
access. Unfortunately, radio
HTTPS transmissions over a wireless
network are easily intercepted
and read by third parties unless
encrypted.
Wi-Fi Protected Access (WPA)
and Wi-Fi Protected Access
II (WPA2) are two security
protocols developed by the
Figure 5.31 Bank login screen showing use of Wi-Fi Alliance to secure wireless
the secure web protocol HTTPS computer networks.

Did you know? Information


Authentication can also be strengthened through the use of public key cryptography.
For example, a user has a smart card that contains a public key and a matching private HTTPS will encrypt payment
key. details such as credit card
The user’s public key is placed on file at the remote server. number and credit card security
To authenticate the user, the remote server sends the user a random challenge (a code when purchasing goods
random number). from a website, thus enabling
The user signs the challenge with their private key to create a digital signature and the payment to be made
sends this signature to the remote server, which verifies the signature with the public securely.
key that it has on file. In addition, HTTPS will assure
In this way, the remote system can verify that the user has possession of the private the payee that the website
key without ever needing sight of it and the user has no need to use a password. is genuine because HTTPS
will use the website’s digital
certificate issued by a trusted
authority.
Questions
5 Why is it considered a good idea to encrypt network communication?
5 Fundamentals of computer networks

Firewall
A firewall is a combination of hardware and software that isolates an ISP
& DNS servers
organisation’s internal network from the Internet at large, allowing some
packets to pass and blocking others. Figure 5.32 shows a firewall located
between an organisation’s local area network and the router that connects, via
Router
an ISP, the organisation’s network to the Internet.
Web server
With all network traffic entering and leaving the organisation’s network
Firewall
passing through the firewall, the firewall is able to allow authorised traffic Internet
E
through whilst blocking unauthorised traffic. The firewall is positioned as gateway

shown in Figure 5.32 so that it watches over all traffic crossing the gateway
point, acting like a sentry or doorman. A doorman/sentry positioned at the
B C
entrance or exit of a building watches for unauthorised attempts to enter the Private Local Area Network

secure area. Some people are allowed to enter, others are prevented. Figure 5.32 Local Area Network
behind a firewall
Questions
6 What purpose is served by a network firewall, and typically where Key term
would a firewall be located in a network? Firewall:
A firewall is a combination
MAC address filtering of hardware and software
that isolates an organisation’s
MAC addresses are 48-bit addresses uniquely assigned to each network interface
internal network from the
card (NIC). Alternative name for a NIC is network adapter.
Internet at large. It monitors
In MAC address filtering, an internal table (in Wi-Fi router in wireless networks incoming and outgoing network
or in a managed switch in wired networks) of MAC addresses is consulted to traffic and decides whether to
decide whether to permit access to the network or not. If the MAC address is allow or block specific traffic
on this list then the device with this MAC address may join the network. If its based on a defined set of
security rules.
MAC address is not on the list then any attempt made to join the network will
be rejected.
However, MAC filtering can be defeated by a spoofer who learns the MAC address of a valid network interface card,
i.e. one on the list, by scanning network traffic. A MAC address is “glued” into a network card, but it is possible to
command the operating system to change information about the MAC address in every data packet it sends out to
the network. If a spoofer were to do this to the network interface card in their machine then the spoofer could gain
access to the MAC address list protected network.
Questions Key term
7 Describe MAC address filtering.
In MAC address filtering, an
8 Describe how the methods of authentication, encryption, firewalls internal table (in Wi-Fi router in
and MAC address filtering could be used in combination to secure wireless networks or in a managed
a network against unauthorised access, alteration or destruction. switch in wired networks) of MAC
addresses is consulted to decide
In this chapter you have covered: whether to permit a device access to
■ The need for, and importance of, network security the network or not on the basis of
its MAC address. The MAC address
■ The following methods of network security:
is a physical address embedded
• authentication
within the device’s network adapter.
• encryption
• firewall
• MAC address filtering.
5 Fundamentals of computer networks
5 Fundamentals of computer networks
Learning objectives:
■ Describe the four layer TCP/
IP model:
■ 5d Four layer TCP/IP model
The four layer TCP/IP model
• application layer
Networking protocols were designed to make possible communication
• transport layer between application programs executing on different hosts whilst hiding the
• internet layer complexities of the underlying network from these application programs.

• link layer
A host, or host computer, is any computer system that connects to an internet
and runs applications.
■ Understand that the HTTP, The term process is used for an instance of a program in execution, so it
HTTPS, SMTP, IMAP and
is actually processed in different hosts connected by a network that are
FTP protocols operate at the
communicating.
application layer
Layered organisation
■ Understand that the TCP and Networking protocols are usually developed in layers.
UDP protocols operate at the Each layer is responsible for a different part of the communication process.
transport layer The software that implements a protocol is called protocol software and

■ Understand that the IP the software that implements a suite of protocols such as TCP/IP, is called a
protocol operates at the protocol stack.
network layer. The TCP/IP protocol suite consists of four conceptual layers as shown in
Figure 5.33:
• Application layer
• Transport layer
• Internet or IP layer
• Link layer.

Application FTP, email(SMTP, IMAP), Web browsing (HTTP, HTTPS)

Transport TCP, UDP

Internet Internet or IP layer

Link Ethernet, PPP, WiFi, DOCSIS (cable TV)

Figure 5.33 The four layers of the TCP/IP protocol suite and stack
Key terms
Host:
It is implemented in software as the TCP/IP protocol stack in separate
A host is any computer system software modules corresponding to the individual layers of the protocol suite.
that connects to an internet and
Each layer and therefore each software module has a different responsibility.
runs applications.
The protocol stack is installed on each computer either as a part of the
Process:
operating system or as a software library.
An instance of a program in
execution.
5 Fundamentals of computer networks

Key terms Application programs interact with the software stack via an Application
Programming Interface (API). The de facto standard is the socket API.
Protocol:
A protocol provides agreed The following Python code snippet shows a client application using the socket
signals, codes and rules for data API to set up a socket to send a message to a server:
exchange between systems.
Networking protocols: clientSocket = socket(socket.AF_INET, socket.SOCK_STREAM)
Networking protocols make message = "Hello Server"
possible communication [Link](message, (serverName, serverPort))
between processes executing on
different hosts whilst hiding the Figure 5.34 shows a client process and a server process that use the socket API
complexities of the underlying Host B
Host A
network from these processes.
TCP/IP protocol suite:
The TCP/IP protocol suite
consists of four conceptual Socket API used by both client
process and server processes to send process
layers: application, transport, and receive messages
Application
internet or IP, and link.
Messages Messages
TCP/IP protocol stack:
Modules
Implements the TCP/IP
within Client Server
protocol suite in software. operating socket byte pipe socket
system or
library of connection pipe TCP/IP protocol
TCP/IP protocol
routines stack
Key term
stack

Application layer: End-system End-system


Application layer protocols Figure 5.34 Sending and receiving messages using the socket API
are used to exchange data
from the TCP/IP protocol stack to send and receive messages via a TCP/IP
between programs running
on the source and destination connection pipe established between client and server.
hosts. It is the application Application layer
layer that provides the interface A process in one end-system (host) uses the application layer of TCP/IP to
between these programs and the
exchange packets of information with a process in another end-system. The
underlying network over which
the programs’ messages are packets of information at the application layer are called messages.
transmitted, e.g. HTTP message The application layer uses different application-layer protocols for different
GET / which fetches the default applications. For example, if the application is designed to enable Web pages
Web page from a Web server.
to be fetched from a Web server then the application will use either the HTTP
application-layer protocol or the HTTPS application-layer protocol. An
application-layer protocol defines the kind of messages to send. In the case of
Key term
Transmission Control HTTP or HTTPS, one such message could be a GET message.
Protocol (TCP): Transport layer
TCP enables applications The transport layer of the protocol stack is a piece of software in each host.
executing on two hosts to
This software implements the two transport protocols Transmission Control
establish a connection and
exchange application-layer Protocol (TCP) and User Data Protocol (UDP). TCP enables applications
messages through a reliable executing on two hosts to establish a two-way connection and exchange
byte-stream channel (pipe) for application-layer messages through a reliable byte-stream channel (pipe) for
data flows between the two end
data flows in either direction between the two end-systems as shown in Figure
systems.
5.34. It also allows the connection to be terminated.
5d Four layer TCP/IP model

TCP breaks long messages into shorter segments which it sends as separate Key term
transport-layer packets known as TCP segments. Function of Transport layer:
The application at the sending side (e.g. a Web browser using the application- The basic function of the
layer protocol HTTP) pushes messages (e.g. GET) through a TCP/IP socket. transport layer is to
The transport-layer protocol TCP has the responsibility of getting the messages accept messages/data from the

to the socket of the receiving application process, e.g. a Web server listening on split these into smaller units
port 80. Port numbers such as port 80 are 16-bit numbers used for application called segments if necessary
(specific instance of a Web browser request) and service identification on the (segment size determined at
TCP connection set up time)
Internet (a Web server).
pass these segments to the
TCP does everything in its control to guarantee delivery of the application- internet or IP layer
layer message and also guarantee that the received TCP segments will be ensure that all the segments
reassembled in the correct order to form the message to be passed to the arrive correctly at the other
end
application-layer and then the corresponding application process. reassemble the received
During set up TCP establishes the maximum size of the packets (Maximum segments, which it gets from
Segment Size or Maximum Transmission Unit) it can use through the network the internet layer, in the
correct order to form the
- see [Link] for an exercise that you can do
message/data to pass to the
to establish the maximum packet size. layer above.
Once the TCP has established a connection it: The transport layer is a true
end-to-end layer which carries
• Monitors the connection for transmission errors and responds when messages/data all the way from
an error is detected by retransmitting the segment that suffered the the source to the destination.
error
• Detects when a connection is broken
• Performs flow control by speed matching sender and receiver Key term
• Provides congestion control when the network is congested. Internet or IP layer:
The internet or IP layer of the
Internet or IP (Internet Protocol) layer
TCP/IP protocol stack in hosts
The transport layer uses the IP layer to carry its segments. Each TCP segment is and routers is responsible for
encapsulated in an IP packet before it is sent across the internet. moving IP-layer packets from
The IP layer adds source and destination IP addresses to packets on their way one host to another without
regard to whether these hosts are
from the transport layer to the link layer, and removes source and destination
on the same network or not.
IP addresses from packets on their way from the link layer to the transport It adds source and destination
layer. IP addresses to packets on their
The internet or IP layer in hosts and routers move these packets known as way from the transport layer
IP or Internet Protocol packets from one host to another without regard to to the link layer, and removes
source and destination IP
whether these hosts belong to the same network or different networks.
addresses from packets on their
The Internet Protocol is a connectionless protocol which just provides a best way from the link layer to the
effort but not guaranteed way of delivering packets called datagrams. The transport layer.
reliability of the transmission is left to the layer above, the transport layer.
Getting to the destination host may require many hops via intermediate routers along the way.
Both hosts and routers need to use the internet or IP layer of the TCP/IP protocol stack but since the job of a
router is dedicated to routing packets, a router only requires use of the internet and link layers of the TCP/IP
stack. The IP layer in a router must have sufficient knowledge of other routers and links in its internet to be able to
make routing decisions for packets that pass through it.
Together TCP and IP hide the differences between the underlying networks through which packets pass when
going from source to destination host.
5 Fundamentals of computer networks

Link layer
The link layer handles all the physical details of interfacing with the network cable or wireless connection. It
includes the network interface card (network adapter) and a device driver (installed in operating system).
TCP/IP protocol supports many different types of link layer, depending on the type of networking hardware being
used. One example is Ethernet.
The link layer adds source and destination hardware addresses (e.g. MAC addresses) to packets that it receives
from the IP layer then dispatches the packets onto the local cable or wireless connection.
If the packet is destined for a host on another network, the link layer destination address is the hardware address of
the gateway (router) to the internet which the other network is connected to.
In an Ethernet local area network (LAN) Web Web
browser server
these hardware addresses are Ethernet
card (Network Interface Card) addresses, Application layer Application layer
HTTP HTTP
or MAC addresses. Figure 5.35 shows
a packet despatched by the link layer of TCP layer layer
a host with IP address [Link] to a
remote host with IP address [Link]. IP address Internet Internet IP address
[Link] layer layer [Link]
Figure 5.35 shows the first, second and
last hop of many hops. Link-layer address Link-layer address Link-layer address
Link layer 00-02-77-A1-88-53 Link layer
00-03-47-C9-69-52 00-04-34-65-07-81
Note that the link layer hardware
address changes from hop to hop Physical cable Gateway Gateway Physical cable
whilst the source and destination IP Link-layer address Link-layer address
00-03-47-B6-21-46 00-04-34-98-15-21
addresses remain constant. Link-layer address Router Link-layer address
network
This is because the link layer’s role is to 00-02-22-E3-54-12 00-04-34-A8-19-10

First hop
stream bytes between directly connected
Source Link-layer Destination Source Destination
machines, hosts and routers. address Link-layer address IP address IP address
00-03-47-C9-69-52 00-03-47-B6-21-46 [Link] [Link]
It is the link layer that puts bits onto the
network cable or wireless connection. Second hop

Sending to a remote machine is done Source Link-layer Destination Source Destination


address Link-layer address IP address IP address
in hops where each hop is a direct 00-02-22-E3-54-12 00-02-77-A1-88-53 [Link] [Link]

connection (link) between a host and a


Last hop
router, a router and a host, a router and
Source Link-layer Destination Source Destination
another router, or two directly connected address Link-layer address IP address IP address
00-04-34-98-15-21 00-04-34-65-07-81 [Link] [Link]
hosts.
Link layer address
00-02-22-E3-54-12
Key term Gateway

The link layer handles all the physical details of


00-03-47-B6-21-46 00-02-77-A1-88-53 00-04-34-A8-19-10
interfacing with the network cable or wireless
connection. IP address Link layer address 00-04-34-65-07-81
00-02-77-A1-45-11
The link layer adds source and destination Link layer address address
hardware addresses (e.g. MAC addresses) to 00-03-47-C9-69-52
[Link]
00-04-34-98-15-21
packets that it receives from the IP layer then
despatches the packets onto the local cable or Router Network

Figure 5.35 TCP/IP protocol stack and the role of the link layer (or
link layer) in the communicating hosts and intermediate routers
5d Four layer TCP/IP model

Questions
1 TCP/IP is a four-layer protocol stack used in networking.
Complete the table, using each number from 1-4 once, to indicate the correct order for these layers (where
1 is the top layer and 4 is the bottom layer).
Layer Order (1-4)
Internet
Application
Link
Transport
2 Figure 5.36 shows the address part of a packet sent between two computers A and B on the same local
area network.
Source link-layer Destination Source Destination
address link-layer address IP address IP address

Figure 5.36
The MAC addresses of their network interface cards are as follows
Computer A: 00-03-47-C9-69-52
Computer B: 00-03-47-C9-44-35
Their IP addresses are as follows
Computer A: [Link]
Computer B: [Link]
Complete the table for the address part of a message packet sent from A to B.

Layer Address
Source link-layer address
Destination link-layer address
Source IP address
Destination IP address
3 Computer B is now relocated to a different local area network on the other side of the world from
computer A but it is still reachable from A across the Internet. Computer A addresses a message packet
and despatches it to computer B. The message packet successfully reaches B. Which address in the packet
must have been changed by computer A for the packet to be successfully routed to B?

4 Describe the roles of the application layer and the data link layer in the four-layer TCP/IP model.

■ The four layer TCP/IP model:


• application layer
• transport layer
• internet layer
• link layer
■ That the HTTP, HTTPS, SMTP, IMAP and FTP protocols operate at the application layer
■ That the TCP and UDP protocols operate at the transport layer
■ That the IP protocol operates at the internet layer.
6 Cyber security
6 Cyber security
Learning objectives:
■ Be able to define the term
cyber security and be able to
■ 6.1 Cyber security threats
describe the main purposes of What is cyber security?
cyber security Cyber security consists of the processes, practices and technologies designed
■ Understand and be able to to protect networks, computers, programs and data from attack, damage, or
explain the following cyber unauthorised access.
security threats: When computers or networks and their programs and data are attacked, the
• social engineering attacker attempts to bypass the security of these systems in order to “hack” into
techniques them. Hence the use of the term hacker for an attacker.
• malicious code (malware) The main purpose of cyber security is to minimise the chances of an attacker
• pharming hacking into a system, and exploiting this access for personal gain or malicious
• intent, e.g. to steal confidential information such as passwords.


weak and default
passwords 6.2 Social engineering threats
• misconfigured access
Every major study on technical vulnerabilities and hacking says the following:
rights
• removable media • Users are the weakest link, whether on purpose or by mistake

• unpatched and/or
Users and their actions represent a giant security hole that
outdated software simply can’t ever be completely plugged.

■ Explain what penetration Social engineering provides a low tech approach to attacking a system.
Social engineering is the art of manipulating a person, or group of people, into
testing is and what it is used
providing information or a service they would otherwise never have given.
for.
Social engineers prey on people’s natural desire to help one another, their
Key term tendency to defer to authority, their ignorance, greed and response to fear of
security:
consequences, e.g. your email account will be suspended unless you login and
Cyber security consists of
the processes, practices and confirm your identity.
technologies designed to protect Questions
networks, computers, programs
and data from attack, damage, 1 You are asked by your network’s administrator to provide your
or unauthorised access. password. How would you respond?

2 You are surfing the Web and a pop-up box appears in your browser
window to tell you that a virus has been detected on your system. To
Key term remove this virus you are told to click on a link. Would you click on
Social engineering: the link? Explain your answer.
Social engineering is the art
of manipulating a person, or 3 An advert appears in the side window of your browser when you are
group of people, into providing visiting a games website. The advert is offering a free game which
information or a service they may be downloaded immediately by clicking on a download button.
would otherwise never have
Would you click on the download button? Explain your answer.
given.
6 Cyber security

Malicious code(malware)
Information
Malicious code (malware) is software that sets out to:
Unsolicited email or messages • Intentionally harm a computer system and other systems that it
that are sent to groups of connects to
people. • Steal confidential information such as passwords
Distributed denial-of-service: • Take control of a computer system for purposes such as sending spam
A distributed denial-of-service or taking part in a Distributed Denial of Service (DDoS) attack
(DDoS) attack occurs when • Hold you to ransom (ransomware) by demanding payment to
multiple systems flood the unencrypt your files
bandwidth or resources of a
• Cause physical damage to machinery or systems controlled by a
targeted system, usually one or
more web servers. The targeted
computer system, e.g. STUXNET malware causing damage to the
system is unable to cope and operation of centrifuges used by Iran in its nuclear bomb programme.
the service it provides becomes The attacker might send an email containing a link that the recipient is asked
unavailable. to click. The link won’t be so blatant as to use the label “Click me to download
malicious code” but if the email comes from an unknown source the likelihood
Key term is that this will be the effect of clicking the link.
Pharming
Pharming:
Pharming is a cyberattack Pharming is an “under the counter, sleight of hand” technique used by
intended to redirect a website’s cybercriminals to redirect you from a legitimate site that you have specified to
traffic to a fake or bogus website. a bogus copy website elsewhere thus allowing criminals to steal the information
that you enter.
Key term Pharming exploits the fact that when the numerical addresses of the Internet
Domain Name Service (DNS): (IP addresses, e.g. [Link]), which are used for routing packets of
The domain naming system data on the Internet, became too inconvenient to remember, they were given
relies upon DNS servers to
corresponding, easier to remember, symbolic names called domain names, like
handle the conversion of the
letter-based (symbolic) website [Link].
names, which are easily recalled Every time a form of a symbolic address is entered, e.g. [Link], it
by people into the machine- has to be turned back into its corresponding IP address.
understandable digits (numeric A Domain Name Service (DNS) server on the Internet handles this conversion
addresses).
process, unless either a “local host file” on your computer or a local cache on
your computer already provides this.
Key point When you enter, for example, a website address into your browser, e.g. www.
Pharming (pronounced [Link], your computer contacts a DNS server and requests the
‘farming’) is a form of online corresponding and genuine IP address, [Link].
fraud very similar to phishing
Hackers can subvert this process in two ways:
as pharmers rely upon the
same bogus websites and theft • They can send out a Trojan horse that rewrites the local host file on your
of confidential information. computer, so that it associates the domain name with a bogus website, e.g.
However, where phishing must [Link] ↔ [Link]. You are then directed to the bogus
entice a user to the website website with IP address [Link], even though you entered the correct
through ‘bait’ in the form of a
symbolic website address, e.g. [Link].
phony email or link, pharming
re-directs victims to the bogus • Alternatively, they can alter the DNS itself, i.e. alter its records so
site even if the victim has typed that anyone who tries to visit that symbolic address is directed to the
the correct web address. This is bogus website. Compromised DNS servers are sometimes referred to as
often applied to the websites of
“poisoned”.
banks or e-commerce sites.
6.2 Social engineering threats

By only attempting to connect to a website with SSL/TLS protection, i.e. prefix Key fact
https:// in the web address and Secure in the browser, your browser will be
able to check with a Certificate Authority that the certificate associated with the Weak passwords:
Attackers know that many
site corresponds to the one for the legitimate website. If a hacker tries to mimic
people use passwords comprised
a secure site, a message will warn that the site’s certificate does not match the of easy-to-remember lowercase
address being visited. letters. Attackers typically work
If you see a warning that a site’s certificate is not valid or not issued by a trusted on those combinations first.
authority, you should not enter the site.
The URL is also a great place to check. Always ensure that, once the page Key points
has loaded, that the URL is spelt correctly and hasn’t redirected to a slightly
Strong passwords:
different spelling, perhaps with additional letters or with the letters swapped
Length and complexity of
around. If you examine the web address in Figure 6.2.1 you will observe that password also adds security.
umo is spelt u r n o. Adding numbers, symbols,
and using both lowercase
and uppercase characters
significantly increases the time
needed to decipher a password.
Figure 6.2.1 Bogus site with a slightly different spelling of umo
Weak passwords
The length of a password, and the size of the character set from which its
characters are chosen, can dictate the vulnerability of a system to penetration by 1 Read the following article
an attacker, i.e. how easy is it to guess the password and using this knowledge on creating a secure
gain access to a system. password you will actually
remember:
For example, if passwords are restricted in length to a maximum of 3 letters,
[Link]
chosen from the 26 lowercase letters of the English alphabet then the maximum
four-methods-to-create-
number of permutations of these letters is
26 x 26 x 26 = 17576
actually-1601854240
A computer might take only a few seconds in a brute-force attack to try each
permutation in turn until the password is found that enables access to a system.
Three letter passwords would be considered very weak. Even extending the Key point
choice to the 95 characters (letters and symbols) on a computer keyboard (26 cards:
Graphic cards are cheap, and
uppercase, 26 lowercase, 10 digits and 33 punctuation and special symbols)
can be programmed to do basic
would not significantly improve matters. computations very quickly such
Weak passwords are also ones that use predictable patterns, e.g. the most as trying to guess password
combinations.
common passwords of 2016 include “123456”, “password”, “qwerty” and
“111111”, according to a recently released compilation1.
Key fact
Using common words, i.e. words that would be found in a dictionary, or a list Weak passwords:
of people’s names or place names also produces weak passwords. Use of such Many people use weak passwords
passwords can be discovered by a dictionary attack. A dictionary attack is one because it can be difficult to
remember strong passwords.
that attempts to discover a password by trying words found in dictionaries.
The dictionary is organised by length of word so it tries single letter words then
double letter words next and so on.
1 [Link]
2016-research-study/
6 Cyber security

Did you know? Recent tests2 cracked eight-character passwords in less than two hours by using
clusters of graphic cards programmed to try permutations of the 95 characters
There are still systems that do
not allow passwords longer than found on a computer keyboard (Figure 6.2.2). An eight-character password
eight characters and no additional is thus now considered weak. The testers concluded that the same processing
security measures such as two- power applied to twelve-character passwords was likely to take a minimum of
stage authentication.
17134 years. A twelve-character password is thus considered very strong.
In June 2014, an ATM belonging
to the Bank of Montreal was
successfully hacked by two
fourteen year-olds using an old
online ATM operator’s manual
that showed how to log into the
cash machine’s administrator’s
account.
During a school lunch break, one
day, they decided to conduct an
experiment with one of the bank’s
Figure 6.2.2 Computer keyboard
ATM cash machines.
Expecting little success they tried Passwords can be difficult to remember, which is one reason why people choose
a six-digit password which to their short simple passwords containing predictable sequences of letters forming a
surprise got them into the system. memorable name or word contained in a dictionary.
Rumour has it that the password
The best kind of password is one that is long and random, or at least appears
they tried was ‘123456’.
They immediately went into to be random. A trick to creating a strong password is to use a sentence or
the bank and told staff that phrase that is meaningful and easy to remember. For example, the password
the security on their ATM was Mio68whiJ£76# was created by taking the initial letters of the words in the
woefully inadequate. The bank
following sentence, substituting ‘£’ for ‘,’ and # for ‘.’ and including the digits
staff did not believe the two
directly:
students initially until they “My innings of 68 was hit in July, 76.”
received a demonstration. The
• Recent research has shown that changing passwords frequently is no
students were then interviewed by
better than not changing passwords, although people still argue that it
the branch manager and sent back
to school with a note explaining
is.
that they were late because they • Don’t re-use passwords and use a different password for each system
had been assisting the bank with that you log into.
their security. Don’t try this • The use of a single password such as your Facebook or Google
yourself! password is not recommended because if this is stolen then all the
systems that you use this password for will be compromised.
• It is alright to write passwords down in a notebook as long as the
notebook can be kept somewhere safe away from the computer(s) that
you use and from being accessed by anyone but you.

2 Read the following article on the potential consequences of the use of


weak passwords.
Virgin Media router security flap follows weak password exposé:
[Link]

2 [Link]
processing-units-may-threaten-worlds-password-security
6.2 Social engineering threats

Questions
4 Which of the following statements would you judge to be true (you
may want to use Figure 6.2.2 to help you answer this question):
123456 is a very weak password.

\zxcvbn,./ is a strong password.


Ms?niW£si36# is a very strong password.
1q2w3e4r5t6y7u8i9o is a very strong password.
5 There are many free online password strength checkers.
Explain why for security reasons you should avoid using a Key term
password checking service. Default password:
Explain how you would choose a strong password so that you A default password is a
password assigned to equipment
would not need to rely on an online password checking service.
and software systems for the
administrator’s account, along
Default passwords with the account’s username,
e.g. admin.
New computers with an operating system already installed, hardware such
Such default passwords used
as routers, wireless security cameras, baby monitors, and database engines by manufacturers and software
such as MySQL, for example, come set up with a default password for the systems are not particularly
administrator’s account, and the account’s username, e.g. admin. secret and so systems that
they are meant to protect are
An administrator’s account has the highest possible access rights and therefore
vulnerable to being hacked and
full control to do anything to the system. worse they grant the highest
It is not difficult for a hacker to obtain the default password used by a possible access rights.
particular manufacturer or installer for the systems sold. Armed with a
knowledge of the default password for the administrator’s account an attacker Did you know?
could take control of a system in order to profit in some way from the gift of Linksys®, a manufacturer of
unfettered access. routers, is now using WPA2
passwords which are unique on
It is very important to change the default password for the administrator’s
each device.
account when setting up a new system and before going live.
Internet of Things (IoT) devices connect to wireless networks and are therefore
vulnerable to being “hacked”. Tens of billions of these devices have been
deployed. If they are password protected then they could have been sold with 3 Read the following
a default password and username. The Mirai malware let attackers hijack article on the failure
thousands of Internet of Things devices and carry out distributed denial-of- to change the default
service attacks. password:
Users should reset the default password when they get an IoT device. Webcam spying
disaster: [Link]
Questions [Link]/
6 Explain why generating a one-time password that a user is forced technology/picture-
to reset as part of setting up a device could help to solve the default galleries/11279102/The-
password issue. six-worst-tech-disasters-
[Link]?image=1
6 Cyber security

Misconfigured access rights


Key term
A basic underlying principle for securing computer systems and data is the
Misconfigured access rights:
Misconfigured access rights principle of least privilege. This means that users are only granted those access
occur when user accounts have rights and permissions they need to perform their official duties, role or work.
incorrect permissions. Access rights determine, for example, what files may be accessed and in what
A user whose status dictates modes - read only, read/write, delete, execute; what programs may be run and
that they should have restricted
whether the user may install programs; what operating system commands may
access rights could have been
granted less restricted access be run, e.g. none, a restricted subset, all including the most powerful.
rights by mistake. Access rights are misconfigured when user accounts have incorrect permissions
This could cause problems. granting them the authority to do things that they shouldn’t be allowed to do.
For example, less restrictive
For example, less restrictive access rights and permissions might be granted in
access rights could grant access
to private information which
error to a user of insufficient status or trust allowing the user to do any of the
the user does not have authority following and more:
to view. • to run executables
• to read data belonging to a certain account
• to run powerful operating system commands which could
Key principle compromise a computer or computer network, etc.
Least privilege principle: The consequences could be, for example, that private information such as
To reduce the likelihood of a employee records, customer data, medical records, student records, passwords,
data security breach or harm etc, could be accessed and passed on. This is not only a security breach but
n
tu also potentially breaks legislation, e.g. the Data Protection Act 1998 (and its
system requires policies and
l i replacement in 2018 the GDPR) - “Data should be kept secure: Appropriate
based on the technical and organisational measures shall be taken against unauthorised or
r r unlawful processing of personal data and against accidental loss or destruction
r
r r of, or damage to, personal data”.
m .be
given only the minimum access Also, if the user was a disgruntled employee, more damage might be done
to sensitive data or computer to the business with an incorrect elevated level of access such as granting the
system necessary to perform power to delete, or read and possibly leak important files.
a job function and that access
should only be granted for the A hacker could exploit a user’s elevated access rights and do harm to the system
minimum time necessary. or take over the system in both cases by gaining access to the user’s account
which might not be so well protected, e.g. by a strong password or two-factor
authentication, as user accounts belonging to users with higher status within
the organisation, and therefore elevated access rights.

Questions
7 Which of the following statements are always true?
The principle of least privilege states that users are only granted those access rights and permissions
they need to perform their official duties.
Access rights determine, among other things, what files may be accessed.
Misconfigured access rights occur when user accounts have correct permissions.
A network manager of a school’s computer network would be granted full access rights.
Misconfigured access rights occur when user accounts have incorrect permissions.
6.2 Social engineering threats

Removable media
An infection of Manchester City Council’s IT system caused an estimated
Questions
£1.5m worth of disruption in February 2009. The use of USB flash drives was 8 Explain what is meant
banned, as this was believed to be the cause of the initial infection. by access rights.
Care in dealing with external devices is necessary because of the threat 9 Why it is important to
of malware infection by means of AutoRun and external drives/media.
assign access rights to
Malware infection of computer systems by Autorun and USB flash drive was
documented in a 2011 Microsoft study3. The study found that 26 percent user accounts?
of all malware infections of Windows systems were due to USB flash drives
exploiting the AutoRun feature in Microsoft Windows.
AutoRun, and the companion feature AutoPlay, are components of the Key fact
AutoRun and removable
Microsoft Windows operating system that dictate what actions the system takes
media:
when a drive is mounted, e.g. a CD-ROM or a USB flash drive.
AutoRun and the companion
An entry in the Windows Registry controls whether AutoRun is enabled or feature AutoPlay are
disabled for a particular drive. components of the Microsoft
If AutoRun is enabled then a text file [Link], if present, is opened and Windows operating system that
any commands present are executed. Such commands include very powerful dictate what actions the system
operating system commands. Figure 6.2.3 shows the contents of a sample takes when a drive is mounted,
[Link] file which tells Windows to run [Link] program located in the e.g a CD-ROM or a USB flash
CD root folder. Also it specifies that Windows should use the first icon from drive.
[Link] to display this CD in Explorer.
[autorun]
Variants of the deadly Conflicker worm are spread Key fact
through removable media (e.g. flash drives) exploiting open=[Link]
Removable media and
the AutoRun feature of the Windows operating icon=[Link],1
malware:
system. Removable media can be a
The United States Computer Emergency Figure 6.2.3 [Link] source of malware which can
4
Readiness Team (US-CERT ) recommends example contents infect a computer system.
disabling AutoRun to prevent malware from spreading through removable
media. Figure 6.2.4 shows the result of running Kaspersky Lab software on a
computer with autorun enabled. Did you know?
Use of [Link] commands
to protect music CDs:
An audio CD, that a user would
not expect to contain software
at all, can contain a data section
with an [Link] file of shell
commands. Some companies,
Figure 6.2.4 Warning message from Kaspersky Lab software
such as Sony BMG, have used
If copying to removable media is permitted then the system is potentially open this to install their software
to confidential information being stolen. The National Security Agency (NSA) that attempts to protect against
had classified information copied and leaked by Edward Snowden in 2013 copying of the audio tracks.
without authorization.
Questions Information
10 Why should AutoRun be disabled in computers running a Windows
operating system? A computer worm is a standalone
malware computer program that
3 [Link] replicates itself in order to spread
2BDEB58211B8/Microsoft_Security_Intelligence_Report_volume_11_English.pdf to other computers.
4 [Link]
6 Cyber security

Unpatched and/or outdated code Key term


Malicious persons can take advantage of unpatched computer vulnerabilities.
patch:
Such persons search non-stop for software vulnerabilities to exploit. For A software patch is a piece of
example, software vulnerabilities have been found in outdated or unpatched software designed to update
versions of Adobe Flash, Oracle’s Java, Microsoft’s SQL Server, Apache web a computer program or its
supporting data, to fix or
server, and operating systems such as Android, Windows and Linux.
improve it. This includes fixing
The cycle proceeds as follows: security vulnerabilities and
other bugs.
Software containing vulnerabilities:
A software vendor releases software that contains security-related bugs.
Malicious persons (or a Government agency, e.g. NSA): Did you know
Identify the security-related bugs in the software. Java and Flash versions on
Exploit code: browsers are most likely
outdated. As a safety measure
Malicious persons develop code that can exploit the bugs in the
many companies uninstall Java
software. and Flash from browsers.
Vendor response: “Outdated, Unpatched Software
The software vendor becomes aware of the situation and issues a patch Rampant in Businesses” article
in Threat Post.
to correct the bugs.
[Link]
User response: unpatched-software-rampant-in-
Users apply the patch to their system to make them secure for the time businesses/117976/
being.
The Slammer worm which exploited vulnerable versions of Microsoft’s SQL Server was the fastest computer worm
in history. It is estimated that as many as 90% of the vulnerable servers online were infected within ten minutes.
The Slammer worm spread at a time when a patch for the vulnerability it exploited had been available for six
months. Named MS02-039, the patch should have ideally been installed on the vulnerable servers long before the
worm started its chaotic journey across the Internet.
Proper patch management is
very important. Software updates
should be automatically managed,
if possible, so that identified
vulnerabilities are removed before
they can be exploited. Don’t keep
or use out of date software on your
computer, especially if patches
for newly identified bugs are no
longer supported, e.g. Windows XP
operating system.
Figure 6.2.5 shows Kaspersky
Lab software reporting multiple
vulnerabilities in CPython software
installed on a computer system.
The offending sofware was removed
from this computer. Figure 6.2.5 Warning message from Kaspersky Lab software
6.2 Social engineering threats

Figure 6.2.6 shows Microsoft Windows 7 update configuration settings screen.

Key points
Strategy for dealing with
vulnerabilities from unpatched and/
or outdated software:
1. Apply patches to fix software with
identified vulnerabilities.
2. Apply patch as soon as it becomes
available.
3. Stop using software identified as
vulnerable until patch becomes
available.
4. Check for software updates regularly
and automatically.
5. Remove outdated software.
6. Consider removing software
altogether if it is not possible to
update automatically
7. Remove software that is no longer
supported because vulnerabilities yet
to be discovered will not be patched.

Figure 6.2.6 Microsoft Windows 7 update


configuration settings screen

Questions
11 Why are software patches required?
12 (a) Why may software on a computer be vulnerable to attack from attackers with malicious intent?
(b) What needs to be done to improve security against such attacks on vulnerable software?

Penetration testing
A penetration test, is a survey, assessment, and test of the security of a given
Key term
organization’s computer systems carried out by a penetration tester (pentester)
Penetration testing:
using the same techniques, tactics, and tools that a malicious hacker would use. A penetration test, is a survey,
In simpler terms, it is the process of attempting to gain access to resources assessment, and test of the
without knowledge of usernames, passwords and other normal means of access. security of a given organization’s
computer systems carried out by
The main differences between a malicious hacker and a pentester are a penetration tester (pentester)
• A pentester attempts to find security weaknesses in a system but does using the same techniques,
not attempt, unlike a malicious hacker, to exploit them only report tactics, and tools that a
malicious hacker would use.
them to the owner of the system.
In simpler terms, it is the
• A pentester has permission, both legal and otherwise, from the owner
process of attempting to gain
of the system that will be evaluated whereas a malicious hacker does access to resources without
not. knowledge of usernames,
A penetration tester, or pentester, is either an employee of the owner of the passwords and other normal
system or an external contractor hired on a per-job or per-project basis. means of access.

Pentesters are required to never reveal the results of a test to anyone except those
designated by their client.
6 Cyber security

White-box penetration testing


Key term
The aim of white-box penetration testing is to quickly detect problems and fix
White-box penetration
them before an external party locates and exploits them.
testing:
The aim of white-box It is commonly performed by internal teams who simulate a malicious insider
penetration testing is to quickly with full knowledge of the structure and makeup of the target system.
detect problems and fix them The time and cost required to find and resolve the security vulnerabilities is
before an external party locates significantly less than with the black-box approach.
and exploits them.
Black-box penetration testing
It is commonly performed by
Black-box testing is a type of test that most closely resembles the type of
internal teams who simulate
a malicious insider with full situation that an outside attack presents and is sometimes known as an external
knowledge of the structure and test.
makeup of the target system. Essentially, the aim of black-box penetration testing is to simulate an external
Black-box penetration
hacking attack or a cyber warfare attack where the attacker has no knowledge of
testing: any credentials for the target system.
Black-box testing is a type of To perform this test a pentester will execute the test from a remote location
test that most closely resembles much like a real attacker.
the type of situation that an The pentester will have nothing other than the name of the company to go on.
outside attack presents and is The pentester will log and keep track of the vulnerabilities of the system under
sometimes known as an external
test and report on these.
test. Essentially, the aim of
black-box penetration testing is Questions
to simulate an external hacking
or cyber warfare attack where
13 What is penetration testing?
the attacker has no knowledge 14 Which of the following statements are true?
of any credentials for the target Black-box penetration testing finds vulnerabilities of a system
system. more quickly than white-box penetration testing.
White-box penetration testing is conducted remotely.
White-box penetration testing uses the full knowledge of the
structure and makeup of the target system.
Black-box penetration testing simulates external hacking.
4 Visit the following site A black-box penetration tester has little knowledge of the target
and explore some of the
system to go on.
world’s biggest hacks:
[Link] 15 What is meant by white-box penetration testing?
informationisbeautiful.
16 What is meant by black-box penetration testing?
net/visualizations/worlds-
biggest-data-breaches-hacks/
In this chapter you have covered:
■ The meaning of the term cyber security and the main purposes of cyber
security
■ The following cyber security threats:
• social engineering techniques
• malicious code (malware)
• pharming
• weak and default passwords
• misconfigured access rights
• removable media
• unpatched and/or outdated software
■ What penetration testing is and what it is used for.
6 Fundamentals of cyber security
6 Fundamentals of cyber security
Learning objectives:
■ Define the term social
engineering
■ 6.2.1 Social engineering
What is social engineering?
■ Describe what social Social engineering is the art of manipulating people so that they give up
engineering is and how it can
confidential information. It is a mind game in which social engineers play with
be protected against
human psychology to gain confidence and win confidential information.
■ Explain the following forms of Social engineering is used to realise a number of outcomes:
social engineering: 1. Financial fraud
• blagging (pretetxting) 2. Identity theft
• phishing 3. Unauthorized access to protected systems.

• shouldering (or shoulder Social engineering involves tricking a person into divulging confidential
surfing). information that may then be used, for example, to gain access to the person’s
computer system, bank account, etc, or to steal their identity and exploit this
theft for financial gain by obtaining, say, a bank loan in the person’s name.
The social engineer sets up and defines a situation where it will seem natural,
normal, or helpful for the person being socially engineered to provide the
Key term requested information or to click the link that’s displayed.
Social engineering: To extract information from the unsuspecting, social engineers rely on creating
Social engineering is the art a sense of urgency in their victims, so that they will respond immediately and
of manipulating people so without thinking. It is human nature to be helpful, to avoid trouble or conflict,
that they give up confidential
and to try to fix things when they break.
information.

The “colonel effect” experiment was conducted by Aaron J. Ferguson at


Information West Point Military Academy in America. He sent a bogus email message
Accounts used to share files with the subject heading “Grade Report Problem” to 500 cadets, asking
and images such as Google them to click a link to confirm that the grades on their last grade report
Drive, Adobe Creative Cloud, were correct or otherwise to report any problems. The email was signed
and Dropbox are the most
Colonel Robert Melville but there was no such colonel at West Point.
effective lures used by social
engineers according to a report, Over 80% of recipients clicked the link in the message. In response, they
The Human Factor 2017, received a notification that they’d been duped and a warning that their
by Proofpoint®, Inc. (www. behaviour could have resulted in downloads of spyware, Trojan horses
[Link]).
and/or other malware.
The “colonel effect” refers to a form of social engineering which exploits
a culture in which an action such as clicking on a link is executed
regardless of its nature because the message purports to come from
an authority figure. It is also known as the “CEO fraud” or “Chief
Executive Officer fraud”.
6 Fundamentals of cyber security

Example 2 - Playing on the urgency of addressing a security issue


You are contacted by phone by a person claiming to be from the security department of Microsoft. The
person says that your Microsoft Cloud account’s security has been compromised and they need to ask you
a few questions before the security issue can be fixed. The questions are as follows
1. What is your full name and address?
2. What is your username?
3. Have you ever written down your password where someone else can find it?
Your answers to these questions are
1. Fred Bloggs, 55 Acacia Avenue, Dingley Dell
2. FredB
3. No I don’t need to.
“That is excellent especially the fact that you haven’t written down your password”, replies the person.
“How do you manage to remember your password, I never can says the person?” To which you reply,
“because it is my sister’s first name”. “Ah that is good because we will also need to talk to your sister
because, according to our records, her Cloud account has been compromised as well. To save time and
because the problem needs to be fixed urgently, can you answer the first two questions for her now.” You
are concerned that your sister’s Cloud account is potentially vulnerable so you oblige and supply your
sister’s full name, address and username, after all where is the harm you think to yourself, her surname and
address is the same as mine.
(a) How do you know that the person is genuinely from Microsoft?
(b) How did the person obtain your password?
(c) Why might the person want your username and password for your Microsoft account?

A person receives the following email message purportedly from Yahoo mail:
“Due to the congestion in the Yahoo mail system, Yahoo mail will shut down all unused accounts. You must
confirm your email by filling out your login information below and then clicking the Reply button. Failure
to do so will result in account suspension.”

1. Relying on the tendency of humans to be helpful by reducing account congestion


2. Informing the reader that failure to comply with the request will result in account suspension and
loss of access to their email
3. Giving the reader no choice but to click on the Reply button (a hyperlink to a website),
threatening account suspension for failure to comply
4. A reason why this email has been sent: Account congestion and removal of unused accounts
6.2.1 Social engineering

Questions
1 You have just entered your keypad code into an electronic lock to let yourself into the office building
where you are working during your summer holidays. A senior looking person follows you in and says he
is glad that you were around as he had forgotten his keypad code. It would have been very embarrassing
for him to be locked out, he says, as he is late for a meeting with the CEO. He asks you to remind him
what the keypad code is, to save him the hassle of contacting security.
(a) Would you let him in? Justify your answer.
(b) Would you divulge the keypad code to him? Justify your answer.
(c) Would your decision have depended on whether the person carried an air of authority?
2 You receive an email with subject “Confirm your availability for the first eleven for next Saturday’s football
fixture against Bash Street Academy”.
You are asked in the body of the email to click on a link to confirm your availability or unavailability. The
email is signed Head of Games and nothing else.
The email rings true because according to the fixture list, next Saturday’s game is against Bash Street
Academy and you do play in the first eleven football team.
(a) What about this email might be considered suspicious?
(b) What about this email might be considered authentic?
(c) How might genuine information included in this email have been obtained?

How to protect against social engineering


Protecting yourself from social engineering requires being aware of the potential security risks, and taking steps to
minimise them.
1. Never reveal personal, financial, or other sensitive information over the phone or the Internet.
2. Never reveal any of the usernames and passwords that you use.
3. Never reveal answers to typical security questions. These are often relied on when you reset passwords. For
example, any of the following
a. What is the name of your favourite pet?
b. What is the name of the town/city where you were born?
c. What is your favourite colour?
d. Etc.
4. Be mindful of information that you post on the Internet, and understand that it could be visible to
strangers.
5. If a caller claiming to be from some company, financial institution or organisation asks for confidential
information then always ask for their contact information which you should then verify is real using some
independent and reliable means such as a phone book or the company’s website.
6. Ignore spam and steer clear of clicking links in Tweets, Facebook pages, etc.
7. Remove access to PowerShell code from your user account - PowerShell is a tool that delivers power and
control over the Windows operating system and the underlying hardware.
8. Remove admin rights from your user account so that you cannot have control over the Windows
operating system and the underlying hardware.
9. Disable macros or only use macros that can be trusted, i.e. macros which are digitally signed by a trusted
source.
10. Be wary of rigged Word documents sent to you and which encourage you to “enable content”. This action
could install malware in your computer’s RAM with unfortunate consequences.
6 Fundamentals of cyber security

Key term Blagging (pretexting)


Blagging, a form of social engineering, is the act of creating and using an
Blagging (pretexting): invented scenario to engage a targeted victim in a manner that increases the
Blagging is the act of creating
chance the victim will divulge information or perform actions that would be
and using an invented scenario
to engage a targeted victim in unlikely in ordinary circumstances. For example, you might be contacted by
a manner that increases the telephone by someone claiming to be from Microsoft, say, who claims that
chance the victim will divulge there is a problem with your computer. After some discussion they ask for your
information a blagger wants,
username and password. This is a fairly blatant and unsubtle attempt to get you
e.g. sensitive or personal nature
such as passwords, or perform
to reveal information of a sensitive or personal nature. However, the telephone
actions that would be unlikely call could be much more subtle as illustrated in Example 2 on page 302. The
in ordinary circumstances, reason why this example might work is that people are easily manipulated
making a payment by credit into giving away information if they believe it is in their best interest to do
card to the blagger to fix a
so, or because they believe they are helping in some way. Especially if the
non-existent problem with your
computer. person claims to be in some position of authority, because the target of the
blag believes that the “attacker” has the right to know - see the “colonel effect”
example on page 301. We have been brought up to answer and work with
Key term authority figures, and not question them!
Shouldering (shoulder Shouldering (or shoulder surfing)
surfing): Shouldering is observing a person’s private information over their shoulder, e.g.
Shouldering is observing a cashpoint machine PIN numbers.
person’s private information over
their shoulder, e.g. cashpoint
machine PIN numbers.

Questions
3 A person is contacted by telephone by someone claiming to be from their bank. They say recent activity
on the account leads them to believe that this bank account has been hacked. Before they proceed any
further they would like to ask some security questions. They conversation proceeds as follows
“Bank”: What is your date of birth?
Person: 23/06/1998.
“Bank”: Name one direct debit set up on your account.
Person: Vodaphone.
“Bank”: What are the first and fourth digits of your PIN?
Person: 8 and 9.
Person: Sorry, I didn’t catch that, what did you say are the second and third digits of your PIN?
Person: 3 and 2.
“Bank”: What is your mother’s maiden name?
Person: Smith.
“Bank”: Thank you very much. I can now confirm that your account is secure and it has not been hacked.
(a) What should the person have done to decide whether or not it was safe to proceed with this telephone
conversation?
(b) What confidential information has the person given away that could enable his or her bank account to
be illegally accessed and money to be stolen?
6.2.1 Social engineering

Phishing Key term


Phishing is a technique of fraudulently obtaining private information, often by
using a legitimate-looking email or SMS in which a lure is dangled in front of Phishing:
Phishing is a technique of
an unsuspecting user of the Internet.
fraudulently obtaining private
A phishing email or SMS message purports to come from a legitimate and/ information, often by using
or trusted source, e.g. a bank, and attempts to fool you into revealing login email or SMS.
credentials, financial details, and/or sensitive information that can later be used
to commit fraud or access accounts. Key term
Phishing casts a big net to catch a few fish. It uses unsolicited email (spam),
Spam:
text messages, or other forms of communication sent out in bulk, i.e. to many Unsolicited email or messages
people. While many people will dismiss the message, a few will respond to it. that are sent to groups of
people.

Scenario 1 - stealing credentials


One phishing technique sends an email containing a link
which you are invited to click, say, to reset the password that
you use to login into a service, e.g. gmail.
Clicking this link will take you to a bogus website, that looks
like the real thing, in which you are invited to enter your
username and password.
Of course, this fake web site is designed to collect the
unsuspecting user’s username and password so that the
attacker can gain access to the person’s gmail account and
emails associated with this account.

Scenario 2 - exploiting security vulnerabilities in web browsers

Another phishing technique sends an email containing


a link which you are invited to click on but this time
the recipient of the email is taken to a website page with
an exploit kit. The exploit kit relies on an out of date
browser being used with security vulnerabilities and
which the kit can exploit to download malware.
Once installed, the malware can steal passwords, install a backdoor into the compromised computer or even
encrypt all files on the computer (ransomware).
Many people think phishing is only a credential problem (i.e. usernames and passwords). They believe that
they are safe as long as they don’t enter their credentials after clicking on the phishing link.
This isn’t true as can be demonstrated with the above exploit kit scenario.
In this case, just clicking the link results in your browser and computer being completely compromised.

Information
Download from KnowBe4 the 22 social engineering red flags to watch out for in any email document:
[Link]
6 Fundamentals of cyber security

Scenario 3 - malicious attachments


Another phishing technique sends an
email containing a malicious attachment.
Malicious attachments come in many forms,
e.g. Word documents, HTML files, zip files
or even executable programs (.exe, .jar, etc).
The recipient of the email is tricked into
downloading and opening/executing the
attachment.
The most common malicious attachments
are Word (or any Microsoft Office tools)
document files. In this case, the attachments
which are macros contain malicious code.
Malicious macros are typically bits of
code designed to damage the user’s device
(computer) when the code is run. The macro
could execute a command to wipe the entire
contents of a disk or it could execute code
that downloads and executes other malware.
Microsoft knows that letting macros run
automatically is dangerous, so they prompt
you to see if you want to execute the macro.
If you do not trust the source you should
decline or even safer decline full stop!
However, attackers have got “smarter” and
try to trick you by making the document say
something like, “this document is encrypted
for your protection, enable macros to
decrypt the contents.”

Scenario 4 - pop-up ads

When you browse the web, you might see a pop-up ad or a page warning you about a problem with your
device. These alerts are pop-up ads, designed to trick you into calling a phoney support number or buying
an app that claims to fix the issue. Don’t call the number. Simply close the pop-up ad, or navigate away from
that page and continue browsing.

A trio of terms captures just about every phishing attack: imitate, motivate, and act (click a link, reply to an e-mail,
or whatever).
Imitate: A phishing message strives to look like it comes from some particular organization.
Motivate: Motivation is the social engineering part of a phishing attack.
Act: The visible hook in a phishing attack is the form that users are requested to fill out. To access this form, users
must take action (click a link, send a reply, etc). An invisible hook may also lurk in a phishing attack, i.e. the
phishing page visited may cause a drive-by download of malware. If this happens, even users who don’t bite the
visible hook and fill out the form may still fall prey to the invisible hook if the malware download succeeds. The
victim is then stuck with a keylogger and a backdoor Trojan that he or she may not know about for some time.
6.2.1 Social engineering

Antivirus software cannot protect against all malware attacks.


Therefore, computers are not entirely safe from malware, so avoidance, i.e. don’t reply to the email or click the link,
remains the best strategy.
These signs can help you identify phishing scams:
• The sender’s email address or phone number doesn’t match the name of the company that it claims to be
from.
• Your email address or phone number is different from the one that you gave that company.
• The message starts with a generic greeting, like “Dear customer.” Most legitimate companies will include
your name in their messages to you.
• A link appears to be legitimate but takes you to a website whose URL doesn’t match the address of the
company’s website.
• The message looks significantly different from other messages that you’ve received from the company.
• The message requests personal information, like a credit card number or account password.
• The message is unsolicited and contains an attachment.

Questions
4 The email shown in Figure
service@[Link] 8 July 2017 at 13.06
[Link] purports to come from
PayPal, an American company To: customer
operating a worldwide online Resolution of Buyer Complaint Case # PP-001-811-430-813
payments system that supports
Hello,
online money transfers.
Give two reasons for After careful consideration of the evidence provided in the case
thinking that this is a detailed below, we have completed our investigation and decided
phishing email. in favor of the buyer. Under terms of our User Agreement, we have
Give two security risks that debited the following amount from your PayPal account as a refund
the recipient of this email to the buyer: 450.00 EUR
could face by clicking on the ......
......
link “click here ...”.
What aspect(s) of human Case number: PP-001-811-430-813
nature do you think that Click here to resolve the problem right now
this phishing email is ........
exploiting? Please do not reply to this email. This mailbox is not monitored and
you will not receive a response. For assistance login to your PayPal
5 Give three signs that can help
account and click the Help link in the top right corner of any PayPal
to identify phishing scams.
page
....... Figure [Link]
6 Fundamentals of cyber security

In this chapter you have covered:


■ Defining the term social engineering
■ Describing what social engineering is and how it can be protected against
■ Explaining the following forms of social engineering:
• blagging (pretetxting)
• phishing
• shouldering (or shoulder surfing).
6 Fundamentals of cyber security
6 Fundamentals of cyber security
Learning objectives:
■ Define the term ‘malware’ ■ 6.2.2 Malicious code
■ Describe what malware is and Malware
how it can be protected against Malware is any software that’s installed on a computer with the intention of
■ Describe the following forms of executing malicious code and/or causing damage such as corrupting data.
malware:
In the UK, under the Computer Misuse Act, it is criminal offence, punishable
• computer virus by imprisonment for up to 10 years, to develop malware and/or disseminate
• trojan
malware.
• spyware.
Figure [Link] shows a list of all processes loaded into the RAM of a Windows
XP computer. A process is an instance of a program in execution.
Information This list shows that three instances of an executable program [Link] have been
[Link]:
This is a program that runs as loaded into RAM.
a process that is responsible for Each process has its own identifier called its PID (Process IDentifier).
enforcing the security policy For example, the first copy of [Link] has PID 680.
on the system. It verifies users A process started by another process will have a Parent Process IDentifier or
logging on to a Windows PPID. For example, the first copy of [Link] has a parent whose PID is 624,
computer or server, handles
the second and third 668.
password changes, and creates
This is suspicious because [Link] should always be started by
access tokens.
[Link] and [Link] has PID 624. The second and third copies of
Hexadecimal address in
RAM of start of process [Link] have PID 668 which is an instance of the program [Link]!

OK

Suspicious

Figure [Link] A list of processes (instances of executing programs) in a Windows XP machine


6 Fundamentals of cyber security

Suspicion is raised further on examining the dynamic linked libraries used by the first of the suspect copies of
[Link]. The list shown in Figure [Link] is not the list for the correct version of [Link]. When probed further,
the malicious code shown in Figure [Link] is found. This code has the normal permissions associated with the
correct [Link] of being able to execute and read but it also has a write permission which it shouldn’t have. In fact,
this computer has been infected with the Stuxnet malware (Stuxnet is a computer worm), a piece of malicious code
designed to damage equipment called a centrifuge operated by the computer.
Key term
Malware:
Malicious computer software
designed to do any of the following
Alter in a harmful manner
the way that your computer
operates, e.g. reformats the
hard drive on start up
Enable information to be
captured especially if it relates
to security, e.g. passwords
Take over your computer for
purposes such as launching
attacks on other computers or
sending spam mail to other Figure [Link] A list of dynamic linked libraries for the
computers. suspicious copy of [Link]

The legitimate [Link] requires


only PAGE_EXECUTE_READ
to operate

Figure [Link] Exposure of the


malicious code of the Stuxnet
malware

This code shown in assembly language form


has been injected into [Link]. It is the code
for the Stuxnet malware. This malware infected
computers controlling the operation of centrifuges
used by Iran in its nuclear bomb programme.
Stuxnet destroyed up to 1000 of these centrifuges
setting back the programme by 2 years.

1 Take the cyber security challenge VOLATILE


SITUATIONS at [Link]
This game emulates the process of using open source
software called Volatility to analyse a memory dump
(copy of the contents of RAM) and find evidence of
malware.
6.2.2 Malicious code

Virus
What is a virus? Information
A virus is a particular form of malware. Floppy disk:

A virus is a self-replicating piece of software that, like a biological virus, A floppy disk is a removable
storage device that is little used
attaches itself to another program, or in the case of macro viruses, to another
now. It is based on similar
file. The virus is only run and copied when the program it is attached to is run
technology to magnetic disk
or the file it is attached to is opened.
storage technology.
If the program or file isn’t accessed in any way, then the virus won’t run and
won’t copy itself.
Key term
Program virus
Virus:
In 1982 a virus labelled the Elk Cloner was written to attack the Apple II
A virus is a self-replicating piece
operating system. This virus ran whenever a computer was started from an of software that, like a biological
infected floppy disk, and would infect with a copy of itself any other floppy virus, attaches itself to another
disk put into the disk drive. This virus was attached to a program that ran program, or in the case of a
macro virus, to another file.
every time the computer was booted from the infected floppy disk.
The virus is only run when the
The Stuxnet malware was attached to a copy of the operating system program program it is attached to is run
[Link]. or the file it is attached to is
Viruses can have harmful effects, ranging from displaying irritating messages opened.
to stealing data or giving other users control over your computer. If the program or file isn’t
accessed in any way, then the
For example, the virus Elk Cloner displayed a message every 50 times the
virus won’t run and won’t copy
computer was started. itself.
Document virus
Document viruses do their
[Link]
damage via a macro attached to
a document.
Figure [Link] shows one way
Test2
to create a macro in Visual
Basic for Applications (VBA).
The VBA code executes when
Test2
the Word document containing
this macro, [Link], is
VBA code written in this window
opened in Microsoft Word. The actual code which creates a pop-up window
This results in a popup window has been hidden
appearing for 5 seconds on top
of the opened Word document
as shown in Figure [Link].

Figure [Link] Shows a VBA coding window for creating code to embed in a
Word document and which executes when the Word document is opened

VBA language statements would be written in the coding window shown in


Figure [Link].

Figure [Link] PopUp window that


appears on top of opened Word
document [Link]
6 Fundamentals of cyber security

Email virus
This is illustrated by a Word document + VBA macro delivered by email as shown in Figure [Link].
The document [Link] attached to the email contains the VBA macro.

Information
In the UK, under the
Computer Misuse
Act, it is a criminal
offence, punishable by
imprisonment for up
to 10 years, to develop
malware and/or
disseminate malware -
[Link]
[Link]/ukpga/1990/18

Figure [Link] Email with Word document attachment

The macro executes when document [Link] is opened unless the user of the document takes steps to prevent
the macro running. Although this macro is relatively benign there are operating system commands it could run
which have the potential to wreak havoc. The macro then becomes a virus, a piece of malicious code.
A macro virus author can program the macro to do almost anything that is possible with a
PC.
For example, it can corrupt data, send files across the Internet, send a copy of itself by email
to other email accounts and format hard drives. The punishment for writing and distributing
viruses is prison for a very long time!
A macro virus can be written to attach itself to Microsoft Word via one or more Word’s document templates, e.g.
[Link] thereby infecting every document subsequently opened in Word.
A macro virus can also be written to search the infected computer for files containing email addresses and then
using these send a copy of itself to new recipients. Typically, such email viruses rely on people double-clicking on
an attachment to distribute themselves automatically. Any attachment that you receive by email could carry a virus;
and launching such an attachment could infect your computer.
One step that you could take is to disable macros or at least configure your computer to request confirmation before
proceeding to open a document containing one of more macros.
Another is to use anti-virus software which scans a program/file for tell-tale signs of malicious code.
6.2.2 Malicious code

Questions
1 Which of the following statements are true.
A computer virus is a form of software bug which can cause errors when executed.
A computer virus does not need to be embedded in another program or document to spread or to
wreak havoc in a computer system.
A computer virus is a type of malware.
A computer virus spreads when the software or document file it is attached to is transferred from one
computer to another.
A computer virus inserts a copy of itself into another program or document.

2 Explain why one needs to be careful when opening an email attachment.

3 It is believed that the Stuxnet malware infected the computers controlling the Uranium enrichment
process when they were hooked-up to a Windows-based tablet computer for diagnostic purposes.
Infection via the Internet was not possible since the computers were not connected to the Internet.
What measure or measures could have been taken to reduce the likelihood of the computers becoming
infected with a virus?

Trojan
A Trojan or Trojan horse is a program that pretends to be legitimate software, but actually carries hidden, harmful
code.
A Trojan program claims to have one function (and may even carry out this function), e.g. it claims to be a game
program, but it actually also does something harmful as well behind the scenes.
For example, Trojan horse software could be created by using a wrapper to bundle together legitimate software, a
game, with two other files intended to do harm, into a single file, [Link], and to make this game of
noughts and crosses available for download from a Web site, [Link].
The three files could be
1. [Link]
Key term
2. [Link] Trojan:
A Trojan or Trojan horse is a
3. [Link]
program that pretends to be
Files with extension .vbs are VBScript files. [Link] does what it says. legitimate software, but actually
It copies the malicious code file [Link] to the root directory of the carries hidden, harmful code.
C: drive. It inserts an entry into the computer’s registry to ensure that the copy Once the Trojan is run, it adds
a part of itself to the computer’s
of DodgyScript at C:\ runs whenever the computer is started. The downloaded
startup routine. This part can
copies of DodgyScript and SetUpTrojan are then deleted from the download then run when the computer
directory. Finally, it causes the game executable OandXs to run. is started up. A form of Trojan
called a backdoor Trojan allows
[Link] would be uploaded, say, to a directory games located
the person who sent the Trojan
within the Web site to run programs on the infected
[Link].
computer, access personal files,
The game + Trojan would be downloaded by clicking on the following modify and upload files. track
download link the user’s keystrokes, or send out
spam mail.
[Link]/games/[Link]
The next time that the computer starts, DodgyScript runs. This script may then
download more malware, e.g. a keylogger.
6 Fundamentals of cyber security

Alteration of the computer’s Windows registry to allow DodgyScript to run whenever the computer is started
requires that the user downloading the game + Trojan has admin rights.
Admin rights grant full access to all parts of the system.
Therefore, one strategy to prevent Trojan malware infecting a computer and potentially a network is to remove
admin rights from ordinary users.
Possible vectors for a Trojan are Information
Malware vector:
1. Email attachment
A vector in computing,
2. Link within the body of an email (email link) specifically when talking about
3. Visiting a Web site (Web site drive-by) and downloading the Trojan. malicious code such as viruses,
The following can be used to protect against these three methods of attack trojans and adware, is the
method that this code uses
1. Use email filtering - blacklist of links to be avoided, emails with exe to propagate itself or infect a
attachments blocked computer.
2. Use up-to-date antivirus software to recognise the signature of the
Trojan, if possible
3. Use Web filtering - keep a blacklist of Web sites to be avoided
4. User security awareness training -
a. Don’t click on email links without checking with the source that
email is genuinely from a trusted source
b. Don’t download email attachments without checking with the source
that email is genuinely from a trusted source
c. Don’t Web surf and click on download links, only download from Information
Definition-based (or signature-
trusted sites.
based) antivirus compares
Questions the signatures (MD5 or SHA-1
hashes) of the files encountered
4 Which of the following statements are true. to see if they match a list of
A Trojan is a kind of virus. known malware.
Typically, when signature-based
A Trojan is a kind of malware.
antivirus software encounters
A Trojan or Trojan horse is a program that pretends to be a signature match, the file is
legitimate software, but actually carries hidden, harmful code. quarantined.
Removing administrator rights from ordinary users can make it Cyber criminals writing
more difficult for a Trojan to infect computers. malware exploits such as Trojans
know their malware may
A Trojan program claims to have one function but it actually also
encounter antivirus software,
does something harmful as well behind the scenes. so they frequently include
5 State three measures other than user security awareness training that malicious code that disables the
antivirus software. In one highly
could be used to protect against downloading a Trojan.
specialized attack in May 2016,
the presence of the antivirus
6 State three things that users should avoid doing when using
software was used to actually
computers in order to minimise the chance of downloading a Trojan. install malicious code.
[Link]
6.2.2 Malicious code

Spyware Key term


Spyware is software installed in a computer to monitor the activities of its user Spyware:
and to report the gathered information to a third party, who may or may not Spyware is software that enables
have criminal intentions. advertisers or cybercriminals to
Spyware may be used, for example, to gather information without your
• track the user’s browsing activities permission.
You may get spyware on your
• log, using a keylogger, what is entered through the computer’s
computer when you visit certain
keyboard websites. A pop-up message
• obtain passwords using a piece of software called a password sniffer may prompt you to download
• send collected data to a particular email address or server. a software utility that you
Tracking cookies may be used to store information about the user on their “need”, e.g. a disk cleaner, or
computer, and to send this information to advertisers or to third parties who software may be downloaded
may or may not have criminal intentions. automatically without your
knowledge. Spyware may also be
Spyware is a threat to a computer user’s privacy but worse, if the spyware has
installed when you click on an
been installed by cybercriminals then the computer’s security may be breached. email link.
Sensitive information such as bank login details may be stolen and used to Spyware programs are not
obtain money illegally from the computer user’s bank account or used by a viruses. Cybercriminals often
command and control server (C2) to take over the computer for the purposes use a Trojan horse to install
of sending spam mail or engaging in a distributed denial of service attack. spyware.
Figure [Link] shows an example in which spyware in the form of a keylogger
is downloaded when an unsuspecting user clicks on the email link.
The user is taken to the bank’s site Bank of Umo but only after a keylogger and trojan malware have been
downloaded to the user’s computer. Closer inspection of the web link reveals that the domain name used is
[Link] and not the genuine domain name [Link]. The trojan software periodically or under
command from a command and control server sends a log of keystrokes to the cybercriminal.
Cybercriminal goes to jail for
a very long time

From accounts@[Link] 6 Figure [Link] Download


To gullible@[Link]
Dear Customer of keylogger together with
You are due a refund of £100. 4 Trojan malware to send log to
To transfer this to your account click on
Keylogger records 40 years in some
the following link
victim’s activities, i.e.
cybercriminal
[Link] countries
every key press
Yours Victim 2
Art Dodger Clicking link [Link]
Senior Accounts Manager contacts server

Email to
1 victim

Keylogger and
Trojan software Crime as a Service (CaaS)
then downloaded
5
Trojan periodically sends
3
keylog to
cybercriminal.
Keylog contains, for example,
credit card details Malware server
Cybercriminal
Bitcoin payment via Tor for the use Malware Incorporated Sales Catalogue
of malware service 1. Zeus - our very popular combined
keylogger and trojan
2. Geinimi - our popular Android trojan
3. Etc......
6 Fundamentals of cyber security

Spyware may be removed or prevented from infecting your computer with antispyware software, e.g. Spybot from
[Link] is one of several free antimalware and antispyware tool. Many antiviruses also include a
antispyware tool.
If the spyware is delivered via a Trojan then the measures taken against Trojans also apply to spyware.

7 Which of the following statements are true.


Spyware is a kind of virus.
Spyware is not a threat to a computer user’s privacy.
Spyware may obtain passwords using a piece of software called a password sniffer
Spyware is software that enables advertisers or cybercriminals to gather information without your
permission.
Spyware may take the form of a keylogger.

2 Write an article for a student magazine on malware and the different types of malware: computer viruses,
Trojans, and spyware. Your article should describe the similarities and differences between each and the
measures that can be taken to reduce the risks posed by each of these.

In this chapter you have covered:


■ The term ‘malware’
■ Describing what malware is and how it can be protected against
■ The following forms of malware:
• computer virus
• Trojan
• spyware.
6 Fundamentals of cyber security
6 Fundamentals of cyber security
Learning objectives:
■ Understand and be able to
explain the following security
■ 6.3 Methods to detect and prevent cyber security threats
measures: Biometric measures
• biometric measures Biometric authentication uses your body as your “password”.
(particularly for mobile Instead of the “password” being something that you know, it is something
devices) physical and unique that you possess such as
• password systems • fingerprint pattern
• CAPTCHA (or similar) • iris pattern
• using email • retina pattern
confirmations to confirm • facial features
a user’s identity • voice pattern
• automatic software • vein pattern of palm of hand.
updates. The following technologies have been developed which exploit the above to
uniquely identify a user:
Key term • fingerprint scanner
Authentication:
• iris scanner
The process or action of
verifying the identity of a user • retina scanner
or process. • facial recognition
• voice recognition
Did you know? • vein recognition.
The structure of vein patterns is Biometrics, however, are not fail-safe. For example, both fingerprint scanning
unique amongst each and every and facial recognition systems have been fooled already.
individual. Scientific studies Unfortunately, the consequences are more severe if a biometric system has been
have shown that identical twins
cracked because users can’t change their fingerprint or facial features as they can
possess unique vein patterns as
well.
a stolen password.
It is also very difficult to spoof a However, biometric authentication is still currently more secure than weak
Vein Pattern Recognition device passwords.
because a constant flow of blood Experts advise that the best approach is to use a combination of biometric
is required in the veins for the
technology and other security measures, such as a strong password (the first
raw images to be captured.
However, vein pattern can factor) in a two-factor authentication process which uses a PIN as the second
change over the lifetime of an factor.
individual and therefore, re- Mobile devices are so numerous today that much attention is now devoted to
registration will be needed.
securing them especially from hackers and the consequences of a device being
lost or stolen. This is especially important given the rise of mobile phone apps
Information
such as Apple Pay, Android Pay, and Samsung Pay, that can make payments.
Biometrics:
The term biometrics is derived
Apple Pay, for example, uses fingerprint scanning to verify the identity of the
from the Greek bio (life) and user before allowing a transaction to proceed via the user’s mobile phone.
metric (measure).
6 Fundamentals of cyber security

Questions
1 State two biometric measures that could be used to verify the identity of a user of a mobile phone system.

Password systems
Passwords have already been covered in some depth in Chapter 6.2 (page 293).
There are systems called password managers that manage passwords for users and ease the task of following these
guidelines for passwords:
• passwords should be strong and unguessable
• a different password should be used for each system.
A typical password manager remembers your credentials (login name and password) and then offers to fill in these
for you when logging in again to the corresponding online account or system, e.g. a website or an application.
It therefore eases the burden of having to remember a different password for each system that you log into.
It may also include a password generator which can generate securely-long and random passwords for you.
Another way to ease the burden of remembering lots of passwords is to rely on a single password for all the online
accounts or systems that you need to login to.
For example many systems allow you to use your Facebook or Google login credentials but now you are relying on
your Facebook or Google account credentials remaining secure. If these credentials are hacked then all your sites
where you have used your Facebook or Google credentials will also become insecure.
Also, linking two or more sites allows companies to collect more data, and more information about you which
becomes a possible privacy issue for you. Some commentators advise caution because they say the main focus of a
social network company is making a profit from your information, not protecting your privacy.
There’s also a possibility that less scrupulous sites may do something else with your data that you didn’t agree to,
e.g. selling it on to another company that you would not wish to have access to any aspect of your online identity.
Before using your existing social account to sign in to a third-party site, make sure you can trust the third party.

Questions
2 Which of the following statements are true of a typical password manager?
It remembers your credentials for each password-protected system that you log into.
It forces you to use the same password for all the systems that you log into.
It eliminates the need to use a password at all.
It offers to fill in your credentials for you when logging in again.
A typical password manager may include a password generator.

3 It is possible to rely on your Facebook or Google credentials as log in credentials for other websites.
State one advantage and one disadvantage of doing this.
6.3 Methods to detect and prevent cyber security threats

CAPTCHA Key term


The term CAPTCHA (Completely Automated Public Turing Test To Tell CAPTCHA:
Computers and Humans Apart) was coined in 2000 by Luis von Ahn1 and A CAPTCHA is a program
which attempts to determine
others at Carnegie Mellon University for a technique that attempts to protect
if a test, set by the program,
websites against Internet bots (or just bots). is answered by a human or
A bot is a software application that runs automated tasks over the Internet, another computer program.
e.g. a bot that distorts the outcome of an online poll by voting automatically In its original form, the test
thousands or more times. required several randomly
selected and distorted
Luis von Ahn and his fellow workers created an anti-bot program called a
characters, generated by the
CAPTCHA which determined if a test, set by the program, is answered by a program, to be deciphered and
human or another computer program (a bot). entered correctly. For success
Their CAPTCHA program generated an image comprised of several randomly it relied on the fact that, at the
selected and distorted characters as shown in Figure 6.3.1. time, computers/computer
programs could not process
distorted images and text as well
as humans could.

Did you know?


Several years after introducing
the world to CAPTCHA
technology, von Ahn realized
that, despite taking just a few
Figure 6.3.1 Example CAPTCHA test
seconds to type a CAPTCHA,
In order to gain access to a CAPTCHA protected site, users must prove that humans were spending
hundreds of thousands of hours
they are human and not a computer by correctly deciphering and retyping
each day typing in more than
the characters. 100 million CAPTCHAs.
At the time that CAPTCHAs were introduced, computers could not process CAPTCHAs were re-purposed
distorted images and text as well as humans could. Therefore, CAPTCHAs as reCAPTCHA technology to
use this time to decipher words
immediately proved effective at frustrating most automated attacks.
tagged as unreadable in the
Eventually, though, hackers and spammers figured out ways to outsmart the digitizing of books and other
technology by creating programs capable of reading and cracking CAPTCHAs. printed material.
To counter this, the CAPTCHA technique was beefed up with monitoring In just the first year after
launching reCAPTCHA,
software which analyses the user’s entire engagement with the CAPTCHA - IP
humans correctly deciphered
address, mouse movement, etc... - to differentiate between a human user and and transcribed more than 440
an abusive bot. This form of CAPTCHA has been renamed No-CAPTCHA. million words, roughly the
equivalent of 17,600 books.
Users now see a check box that humans just check and in most cases, they pass
the test - Figure 6.3.2.
Information
Spammer:
A person or organization that
sends irrelevant or unsolicited
messages over the Internet,
typically to large numbers
Figure 6.3.2 Example No-CAPTCHA of users, for the purposes of
advertising, phishing, spreading
malware, etc.
1 Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford
6 Fundamentals of cyber security

If the user engagement check can’t confidently predict whether a user is a


human or an abusive bot, it will prompt a more challenging CAPTCHA
such as a test that shows the user a picture of a cat and asks for similar
photos to be selected from a grid of photos as shown in Figure 6.3.3.

CAPTCHAs
Protect against spam and abuse
Abusing online polls: If the result of an online poll is to be trusted
then it must ensure that only humans can vote. CAPTCHAs force
auto-polling hackers to type in CAPTCHAs by hand and thereby
reduce the hackers’ attempts to manipulate poll results.
Abusing free email services: companies such as Yahoo offer free email
services. CAPTCHAs are used to prevent a bot attack that signs up
for thousands of email accounts every minute.
Spam: CAPTCHAs are used against email spam: “I will only accept
an email if I know there is a human behind the other computer.”

Figure 6.3.3 Example picture test


CAPTCHA

Questions

4 Which of the following statements are true of the latest form of CAPTCHAs?
A CAPTCHA can help to prevent tickets for a sporting event being bought thousands of time by a
bot created for this purpose by ticket touts.
A CAPTCHA can be used by a user as a direct replacement for a login password.
CAPTCHAs can be used to detect viruses in downloaded files.
CAPTCHAs can help to reduce the effects of automated voting in an online poll.
A form of CAPTCHA can help to decipher words tagged as unreadable in the digitizing of books.

5 Many people post comments on blog websites in response to the websites’ blog articles. Such articles can
also attract bot-posted comments which advertise products. State one technique that could be used to
thwart such bots and explain what it relies on to be successful.
6.3 Methods to detect and prevent cyber security threats

Using email confirmation to confirm a user’s identity Key term


Verifying identity is very important. For example, an account holder or user Verification:
of an online account who cannot gain access to this account because they have The process of establishing the
truth, accuracy or validity of
forgotten their access password should be able to verify their identity to the
something.
system by some other means and then once verified be allowed to reset their
password.
One such method uses
the account holder’s email
address to confirm their
identity. This email address
would have been supplied at
the time that the account was
set up.
The account holder clicks on
a Forgot password link on the
login page. The hyperlink
takes the account holder to Figure 6.3.4 Forgot your password?
a page where they can enter their email address You have requested to change your password - Inbox
- Figure 6.3.4. The entered email address is
someaccount@[Link] 11th July 2017 at 13.51 C
checked against the email address recorded To: Fred Bloggs
You have requested to change your password
against this account. If matched then an email
Fred Bloggs, to reset your password, please visit
addressed to the account holder is sent which
[Link]
contains a password reset link - Figure 6.3.5.
An expiry date/time is usually applied to the
password reset link so that it cannot be used
after a certain time period. Other restrictions are
also applied to this link such as
• it may only be used once Figure 6.3.5 Email with password reset link
• it can no longer be used if superseded by a new link.
Information
When a new user fills out an online registration form to apply to register an
account, an email is often sent to the new user’s supplied email address. This A spambot is a computer
email can contain a link that the new user is required to click to complete program designed to assist in
the sending of spam. Spambots
registration and activate their account. Alternatively, it may contain a registration
usually create accounts and send
code that the user is then required to type into the registration page to confirm spam messages with them.
their identity. If this checks out then the user’s account is activated.
Requiring a user to click a confirmation link in their email reduces the likelihood of spambots registering an
account.

Questions
6 Explain how email may be used to confirm an account holder’s identity when the account holder makes a
request to reset their password.
6 Fundamentals of cyber security

Automatic software updates


Unpatched and/or outdated software is vulnerable to being exploited by malicious persons as described in detail in
Chapter 6.2 (page 298).
It is therefore important to check for software updates regularly and automatically so that vulnerabilities may be
fixed as soon as patches or updates become available. You should select the install updates automatically option
and not choose to install updates manually. It is very easy to forget to install updates or to delay applying updates
leaving the system vulnerable.
In this chapter you have covered:
■ The following security measures:
• biometric measures (particularly for mobile devices)
• password systems
• CAPTCHA (or similar)
• using email confirmations to confirm a user’s identity
• automatic software updates.
7 Relational databases and structured query language (SQL)
7 Relational databases
and structured query language (SQL)

Learning objectives:
■ Explain the concept of a 7.1 Relational databases
database
What is a database?
■ Explain the concept of a
In the early days of computerised data processing, a company's data was
relational database
■ Understand the following
duplicated in separate files for the use of individual departments.
database concepts: For example, the personnel department (now often called human resources)
• table would hold details on name, address, qualifications, etc of each employee,
• record while the payroll department would hold details of name, address and salary of
• field each employee. Each department had its own set of programs (applications) to
• primary key process the data in these files. This led to
• foreign key • duplicated data, meaning wasted space
■ Understand that the use • inconsistency problems, where, for example, an address was updated on
of a relational database one file but not on another
facilitates the elimination of • the data was not shareable: if one department needed data that was held
data inconsistency and data
by another, it was awkward to obtain it.
redundancy.
In an attempt to solve the above problems, the data from the various
Key concept departments was centralised in a common pool so that all applications had
Database: access to the same set of data. For example, all the details of stock held by a
A database is a collection
builders merchant would be held in a database which was accessible by all
of non-redundant, logically
related data, and a description
applications using the data. The sales system would update quantities in stock,
of this data, shareable between the marketing department would use the data to produce a catalogue, the
different application systems. reorder system would use it to decide what stock to reorder.
A database, therefore, is defined as a collection of non-redundant data
shareable between different application systems.
What is a relational database?
Non-redundant means no
unnecessary duplication In a relational database, the data is held as a collection of tables. Figure
7.1.1 shows a snapshot of some data stored in two tables within a hospital
Field name/attribute (name)
relational database. Other tables within this database are not shown.

PatientNo Forename Surname Gender DateOfBirth


Record
1456 Fred Smith M 1/3/1970
1461 Mary Berry F 18/5/1965
1468 Abdul Ali M 11/10/1981
Table
1472 Sui Wang F 27/11/1999

Field value or datum WardId WardName WardType NoOfBeds


Figure 7.1.1 Collection of tables - Patient table 1 Nightingale Orthopaedic 30
and Ward table - which belong to the hospital 2 Barnard Cardiac 25
relational database 3 Seacole Medical 35
4 Guttman Geriatric 30
7 Relational databases and structured query language (SQL)
Key concept
• The two tables in the hospital relational database are named Patient and Ward, Relational database:
respectively A relational database is a
• Each table consists of a number of rows collection of tables.
• Each row is called a record
• Each record has a number of fields and each field has a field Key concept
value, e.g. 'Nightingale' Record:
• Each column of a table has a name, e.g. PatientNo, which is A record is composed of related pieces of
called a field name or attribute/attribute name or just field. information divided into named fields, e.g. all
For example, in the table Patient, there is a record with the value the information that a school holds about a
particular student.
'Nightingale' for field WardType.
Questions
1 What is PatientNo PatientName WardName WardType
a database? 1456 Smith Nightingale Orthopaedic
a relational database? 1461 Berry Barnard Cardiac
1468 Ali Barnard Cardiac
2 For the table Patient, Figure 7.1.1,
1472 Wang Guttman Geriatric
give one example of
1478 Banderjee Barnard Cardiac
a field name
1483 Noggs Nightingale Orthopaedic
a field value in the second record.
1497 Fadhil Nightingale Orthopaedic
3 (a) Table 7.1.1 records patient information, Table 7.1.1 PatientWard table
patient no, patient name, which ward they are in and the ward type.
In what way does this table contain redundant (unnecessary duplication) data?
Split this table into two separate tables, ensuring that each new table contains no redundant data (it
may still contain some duplication) while preserving the link between patient and the ward that the
patient is assigned to.
Do any of your new tables contain duplication and if so, is it necessary duplication?

Modelling a relationship between two tables


The relationship between patient and ward is modelled in a relational database by shared or common fields/
attributes. Figure 7.1.2 shows how this is done using field/attribute WardId.
Although the tables Patient and Ward contain multiple records for patient and ward, it is a convention to use the
singular form to name the respective table.
The tables, in fact, record information about the entities WardId WardName WardType NoOfBeds
patient and ward. 1 Nightingale Orthopaedic 30
An entity is an object, person, place, relationship, 2 Barnard Cardiac 25
concept, activity, event or thing of interest to an 3 Seacole Medical 35
organisation and about which data is recorded. 4 Guttman Geriatric 30

PatientNo Forename Surname Gender DateOfBirth WardId


Key concept
Modelling relationships:
1456 Fred Smith M 1/3/1970 3
Relationships in a relational
1461 Mary Berry F 18/5/1965 1 database are modelled by
1468 Abdul Ali M 11/10/1981 3 shared or common fields.
1472 Sui Wang F 27/11/1999 1
Figure 7.1.2 Tables Patient and Ward linked by a common field WardId
7.1 Relational databases

Entity relationship diagram (Beyond 8525 specification)


The relationships between entities are best represented diagrammatically in an entity-relationship diagram or E-R
diagram. Figure 7.1.3 shows the E-R diagram for the two tables Ward and Patient.
A ward is occupied by many patients (zero or more) and a patient is present in one ward at a time (at most one).
We say the relationship between the ward and patient entities is a one-to-many, symbol
A relationship is represented by a line drawn between two associated entities with a shape resembling a crow's foot
drawn at the many end of the relationship as shown in Figure 7.1.3.
E-R diagraming is beyond
AQA's 8525 specification
Ward Patient but useful to know.

Figure 7.1.3 E-R diagram for the tables Patient and Ward

A relationship has a degree which may be one of


One-to-one
the following: 1:1
• one-to-one One-to-many
• one-to-many 1:n

• many-to-one Many-to-one
n:1
• many-to-many
Many-to-many
Drawn as shown in Figure 7.1.4. n:m

Primary and foreign keys Figure 7.1.4 Diagrammatic representations of


Primary key relationship degrees
A primary key is a field or minimum combination of fields
which is unique for each record in a table. StudentId ExamCode Grade Date
For example, WardId in the Ward table. A value for WardId of, 1 Phys1 A June 2019
say, 2, identitifies one and only one record in the Ward table, 1 Chem1 C June 2019
1 Maths1 B June 2019
i.e. 2 . Barnard Cardiac 25
2 English1 D June 2019
The primary key for the ExamResult table shown in Table 7.1.2
2 French1 B June 2019
is a composite primary key, StudentId, ExamCode. Neither 2 German1 C June 2019
StudentId nor ExamCode alone is sufficient to guarantee 2 Maths1 B June 2019
uniqueness. 3 Sociology3 E June 2019
For example, StudentId value 1 identifies three records. 3 Business2 A June 2019
ExamCode might seem promising as a primary key at first 3 Maths1 C June 2019
sight: Phys1 and Chem1 are unique in the table, but Maths1 is Table 7.1.2 ExamResult table
definitely not as it identifies three records.
Foreign key
Key concept
key:
A foreign key is a field/attribute in one table that is also the Attribute/field or combination of attributes/fields
which uniquely identifies a single record in the
primary key of another table. It forms a link between the two
table.
tables via this shared or common field/attribute. Composite primary key:
Minimal combination of fields that uniquely
For example, WardId has the role of primary key in the Ward identifies a single record of the table.
table and foreign key in the Patient table shown in Figure 7.1.2.
Thus, in a relational database, relationships are modelled by the foreign key mechanism.
7 Relational databases and structured query language (SQL)

Shorthand way of representing the structure of a table


Key concept
It is rather cumbersome to show the structure of a table by drawing it Foreign key:
as shown in Table 7.1.2 so a shorter representation is often used which A foreign key is an attribute/field in
omits the data/records. The shorthand representation of a table is called a one table which is also the primary
relation. key of another table. It forms a link
between two tables via this attribute.
For example, the Ward and Patient tables shown in Figure 7.1.2 can be
represented as follows
Primary key
Ward (WardId, WardName, WardType, NoOfBeds) Foreign key
Patient (PatientNo, Forename, Surname, Gender, DateOfBirth, WardId)
Primary key

The primary key of each table is indicated by using an underline. The foreign key is indicated by italicising the field
representing the foreign key.

Questions
4 The fields for each table shown in the E-R diagram
in Figure 7.1.5 are as follows Customer AuctionItem
Customer table: CustomerId, Name, Address
AuctionItem table: ItemId, AuctionPrice, PaidYN, CustomerId Figure 7.1.5 E-R diagram for the
tables Customer and AuctionItem
CustomerId alone is unique in the Customer table and
ItemId alone is unique in the AuctionItem table.
(a) Name a primary key for each table
(b)(i) Which table contains a foreign key? (ii) Name this foreign key.

5 Each GP (General Practitioner) is registered with one GP whereas a GP has many registered patients. This
relationship is shown in the E-R diagram in
Figure 7.1.6. Figure 7.1.7 shows the GP Patient
corresponding tables before the foreign key,
modelling the relationship between the Figure 7.1.6 E-R diagram for the tables GP and Patient
two tables, is added to one of the tables.
(a) State the primary key for each table. GPId GPSurname GPForename Gender
(b) 1 Bloggs Arthur M
(i) Name the field to use as a foreign key 2 Patel Sami F
(ii) Name the table it should be added to. 3 Amari Sarab M
4 Oni Ayomide F
6 Represent in the shorthand
way described above, the tables shown PatientNo Forename Surname Gender DateOfBirth
in Figure 7.1.7 without and then with 1456 Fred Smith M 1/3/1970
1461 Mary Berry F 18/5/1965
the foreign key added.
1468 Abdul Ali M 11/10/1981
1472 Sui Wang F 27/11/1999
Figure 7.1.7 Tables GP and Patient with the foreign key not yet added
7.1 Relational databases

Link tables Studies


A student is associated with zero or more subjects and Student Subject
a subject is associated with zero or more students. The StudiedBy
table Studies shown as an entity in the E-R diagram in
Figure 7.1.8 provides the link that is needed between Studies

the tables Student and Subject.


Figure 7.1.8 E-R diagram showing the relationships
We ignore the many-to-many relationship when
between the three entities Student, Subject and Studies
designing the corresponding relational database and
just model the one-to-many relationships as shown in Figure 7.1.9.

Student Studies Subject

Figure 7.1.9 E-R diagram showing the one-to-many relationship


between Student and Studies and between Subject and Studies

Based on Figure 7.1.9 the relational database thus consists of three tables described in shorthand form as
Subject (SubjectId, SubjectName)
TableName Primary Key
Student (StudentId, Forename, Surname, Gender, DateOfBirth, Address) Student StudentId
Studies(StudentId, SubjectId) Subject SubjectId
Studies StudentId, SubjectId
The primary key for each table is shown in Table 7.1.3. Both StudentId
and SubjectId in table Studies are foreign keys as well. Table 7.1.3 Primary key for each table

7 A competition is made up of many events. Each event involves many teams and a team participates in
many events. The entity-relationship diagram for this competition is shown in Figure 7.1.10.
The tables for Event and Team are described
ParticipatesIn
in shorthand form as follows
Event Team
Event(EventId, EventDescription, Date, Time) Involves
Team(TeamId, TeamName, ContactTelNo) Figure 7.1.10 E-R diagram showing the
relationships between two entities Event and Team
(a) Modify this entity-relationship diagram so that
it uses a link entity and only one-to-many relationships.
(b) State in shorthand form the table for the link entity.
7 Relational databases and structured query language (SQL)

Types of database
The two types of database considered by AQA's syllabus are
• Flat file databases - where data is stored in a single table
• Relational databases - where data is stored in multiple linked tables.
These are not the only types of database in use today.
Table 7.1.4 shows a single table database CourseData which if stored in a disk file would be classified as a flat file
database. It is considered flat because it lacks structure other than being a collection of records made up of fields.
The equivalent relational database is shown as an E-R diagram in Figure 7.1.11 and in shorthand form in Figure 7.1.12.

StudentId StudentName Gender CourseCode CourseTitleTeacherId TeacherName


15898 Bond M AQA0643 A Level CS 1234 Mead
15898 Bond M UCL0675 A Level Maths 5678 Davies
15898 Bond M EDE0187 A Level Art 9123 Milsom
24298 Smith F UCL0675 A Level Maths 5678 Davies
24298 Smith F AQA0643 A Level CS 1234 Mead
24298 Smith F AQA0432 A Level ICT 1234 Mead
10598 Robert M EDE0187 A Level Art 9123 Milsom
10598 Robert M UOC0987 A Level French 4567 Crapper
10598 Robert M AQA0432 A Level ICT 1234 Mead
13497 Nixon F UOC0987 A Level French 4567 Crapper
Table 7.1.4 Single table database CourseData

Student StudentCourse Course

Figure 7.1.11 E-R diagram relational database CourseData

Course(CourseCode, CourseTitle, TeacherId)


Teacher(TeacherId, TeacherName)
Teacher
StudentCourse(StudentId, CourseCode)
Student(StudentId, StudentName, Gender)

Figure 7.1.12 Relational database CourseData tables in shorthand form


The advantage of keeping all the information in one table (flat file), is that it is easier to set up. The disadvantages
are that it is harder to manage and takes up more space because the same data is included multiple times, e.g.
CourseTitle data in Table 7.1.4 is stored unnecessarily several times. This can lead to inconsistencies in the data.
For example, if the single table is edited because the course title changes from A Level ICT to A Level IT, it is
possible that the second instance is not changed through oversight. AQA0432 might now correspond to A Level IT
in one record and still be A Level ICT in another. This is an inconsistency.
A relational database stores related information in separate tables - Figure 7.1.13. This means that individual pieces
of information such as "course code has a given course title" is stored just once. There is now only one place where
course title A Level ICT is stored, i.e. in the Course table. Any duplication which occurs is necessary and occurs
where two tables need to be linked via a foreign key, e.g. TeacherId in Course table where teacher Mead teaches
7.1 Relational databases

both A Level CS and A Level ICT. Duplication which is necessary, as in the case of foreign key TeacherId in
Course table shown in Figure 7.1.13, is non-redundant duplication.
Duplication which is unnecessary, such as CourseTitle data in the single table (flat file) shown in Table 7.1.4, is
called redundant duplication.

CourseCode CourseTitle TeacherId StudentId StudentName Gender


AQA0643 A Level CS 1234 10598 Robert M
UCL0675 A Level Maths 5678 13497 Nixon F
EDE0187 A Level Art 9123 15898 Bond M
AQA0432 A Level ICT 1234 24298 Smith F
UOC0987 A Level French 4567 Student table

Course table StudentId CourseCode


Necessary
15898 AQA0643
duplication
TeacherId TeacherName 15898 UCL0675
1234 Mead 15898 EDE0187
4567 Crapper 24298 UCL0675
5678 Davies Teacher table 24298 AQA0643
9123 Milsom 24298 AQA0432
10598 EDE0187
Figure 7.1.13 Relational database CourseData 10598 UOC0987
10598 AQA0432
13497 UOC0987
StudentCourse table

Questions
8 What is a flat file database?

9 How does a relational database differ from a flat file database?

10 Explain what is meant by


data inconsistency
data redundancy

11 Explain how the use of a relational database facilititates the elimination of


data inconsistency
data redundancy

Inthis chapter you have covered:


■ The concept of a database
■ The concept of a relational database
■ The following database concepts:
• table
• record
• field
• primary key
• foreign key
■ Understanding that the use of a relational database facilitates the elimination of data inconsistency and data
redundancy.
7 Relational databases and structured query language (SQL)
7 Relational databases
and structured query language (SQL)

Learning objectives:
■ Be able to use SQL to retrieve 7.2 Structured Query Language
data from a relational Querying a database
database, using the commands The main purpose of storing data in a database is to enable applications to
• SELECT interrogate the database for information. This interrogation is called querying
• FROM the database.

• WHERE Structured Query Language (SQL)


• ORDER BY...ASC | Structured Query Language (SQL) can be used to query a database. It is a
DESC simplified programming language.
■ Be able to use SQL to insert
Retrieving data from a single table
data into a relational database
using the command: Table 7.2.1 shows data for the Student table with structure
Student (StudentId, StudentName, Gender)
INSERT INTO table_name The following query, expressed in SQL, will retrieve all of the data in the
(column1, column2, ...)
Student table
VALUES (value1, value2, ...)
■ Be able to use SQL to edit SELECT *

and delete data in a relational FROM Student;


database using the commands: The wildcard character * matches the attribute/field list
StudentId, StudentName, Gender
UPDATE table_name
SET column1 = value1,
StudentId StudentName Gender
column2 = value2, ...
WHERE condition
1 Ames M
2 Baloch F
DELETE FROM table_name 3 Cheng F
WHERE condition. 4 Dodds M
5 Groos M
6 Smith F
Table 7.2.1 Table Student

The ANSI/ISO SQL standard requires that a semicolon is used at the end of
the SQL statement but some systems relax this requirement. When writing
SQL the convention is to use upper case for the SQL commands.
If we wanted just the data for StudentName we would refine the query as
follows
SELECT StudentName
FROM Student;
7 Relational databases and structured query language (SQL)

We could refine the search even further by adding a WHERE clause that applies a search condition as follows
SELECT StudentName
FROM Student
WHERE Gender = 'F';
The result set that would be returned when this query is applied to table Student would be as follows
Baloch
Cheng
Smith
because only these rows of the table match the search condition Gender = 'F'.
Gender = 'F' is actually called a predicate because it evaluates to either TRUE or FALSE.

If we also wanted the values of StudentId returned then the query would be
SELECT StudentId, StudentName
FROM Student
WHERE Gender = 'F';

Questions
1 Write an SQL query that returns the names of all students in Table 7.2.1 who are male.

Retrieving data from multiple tables


Table 7.2.2 shows data in table form for the Ward table with WardName NurseInCharge NoOfBeds
structure Victoria Sister Bunn 30

Ward (WardName, NurseInCharge, NoOfBeds) Aylesbury Sister Moon 40


Table 7.2.2 Table Ward
Table 7.2.3 shows data in table form for the Patient table with
structure PatientId Surname WardName
Patient (PatientId, Surname, WardName) 1 Bond Aylesbury
2 Smith Victoria
The two tables are linked via a shared or common attribute
3 Jones Aylesbury
WardName. The existence of an attribute common to both tables is 4 Biggs Victoria
not enough to join data from the corresponding tables correctly, as
Table 7.2.3 Table Patient
the following SQL query demonstrates
Victoria Sister Bunn 1
SELECT [Link], [Link],
Victoria Sister Bunn 2
[Link]
Victoria Sister Bunn 3
FROM Ward, Patient;
Victoria Sister Bunn 4
The part of the query [Link] references the WardName
Aylesbury Sister Moon 1
attribute in table Ward and the part [Link] references
Aylesbury Sister Moon 2
PatientId attribute in table Patient.
Aylesbury Sister Moon 3
The FROM Ward, Patient part joins both relations without regard Aylesbury Sister Moon 4
for the way that the data is actually linked via matching values of the
shared attribute, WardName. The result set returned by the query is Table 7.2.4 Result set ignoring
shown in Table 7.2.4. relationship between Ward and Patient
7.2 Structured Query Language

When the search condition


WHERE [Link] = [Link]

is added to the SQL query, we are able to exclude values that are not linked by the attribute WardName and to
include only those that are. This SQL query will return the result set that
corresponds to the real world situation shown in Table 7.2.5. Aylesbury Sister Moon 1
Victoria Sister Bunn 2
SELECT [Link], [Link], [Link]
Aylesbury Sister Moon 3
FROM Ward, Patient Victoria Sister Bunn 4
WHERE [Link] = [Link];
Table 7.2.5 Result set taking
The two relations have been joined on their common attribute, WardName, i.e.
account of relationship between
where the value of WardName is the same in both tables. Ward and Patient
Writing the query as follows would return the same result set because dropping
the table name prefix before NurseInCharge and PatientId in the SELECT part of the SQL query is allowed where
there is no ambiguity as to what is intended.
SELECT [Link] , NurseInCharge, PatientId
FROM Ward, Patient
WHERE [Link] = [Link];

Questions
2 Write the SQL query that returns from Tables 7.2.2 and 7.2.3 the name of the nurse in charge of the ward,
surnames of all patients in this ward and the ward name.

Ordering the result set returned by a query


We can order a result set returned by a query in ascending or descending order with the keyword ORDER BY
qualified by one of the keywords ASC or DESC. If the qualifier is omitted then ASC is assumed. For example, we
can place the result set returned in ascending SELECT [Link], NurseInCharge, PatientId
order on WardName by the query opposite. FROM Ward, Patient
Table 7.2.6 shows the outcome of applying this WHERE [Link] = [Link]
query to the Ward and Patient tables. ORDER BY [Link] ASC;

Questions Sister Moon 1


Sister Moon 3
3 Write the SQL query that returns the names of both nurses and their Victoria Bunn 2
patients, from Tables 7.2.2 and 7.2.3, ordered in descending patient Victoria Bunn 4
name order. Table 7.2.6 Result set ordered
on WardName in ascending
alphabetic order
7 Relational databases and structured query language (SQL)

Relational or comparison operators for Comparison


search condition Description
Operator
Table 7.2.7 shows comparison operators that may be used
= Equal to
in SQL queries.
< Less than
Table 7.2.8 shows the outcome of applying this query to > Greater than
the Patient table. <= Less than or equal to
SELECT PatientId, Surname >= Greater than or equal to
FROM Patient <> Not equal to
WHERE PatientId <> 2; Table 7.2.7 Comparison operators for SQL queries

Table Country has the structure 1 Bond


Country (Name, Capital, Population, Area) 3 Jones
4
Table 7.2.9 shows some data for table Country.
Table 7.2.8 Result set for
The result set returned when the following SQL query
PatientId <> 2
SELECT Name, Capital, Population
FROM Country Name Capital Population Area
WHERE (Population < 7000000); Argentina Buenos Aires 32 300 003 2777815
Bolivia La Paz 7 300 000 1098575
is applied to this Country table with attributes Brazil Brasilia 150 400 000 8511196
Name, Capital, Population, Area is shown below Canada Ottawa 26 500 000 9976147
Chile Santiago 13 200 000 756943
El Salvador San Salvador 5300000
Colombia Bagota 33 000 000 1138907
Guyana Georgetown 800000
Cuba Havana 10 600 000 114524
Ecuador Quito 10 600 000 455502
El Salvador San Salvador 5 300 000 20865
Guyana Georgetown 800 000 214969
Table 7.2.9 Table Country showing some values

Questions
45 Write the SQL query that returns the patient surnames from Table 7.2.3, for which the patient identifier is
less than or equal to 3. Order the result set in descending order of patient identifier (PatientId is the patient
identifier).

5 What result set is returned when this SQL query is applied to the data in Table 7.2.9?
SELECT Capital, Population, Area
FROM Country
WHERE (Population > 32000000);
7.2 Structured Query Language

Deleting data in a single table


The DELETE statement is used to delete rows of a table.
DELETE FROM table_name
WHERE some_column = some_value;

The WHERE clause specifies which row or rows should be deleted. If the WHERE clause is omitted, all rows will
be deleted!
For example referencing Table 7.2.9,
DELETE FROM Country
WHERE Capital = 'Brasilia';
deletes the row Brazil, Brasilia, 150400000, 8511196.

Questions
6 Write the SQL statement to delete the row with BorrowerId 3 in BorrowerId Surname Initial
1 Smith K
the Borrower table shown in Table 7.2.10.
2 Barnes W
3 Minns M
7 Write the SQL statement to delete the row(s) with
Population > 15000000 in the Country table shown in Table 7.2.9. Table 7.2.10 Table showing some
values for the table Borrower

Inserting data into a single table


The INSERT INTO statement inserts a new row into a table. It is possible to write this statement in two forms.
The first form does not specify the column names where the data will be inserted, only their values:
INSERT INTO table_name
VALUES (value1, value2, value3, ...);

The second form specifies both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

In the first form, a value of the correct data type must be supplied for every attribute of the table and the order of
the supplied values must be the same as the corresponding columns in the table.
In the second form, a value for every specified column must be supplied and each value must match in data type the
corresponding specified column, i.e. value1 corresponds to column1, value2 to column2, etc. The value Null will
be inserted for any columns not referenced.
WardName NurseInCharge NoOfBeds
For example, for table Ward, Table 7.2.2, reproduced here Victoria Sister Bunn 30
First form: Aylesbury Sister Moon 40
INSERT INTO Ward VALUES ('Gresham', 'Mr Oonga', 20); Table 7.2.2 Table Ward
This first form creates a new row in Table 7.2.2 with values
'Gresham', 'Mr Oonga', 20
Second form:
INSERT INTO Ward (WardName, NurseInCharge) VALUES ('Savernake', 'Sister Teng');
This second form creates a new row in Table 7.2.2 with values 'Savernake', 'Sister Teng', Null
7 Relational databases and structured query language (SQL)

Questions

8 Write the SQL statement to add a new row to the Ward table (Table 7.2.2) for ward 'Amersham',
containing 25 beds. The nurse in charge is 'Sister Brody'.

9 Write the SQL statement to add a new row to the Country table (Table 7.2.9) for 'UK', 'London'.

Updating data in a single table


The UPDATE statement is used to update an existing row of a table.
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE some_column = some_value;
For example,
UPDATE Ward
SET NurseInCharge = 'Mr Ali', NoOfBeds = 25
WHERE WardName = 'Victoria';

Questions

10 Write the SQL statement to update the row of the Country table (Table 7.2.9) for 'UK' to add population
64100000, area 243610. Assume that an insert statement has inserted 'UK', 'London' already as in Q9.

SQL Tutorials
SQL tutorials are available at [Link]
It is also possible to explore SQL locally by first installing a database engine and then a tool which supports the
execution of SQL against a database accessed
through the database engine.
SQLite is a self-contained, server-less, zero
configuration, transactional SQL database engine.
The code for SQLite is public domain and is
thus free for use for any purpose, commercial or
private. It can be obtained from
[Link]
An easier route to using SQLite is to download
DB Browser for SQLite from
[Link] This application
takes care of the installation of both the SQLite
database engine and an interface for executing
SQL - see Figure 7.2.1.
Figure 7.2.1 DB Browser for SQLite
7.2 Structured Query Language

After installing DB Browser for SQLite, launch the application. The user interface for DB Browser for SQLite is
shown in Figure 7.2.2.

Figure 7.2.2 DB Browser for SQLite user interface

Download the [Link], [Link], [Link] and [Link] databases from


[Link]/aqacs/[Link]
Open [Link] database using the Open Database button. Figure 7.2.3 shows that the opened database
consists of two tables Patient and Ward.
The data stored in the Ward table is revealed by executing the SQL query
SELECT * FROM Ward;

Executes all the


SQL statements
in the SQL
window
Executes the SQL statement that starts in the current line

Figure 7.2.3 Execute SQL tab


7 Relational databases and structured query language (SQL)

Figure 7.2.4 shows the result of executing the SQL query


SELECT [Link], NurseInCharge, PatientId
FROM Ward, Patient
WHERE [Link] = [Link]
Cursor in this line
ORDER BY [Link] ASC; and execute current
line icon clicked

1 Try all the SQL examples in this chapter in DB


Browser for SQLite.

Figure 7.2.4 Querying Ward and Patient tables


In this chapter you have covered:
■ How to use SQL to retrieve data from a relational database, using the commands
• SELECT
• FROM
• WHERE
• ORDER BY...ASC | DESC
■ Using SQL to insert data into a relational database by using the command

INSERT INTO table_name


(column1, column2, ...)
VALUES (value1, value2, ...)

■ Using SQL to edit and delete data in a relational database by using the commands

UPDATE table_name
SET column1 = value1,
column2 = value2, ...
WHERE condition

DELETE FROM table_name


WHERE condition
8 Ethical, legal and environmental impacts of digital
technology on wider society, including issues of privacy
8 Ethical, legal and environmental impacts of digital technology
on wider society, including issues of privacy


Learning objectives:
■ Explain the current ethical, Ethical impacts of digital technology
legal and environmental What is ethics?
impacts and risks of digital When a person ‘thinks ethically’ they are giving some thought to human action
technology on society. Where that has moral consequences for someone beyond themselves and their own
data privacy issues arise these desires and self-interest.
should be considered. Digital technology has created new possibilities for human action but it has
also raised new ethical questions, i.e. questions requiring new ethics with which
to reason.
Information The European Data Protection Supervisor (EDPS), an independent institution
Hyperscale computing: of the EU, published a report in 2015 entitled
In computing, hyperscale is “Towards a New Digital Ethics”
the ability of an architecture to
([Link]
scale appropriately and quickly
in a cost-effective manner as Documents/Consultation/Opinions/2015/15-09-11_Data_Ethics_EN.pdf)
increased demand is added At its core is the protection of human dignity and the fundamental rights to
to the system. Hyperscale
privacy and to the protection of personal data.
computing is necessary in order
to build a robust and scalable The challenges facing legislators in the digital age
Cloud, and is often associated Laws have not kept pace with the development of digital technologies.
with the infrastructure required There is a general feeling that a person’s privacy has shrunk in the global
to run large distributed sites
information society. There are something like five hundred companies that are
such as Facebook, Google,
Microsoft Azure or Amazon able to track every move you make on the Internet, mining the raw material of
AWS. the Web and selling it to marketers.
“Personal data are purchased, aggregated, analyzed, packaged, and sold by
data brokers who operate, in the US at least, in secrecy – outside of statutory
Key point
consumer protections and without consumers’ knowledge, consent, or rights
Having hyperscale ability
enables many results to be
of privacy and due process” (U.S. Committee on Commerce, Science, and
extracted from individuals’ Transportation, 2013).
personal data that would have The nature of software, data, and information, and the degree and scale of
remained unknown but for control over software available to computer scientists and software engineers
the scaling of the processing it
constrain what the lawyers and legislators can achieve when local laws run up
makes possible, as well as the
support for massive datasets of against the global Internet.
personal information it grants. “In today’s digital environment, adherence to the law is not enough; we have to
The extracted information consider the ethical dimension of data processing.”
can be of benefit to society (Towards a New Digital Ethics)
but it also has the potential
This is the case whether the right under scrutiny is any one of copyright,
for misuse if the processing is
used for social or economic trademark, privacy, or freedom of expression. Can a law made in one country
discrimination, unsolicited be successfully applied to the global Internet whose content, algorithms and
advertising, or reputational access embed value judgments from different cultures, societies and legal
damage.
systems?
8 Ethical, legal and environmental impacts of digital

Information Questions for discussion


The Web means the end of Topic: Practical obscurity
forgetting: 1 Practical obscurity is an important factor in the preservation of
New York Times article by privacy. If the representation of information does not permit it to be
Jeffrey Rosen easily queried, e.g. the information is on paper in a filing cabinet, then
[Link] the extraction of important knowledge (usable information) is made
com/2010/07/25/
more difficult.
magazine/25privacy-t2.
html?pagewanted=all&_r=0
Why does the ability to collect and process data on a mammoth scale
in the way achieved by Google and other companies reduce practical
Key concept obscurity?
Personal data: 2 "The average citizen has participated actively in their own surveillance
Any information related to when engaging with digital services and businesses". Explain why you
a natural person or "Data agree or disagree with this statement.
Subject", that can be used to 3 In respect of the Internet, should the reach of the law for each of
directly or indirectly identify the following apply (i) globally or (ii) locally with each country
the person. deciding what law to apply?
It now includes online
(a) copyright (b) privacy (c) freedom of expression.
identifiers, e.g. IP addresses,
location data, and biometric/
genetic data.
Entity:
The terms of the GDPR apply to
General Data Protection Regulation 2018 anyone processing personal data
The EU’s General Data Protection Regulation (GDPR) took effect on 25 May 2018, and except for individuals processing
personal data for personal or
affects not only EU-based organizations, but also possibly data controllers and processors
household activities. This means
around the world of data of EU data subjects. The UK has passed an Act of Parliament that the GDPR applies to clubs
which implements the GDPR - Data Protection Act 2018. The fines for non-compliance or societies holding the names,
per incident can be substantial (maximum € 20 million or 4% global annual turnover contact details or other personal
information about members.
whichever is higher).
GDPR brings about widespread unification and standardisation of data privacy and
data security requirements across all 28 member states. Its introduction has been prompted by the growth of use of
Big Data, Cloud, and Internet Of Things (IoT) applications.
Before entering a website
The GDPR applies to which gathers data personal
Key concept • Companies or entities with a seat of business or to you, it must obtain your
Data subject: consent to do this, and to
establishment in an EU member state and which
record and process this data.
A living person whose personal process data in the context of their businesses You have the right to opt-out.
data is processed by a controller regardless of where the actual processing takes place.
or processor.
• Companies or entities with no establishment or physical presence in an EU
Data Controller:
member state which offer goods or services to individuals in the EU.
The person/entity who
• Companies or entities with no establishment or physical presence in an EU
determines the purposes,
conditions and means of the
member state which monitor the behaviour of individuals in the EU.
processing of personal data. The GDPR offers an enhanced level of protection for data subjects: Companies and
Data Processor: • The definition of "Personal Data" now explicitly includes entities must
record that they
The entity that processes online identifiers, location data, and biometric/genetic data. have obtained
data on behalf of the Data • Higher standards for privacy notices and for obtaining your consent to
Controller. consent. gathering, recording
and processing your
• Easier access to personal data by data subject.
Key concept • Enhanced right to request the erasure of their personal data.
personal data.

Information:
• Right to object to processing now explicitly includes profiling.
Data is how information is
• Right to transfer personal data to another organisation.
represented.
Ethical impacts of digital technology

Case studies for discussion


1 Consider the case of a large retail chain with establishments in member states of the EU.
The retail chain collects personal data from customers in these member states. They also have an online
website where they sell goods worldwide and they collect personal data in member states, and the US,
Canada and Latin America. They move all their data processing activities to the Cloud. The data is stored
on servers in the US and security for the data is managed from India.
Does the GDPR apply to this retail chain considering that the servers are not in the EU and the services
are not managed in the EU and many data subjects whose data are collected are not in the EU?
The answer is yes because the company has an establishment in the EU and processes personal data. The
main relevant factor is the seat of business. That is all that counts.
2 Where location data other than traffic data, relating to users or subscribers of public communications
networks or publicly available electronic communications services can be processed, such data may only
be processed when they are made anonymous, or with the consent of the users or subscribers to the extent
and for the duration necessary for the provision of a value added service. The service provider must inform
the users or subscribers, prior to obtaining their consent, of the type of location data other than traffic
data which will be processed, of the purposes and duration of the processing and whether the data will be
transmitted to a third party for the purpose of providing the value added service.
3 The GDPR states that the test for whether a person is "identifiable" depends upon "all the means
reasonably likely to be used" to identify that person. This means that IP addresses of visitors to a website
are personal data in certain circumstances.
IP addresses will be personal data in the hands of any party that can lawfully obtain sufficient additional
data to link the information to a person's real world identity. On the other hand, IP addresses will not
be personal data in the hands of a party that has no legal means of obtaining sufficient additional data to
make such a link.

Questions for discussion


4 A company based in California, its only seat of business, operates servers and a subscription service for
online multiuser gaming. It has members from everywhere in the world including the EU.
Does the GDPR apply to this company? Justify your answer.
5 A company based in Nevada, USA, its only seat of business, monitors the online behaviour of individuals
in the EU so that it can create profiles of individuals to sell on to retail companies.
Does the GDPR apply to this company? Justify your answer.
6 Using your mobile phone you access an online game running on a company's servers but have noticed
that wherever you are when playing this game, adverts pop up for retail stores in your current locality.
You believe that this company is using your location data but you did not consent to this specific use of
your location data when you consented for the company to process your personal data. Has this company
broken the GDPR? Justify your answer.
7 Like many website operators, a company records the IP addresses of visitors of its websites.
(a) Will IP addresses qualify as personal data under the GDPR?
(b) If they do qualify then will the company be required to obtain consent in order to process such data
from individuals visiting the company's websites?
8 Ethical, legal and environmental impacts of digital

Geolocation- tracking you and your location


Geolocation is the identification or estimation of the real-world geographic location of an object, such as a mobile
phone, or Internet-connected computer.
Geolocation data collection can be categorised into three types according to how the data is collected:
1. Voluntary geolocation data collection - some people deliberately broadcast their geographic location by
formally tagging their location and "checking in" at various places on social media sites using their GPS-
enabled smartphones or by connecting to a Wi-Fi access point.
2. Necessary geolocation data collection - a mobile phone is constantly reporting its location to the nearest
mobile base station. That is how the mobile phone network knows where the phone is located so that it can
connect a call to the phone. The mobile phone company keeps records of where your mobile has been and
where it is currently.
3. Surreptitious geolocation data collection - this is geolocation tracking without your knowledge or
consent, e.g. StingRay which pretends to be a mobile base station by simulating its signal and thereby
forcing each mobile phone in its area to disconnect from its service provider site (e.g. operated by Vodafone,
EE, etc.) and establish a new connection with StingRay by which the mobile phone numbers and unique
electronic serial identification numbers of each can be read and a target for surveillance identified. StingRay
may then establish a connection with the mobile phone's provider and remain in the middle, listening and
recording calls made from the connected mobile phones.

1 Visit the following site and read about the use of StingRay equipment.
[Link]
2 Visit the following site and view the video on Raytheon's Rapid Information Overlay Technology (RIOT)
which uses only publicly available data from social media sites, Facebook, Instagram, etc to draw a detailed
picture of a person based on where he or she goes: [Link]
Optional: Visit the following site and view the video "Can You Track Me Now?"
3
[Link]
(Warning: This video is 1 hour 39 minutes long)

Society
A society of citizens is a society in which strangers can trust one another since everyone is bound by a common set
of rules.
Trust can grow between strangers, because it does not depend upon family connections, tribal loyalty, or favours
granted or earned.
Citizenship is the relation that arises between the state and the individual when each is fully accountable to the
other:
• It consists of a web of reciprocal rights and duties upheld by a rule of law which stands higher than either party.
• The state enforces the law but it enforces it equally against itself and against the private citizen.
• The citizen has rights which the state is duty-bound to uphold.
• The citizen has duties which the state has a right to enforce e.g. when the state is threatened a citizen may be
conscripted.
Ethical impacts of digital technology

It is generally accepted that we surrender certain freedoms in exchange for security provided by the state.
Citizens are supposed to have a clear conception of where their freedoms end because these rights and duties are
defined and limited by law.
However, laws have not necessarily kept pace with the development of digital technologies whilst at the same time
digital technologies have created new possibilities for human action such as state electronic mass surveillance of its
citizens.
This has led to a general feeling that a person’s privacy has shrunk in the global information society:
1. Citizens normally value their privacy and may not like it when governments or security services have too
much access.
2. However, governments and security services often argue that they cannot keep their citizens safe from
terrorism and other attacks unless they have access to private data.

4 Visit the site [Link] and answer the following questions:


What is Prism?
What is Tempora?
Why might Angry Birds and other mobile applications lead to a leakage of personal information?

Investigatory Powers Act 2016


In the light of concerns expressed by various quarters in society, especially following the Edward Snowden
revelations, the Investigatory Powers Act 2000 was revised and replaced in 2016 by a new Act, the Investigatory
Powers Act 2016. This new Act comprehensively sets out, and in limited respects, expands the electronic
surveillance powers of the UK intelligence community and police whilst also improving the safeguards on the
exercise of these powers.
This Act sets out the extent to which certain investigatory powers may be used to interfere with privacy.
The Act introduced new powers, and restated existing ones, for UK intelligence agencies and law enforcement to
carry out targeted interception of communications, bulk collection of communications data, and bulk interception
of communications.
The Secretary of State may, by retention notice, require a telecommunications operator to retain UK Internet users'
"Internet connection records" for up to one year – which websites were visited, e.g. [Link] but
not the particular pages and not the full browsing history. The retention notice warrant must be approved by a
Judicial Commissioner.
It allows police, intelligence officers and other government department managers to see Internet connection records,
as part of a targeted and filtered investigation, provided that a warrant has been granted for this purpose.
It permits the police and intelligence agencies to carry out targeted equipment interference, that is, hacking into
computers or devices to access their data, and bulk equipment interference for national security matters related to
foreign investigations covered by a warrant. A bulk interception warrant applies to the interception of overseas-
related communications. A bulk acquisition warrant can be issued by the Secretary of State in the interests of
national security or for the purpose of preventing or detecting serious crime.
8 Ethical, legal and environmental impacts of digital

5 Visit the following site and view the video to get an overview of the implications of the Investigatory
Powers Act 2016:
[Link]
What is meant by the double-lock for interception warrants?

Questions
8 The making of the law, as an activity, is itself governed by morality - what is right and what is wrong.
There are three important moral considerations that must be taken into account in every decision the state
makes:
public welfare;
individual rights;
justice between individuals.
This question is about the Investigatory Powers Act.
How does the Act target public welfare?
The Act has the potential to interfere with the privacy of individuals. Explain.
What safeguard(s) does the Act contain to protect the rights of individuals to privacy?

Wi-Fi hotspots
Wi-Fi hotspots can create data privacy issues because they are a means by which communications may be
intercepted and data stolen.
Wi-Fi hotspots are wireless broadband networks which allow access to the Internet in various public spaces such
as cafes, airports and public transport. They enable people to access their email and other network applications
in public spaces. It's faster and more reliable than mobile broadband like 4G and avoids using some of a mobile
phone's data allowance. But public Wi-Fi hotspots are not considered safe. For example, in 2016 a journalist wrote
an article reporting that his email got intercepted by a hacker while using an airplane Wi-Fi - read the following
article at [Link]
For this reason, many people avoid using Wi-Fi hotspots or if they have to, don't communicate anything
confidential such as bank account details or login details. Better still they use a Virtual Private Network (VPN) so
that communications are encrypted or they use a messaging app such as WhatsApp®.
WhatsApp provides end-to-end encryption which means that messages are secure so only you and the person
you're communicating with can read or listen to them, and nobody in between, not even WhatsApp (except for a
security flaw that has been discovered recently - [Link]
End-to-end encryption relies on a temporary session key which is not saved so cannot be handed over to security
services because once used it is destroyed.

6 Read the article which is available on the following site:


[Link]
Give one argument for and one argument against a government being allowed to read end-to-end
encrypted messages (the encryption key used must be saved somewhere if a government is to be able to
decrypt a communication)?
Ethical impacts of digital technology

Wearable technologies
Wearables include anything strapped to or otherwise attached to the human body that
• Collect state, e.g. heart rate
• Communicate information, e.g. heart rate
• Or otherwise performs some type of control function on or around the individual, e.g. warn
wearer heart rate too high.
Figure 8.1 shows an example containing two sensors and one actuator each with a controller and a low energy
Bluetooth wireless interface called BLE.

Wireless
Bluetooth LE (BLE)
Interface Personal
Controller
Bluetooth Smart phone Network
LE (WPAN) Figure 8.1 Wearable
Sensor radio frequency
links embedded system
To mobile
phone
network
Sensor

Actuator
Figure 8.2 Nike+ running watch and App
([Link]/ivyfield/4762376623 CC
BY 2.0)
These connect to a smart phone via Bluetooth forming a
Wireless Personal Network (WPAN).
The smart phone may then connect to the Internet via a
mobile phone network then an Internet gateway in order to
upload the data.
The Apple Watch, FitBit, Nike+ and others are well-known
examples.
Figure 8.2 shows a Nike+ running watch with integrated
sensors and the running app displaying data on an iPhone.
Wearable, networked sensors may detect heart rate,
temperature, inertial acceleration (for example, to evaluate
a runner's stride and tempo), location information (for
calculating speed), and many others.
However, ethical concerns, from privacy to security, arise
with the use of wearables such as who has access to a person's
personal health data if the wearable(s) is used to monitor
a person's health and communicated via a gateway such as
Microsoft's Azure IoT hub? Who owns and controls it? Is it
shared with third parties? Is it sold or loaned for marketing or
advertising purposes?
8 Ethical, legal and environmental impacts of digital

Wearables may also be used by companies to track their employees' movements which again raises ethical concerns
regarding how this information might be used.
One form of wearable, Google glass, prompted various sources to raise issues regarding the intrusion of privacy,
and the etiquette and ethics of using the device in public and recording people without their permission. Google
Glass displayed information in a smartphone-like hands-free format. Wearers communicated with the Internet via
natural language voice commands. However, Google Glass also had a way to record everything going in front of the
wearer. It turned out that very few people were willing to be recorded walking and talking because they considered
it an invasion of their privacy. On January 15, 2015, Google announced that it would stop producing the Google
Glass prototype but in July 2017 it announced that the Google Enterprise Edition would be released for use in the
workplace as an assistive device.

Questions
9 Why might wearing Google Glass in a cinema prompt the management to request that you remove it or
worse, leave the cinema?
10 A healthcare company which charges for its services provides each of its clients with a free wearable fitness
tracker. Fitness data is sent from the clients' mobile phones via the Internet to the company's servers where
the data is analysed.
(a) State one concern that a client might have about how the personal health data obtained from the
fitness tracker will be used by the healthcare company.
(b) State one benefit that a client might receive from using the free wearable fitness tracker.
11 Current health care is doctor-centric. Society may have to get used to relying on a different model of
health care in the future which raises ethical issues of access and privacy concerns regarding individuals'
health data and how it is used.
(a) One such model could involve the use of wearable technology.
Suggest three uses of wearable technology connected to a smart phone that could assist individuals in
monitoring and maintaining their health.
(b) If this model is adopted, why might some individuals not be able to participate in such a programme
of health care and therefore be disadvantaged?
(c) Explain how the data collected by wearable technology could be communicated securely to individuals'
doctors.
(d) Give two reasons for society why in the future, a greater reliance on the use of wearable technology for
healthcare might become necessary.

Internet of Things (IoT)


According to the IEEE1, an Internet of Things (IoT) is a network that Information
connects uniquely identifiable "things" to the Internet. The "things" In 2012, Google filed a patent
application for a device which
have sensing/actuation, potential programmability capabilities, unique
receives the environment sounds
identification, information about the "thing" can be collected and the state of
heard at the same time with a
the "thing" can be changed from anywhere, anytime, by anything." conversation on a computer
The "Things" in IoT are "Smart Things" which consist of microphone or phone so that it
• Sensors (temperature, light, motion, moisture, etc). could identify exactly what the user
was doing and use this to make an
• Displays.
advertisement highly adapted to the
surrounding environment.
1 IEEE - Institution of Electrical and Electronic Engineers
Ethical impacts of digital technology

• Actuators - a component responsible for moving or controlling a Information


mechanism or system, e.g. opening or closing a valve. Radio frequency identification
• Computation (can run programs and logic). (RFID):
• Communication interfaces (wired or wireless). Any method of identifying
and tracking items using
The IoT enables environmental monitoring of temperature, humidity, dew point,
radio waves. Typically a reader
air quality and more. (also called an interrogator)
The Internet of Things raises ethical questions such as "Who is the owner of the communicates with a
data retrieved by the sensors of the objects connected to the Internet of Things?” transponder, which holds digital
It is quite feasible for people to not know where their information ends up. information in a microchip.
Alternatively, a chipless RFID
The movement of individuals may be monitored without them being aware of it.
tag is used which just uses
How many people are aware that RFID tags are embedded in all sorts of objects material to reflect back a
from car tyres to goods purchased in shops? The data registered by the sensors can portion of the radio waves
be sent in great quantities and in different ways through networks. beamed at them. People can be
tracked by the RFID tag they
The information collected from a chip implanted with the person’s consent (for
have in their possession e.g. a
medical purposes) might be used for purposes other than those for which consent bus pass, and those injected or
has been obtained. implanted within human or
Computer based implants animal skin.
Computer based implants include any sensor, controller, or communication
device that is inserted and operated within the human body or an animal's body.
Task
7 Visit the following site to see the world's smallest implantable computer:
[Link]
Give two uses for this computer implanted within the body. Information
Attempts are being made
to control the wild pony
population on Dartmoor
using a medical implant that
Questions is injected under the skin of
female ponies. The implant is
12 Microchips are being developed containing a reservoir of a particular
designed to deliver a measured
drug. These can be implanted under the skin and are designed to dose of a contraceptive.
release 30 micrograms a day of the drug. The dosage may be altered
by remote control, as well. Information
1. Dick Cheney was US
Suggest one benefit and one danger from such a computer based
Secretary of Defense during
implant. Operation Desert Storm, the
1991 invasion of Iraq.
13 Discuss benefits and dangers of using a computer based implant 2. Dick Cheney has been
containing a person's complete medical record.
fitted with a heart pacemaker,
recently.
14 State two applications of computer based implants that have restored
The pacemaker was specially
lost senses in human beings. adapted for Dick Cheney so
that it would be resistant to
hacking and disruption. This
must be very reassuring to the
rest of the population which has
to make do with pacemakers
that are vulnerable to hacking.
8 Ethical, legal and environmental impacts of digital

Issues around copyright of algorithms (not in AQA specification 8525)


The expression of an algorithm in a source code file (i.e. a program) can be
Information
copyrighted but the algorithm itself cannot be in many jurisdictions around the The expression of an algorithm
world because copyright cannot protect a concept, idea or fact. Every day stories in a source code file can be
covering the same news events appear in the nation’s rival newspapers but because copyrighted. However, to
the words used in each case are different, there is no copyright infringement. protect the expression of the
algorithm it should be patented,
Copyright only protects the original expression of an idea while patent protects provided it meets the criteria for
man-made, inventive and novel inventions based on ideas. a patent.

A famous patent is Google's search algorithm. Patent publication number US


6285999 B1 "Method for node ranking in a linked database, inventor Lawrence
Information
Page" was filed on July 6, 2001 by Lawrence Page - see [Link]/patents/ Proprietary software:
US6285999. Only the original authors
Copyright allows the rights holder to prevent unauthorised reproduction of of proprietary software can
legally copy, inspect, and alter
particular pieces of source code that embody an algorithm. However, such rights
that software. In order to use
do not pertain to the algorithm itself and so copyright itself does not prevent proprietary software, computer
others creating other expressions of the same algorithm in some other form, such users must agree (usually by
as a different source code file unless the algorithm is covered by a patent. signing a license displayed
the first time they run this
Most countries place some limits on the patenting of inventions involving software) that they will not do
software, but there is no one legal definition of a software patent. In Europe, anything with the software that
"computer programs as such" are excluded from patentability, but despite this, the software's authors have not
expressly permitted. Microsoft
the United Kingdom Intellectual Property Office (UKIPO) regularly grants
Office and Adobe Photoshop
patents to inventions that are partly or wholly implemented in software. are examples of proprietary
You must be careful not to violate copyright laws when using the work of others. software.
Open source software:
Questions Open source software is
software with source code that
15 Which of the following statements are true?
anyone can inspect, modify, and
A An algorithm can be copyrighted. enhance.
B The expression of an algorithm in a source code file can be (Reproduced under Creative
copyrighted. Commons licence CC BY-SA
4.0 from
C An invention may be patented in the UK if partly or wholly
[Link]
implemented in software.
D The expression of an algorithm in a source code file cannot be
copyrighted.
E An algorithm cannot be copyrighted.

8 Read the article on open source software at [Link]

Questions
16 Some people prefer open source software to proprietary software whilst others prefer to use propriety
software.
State one reason for using open source software and one reason for using propriety software.
Ethical impacts of digital technology

Theft of computer code (not in AQA specification 8525)


The theft of intellectual property is a crime. Software is intellectual property. The copying, use and distribution
of software without permission is known as software piracy. Software piracy started to become an issue when the
arrival of microcomputers in the late 1970s and early 1980s created a mass market, and software houses started to
produce products that didn’t require technical support to install and run.
Cracking and hacking (unauthorised access to a computer system) (not in AQA specification 8525)
Hacking and cracking are forms of Internet and computer related privacy and copyright breaches, usually malicious.
Cracking focuses on finding or making a back door in software, and exploiting it for malicious use or for an act
which breaches copyright. For example, when installing software, the user is often required to enter a unique
product key which came with the software. People who practise cracking try to find a way of subverting this
protection. It might mean patching the software so that it will now accept a product key set by the cracker.
A hacker is someone that uses their extensive knowledge of software systems and computer code (or uses a tool
provided by other hackers) for malicious purposes such as stealing passwords, creating a bot net, or in general
committing acts that breach someone's privacy, without their knowledge, or consent. Broadly speaking, hacking is
unauthorised access to a computer system.
More detail is covered in section 6, Fundamentals of cyber security, of this book.

Questions
17 Explain the difference between a hacker and a cracker.

Environmental impact
We live in an era where a multitude of devices are in use each day from servers to embedded systems, personal
computers to smartphones.
All of these devices consumed natural resources when they were manufactured and create disposal problems which
can impact on the environment when no longer required.
Manufacture
Manufacturing computer parts can result in direct and indirect damage to the environment from:
• the waste generated and the energy consumed in mining of raw materials needed to make the parts and
their packaging
• the consumption of water needed during production of both parts and their packaging
• the power consumed to operate the factories of production
• the use of fossil fuel for transporting parts and their assemblies.
Greenhouse gas emissions result from the above activities which contribute to global warming.
Use
Energy is consumed when devices are in use and also when left unattended, switched on. Many systems include
options for conserving power, but these only operate if the system is configured to use them when the system is
on but inactive. In the UK in 2016 the annual cost of leaving devices on at work or home was estimated to be
£120,000,000. Data centres are particularly high energy users. The Google data centre shown in Figure [Link],
Chapter 4.5.5, of some 100,000 commodity servers, consumes a total power of 40 MegaWatts. This is roughly the
total power output of Coolkeeragh power station in Northern Island.
8 Ethical, legal and environmental impacts of digital

Heat generation, a by product of the use of technology, is also a problem for the environment. Whilst one computer
alone may not seem to generate a lot of heat, the sheer volume of computers in use on this planet do. This heat
doesn't disappear, it dissipates into the environment.
Disposal
One should always try to recycle components not only because computers
Information
contain precious or rare elements such as gold which can be reused but also
Carbon footprint:
because some components are toxic to the environment and some do not The amount of carbon dioxide
decompose readily resulting in the need for more landfill sites. The alternative of released into the atmosphere
burning in an incinerator is harmful to the environment because it will result in as a result of the activities
the emission of greenhouse gases and the release of hazardous chemicals. of a particular individual,
organization, or community.
Environmental benefits
Whilst people should be concerned about the carbon footprint of digital
technologies, some of this footprint can be offset against savings made elsewhere Did you know?
from changing the way things are done. These are listed below. Medical prescriptions:
1. Reduction in use of paper Many doctors' surgeries now
send patient prescriptions
Many items that traditionally were paper-based don't have to be any to pharmacies electronically
longer, electronic copies can now be stored and made available online, thus eliminating the need for paper
reducing the demand for paper. For example, consumers may now download prescriptions.
electronic copies of books and read them on screen.
Cloud storage has made it easier to collaborate online thus avoiding the need Information
to work with multiple paper copies of a document. Digital native:
Someone who has grown up
However, many people still prefer to read paper copies, but it is expected with digital technology.
that this will change over time as the percentage of digital natives increases. Digital immigrant:
When this is coupled with widespread, affordable, high speed Internet access Someone who grew up before
digital technology became
it is expected that there will be less need for paper which should result in
prevalent.
fewer trees being cut down, and less damage to the environment. Also, if less
paper is needed there will be less of it to be disposed, and if disposal is by
burning, less carbon emissions.
Some schools and colleges have already adopted an e-book only policy further contributing to a reduction in
the need for paper.
2. Download versus supply in some storage media form
Software is downloaded nowadays instead of being supplied on storage media such as CD-ROM. This has led
to a reduction in environmental costs incurred by the manufacturing, packaging and transportation of such
storage media. Similarly, transactions are usually paid for online via electronic money, i.e. a credit or debit card,
which avoids the need to use paper money or a paper cheque. Also downloading software avoids another source
of carbon emissions which occurs when software goods have to be physically transported.
3. Working from home
Cloud storage has created more opportunities to work from home as it is now possible to collaborate online on
tasks and avoid journeys to and from the workplace via energy consuming and polluting forms of transport.
This may be a model of working in the future for many people and from which much environmental benefit
may be gained.
Ethical impacts of digital technology

Smart systems
Smart or intelligent systems have the ability to make decisions on behalf of a user, reducing reliance on the need
for human control. Smart home systems now allow users to automate many monitoring and control tasks based
on initial settings plugged into an app. Software then makes decisions based upon external factors such as room
temperature, the time of day, and the movement patterns and habits of the occupants of the house. Smarter control
of heating and lighting systems can lead to energy savings which impact positively on the environment.
In conjunction with smart lighting, i.e. digitally controllable lighting, individual lights can be made to flash to warn
an occupant of a central heating boiler fault that is causing the emission of harmful levels of carbon monoxide.

Questions
18 Give one cause of the negative impact on the environment in each of the following:
the manufacture of digital technology devices.
the use of digital technology devices.
the disposal of digital technology devices.

19 Explain three different environmental benefits of the use of digital technology in particular ways.

Cyber security
See Section 6, Fundamentals of cyber security.
Cloud storage
See Chapter 4.5.5.
Autonomous vehicles
What is meant by autonomous vehicle?
The dictionary definition of autonomous is
Acting alone, independent, self-governing
Autonomous vehicles are automated vehicles with various degrees of control by "machine" where the machine
consists of
• a range of sensors that sense the environment, e.g. other vehicles, and the behaviour of the vehicle, e.g. the
vehicle's own speed
• actuators that physically carry out commands such as apply brakes
• processors that process sensor information, evaluate some or all aspects of the driving situation, make
decisions that control the vehicle to a lesser or greater extent, e.g. take avoiding action; issue commands in
the form of electronic signals to the actuators that carry out these decisions
• algorithms in the form of computer programs that execute in the processors to carry out the tasks of the
previous bullet point.
Autonomous vehicles in the main rely on various levels of artificial intelligence.
The algorithms that are used are machine-learning algorithms.
Such algorithms are harder to test because they rely on statistical techniques.
Contrast this with autopilot software used in commercial aeroplanes which does not rely currently on machine-
learning algorithms.
Autopilot software is considered provably safe because it relies on deterministic algorithms which lend themselves to
proofs of correctness.
Machine-learning algorithms require massive amounts of training data to work properly, incorporating nearly every
scenario the algorithm will encounter. And therein, lies the problem: the sheer number of "edge cases", i.e. unusual
circumstances that autonomous cars have to handle. This is known as the generalisation problem.
8 Ethical, legal and environmental impacts of digital

The death of Elaine Herzberg on March 18th 2018 was the first recorded case of a pedestrian fatality involving
a self-driving (autonomous) car. Elaine was pushing a bicycle across a four-lane road in Tempe, Arizona,
United States when she was struck by an Uber test vehicle, which was operating in self-drive mode with a
human safety backup driver sitting in the driving seat.
According to The National Traffic Safety Board (NTSB) which investigated the fatal crash, the software
installed in Uber's vehicles to help it detect and classify other objects "did not include a consideration for
jaywalking pedestrians". The software was only designed to detect pedestrians at known crossing points called
crosswalks in the United States of America.
Uber's vehicle detected Elaine's presence approximately 6 seconds before impact, but it failed to implement
braking because it kept re-classifying her - alternating between vehicle, bicycle, and unknown object. Each
time the automated driving system re-classified Elaine, it had to predict a new path for her. Unfortunately,
while this was happening, the backup human driver was watching a streaming video on her mobile phone
strictly against Uber's company policy. By the time that the software issued an auditory warning to the backup
driver to take over, it was too late to avoid the collision.

Questions
20 Explain why Example 1 above is an example of the generalisation problem.

Automated and fully-automated vehicle


The Society of Automobile Engineers has published a globally accepted taxonomy (detailed definitions) for six
discrete and mutually exclusive levels of driving automation, ranging from no driving automation (level 0) to full
driving automation (level 5). Central to this taxonomy are the respective roles of the (human) user and the driving
automation system in relation to each other: The task of controlling the movement of the vehicle
1. In level 0 the driver performs the entire dynamic driving task, even when enhanced by active safety systems
such as an anti-lock brake system, electronic stability control. These active Information
safety systems provide momentary intervention but do not perform any Levels 0-2:
part of the Dynamic Driving Task (DDT) on a sustained basis. In levels 0-2, the driver
monitors the driving
2. If the driving automation system performs subtasks of the DDT but not all
environment, the vehicle
then the system is classified as corresponding to level 1 or 2. e.g. adaptive performance, and the
cruise control, lane-keeping/lane-following assistance. driving automation system
performance.
3. If the driving automation system performs the entire dynamic driving task
Adaptive cruise control:
then this is classified as corresponding to levels 3, 4 and 5. Maintains vehicle at a
Levels 0-2 constant speed and at a
constant distance from
In levels 0-2 driving automation, the driver is expected to monitor the driving vehicle ahead.
environment and the driver is expected to be receptive to evident vehicle system
failures and not wait to be alerted, e.g. a broken steering arm - the component that moves a front wheel in and
out under steering wheel control.
Ethical impacts of digital technology

Level 0 Information
There is no automation. The driver performs all the DDT, i.e. driving tasks. Level 3 assumes that the
Levels 1-2 driver is receptive to alerts or
other indicators of a DDT
In levels 1-2 there is some driving automation. The driver performs the performance-relevant system
remainder of the DDT not performed by the driving automation system. failure. Being receptive is not the
The driver is expected to be receptive to and react to evident driving same as monitoring. For example,
a person can be alert to a fire
automation system failures, such as a failure in an adaptive cruise control
alarm without necessarily
system, by resuming performance of the complete DDT, i.e. the driver takes monitoring the fire alarm.
over control.
The differences between the level 1 and level 2 are twofold:
1. The degree of control over the vehicle's movement
2. The degree of object and event detection and response. e.g. other vehicles, lane markings, traffic signs
Level 1 and 2 differences:
• Level 1 is labelled driver assistance because it has limited object and external event detection and response,
and is limited to just one movement, either longitudinal or lateral, e.g. adaptive cruise control system
(responds to external event of vehicle in front) or a lane-centering system (lateral vehicle motion control)
• Level 2 is labelled partial automation (but not self-driving) because it supports limited, but more than level
1, object and external event detection and response, whilst controlling both longitudinal (forward) and
lateral (sideways) separation of the vehicle from other objects, e.g. both adaptive cruise control (maintaining
safe separation from vehicle ahead) and lane-following/lane-keeping/lane-centering system.
Levels 3-5
In levels 3-5 the Automated Driving System (ADS) monitors its own performance of the complete DDT.
Level 3
Information
In level 3 driving automation, the driver must be receptive to a request from The fictional autonomous car
the Automated Driving System (ADS) to intervene and/or be receptive to an KITT from the TV show Knight
evident vehicle system failure, e.g. a broken steering arm. Rider, only achieved level 4
autonomy. Michael Knight
Levels 4-5 was required on occasion to
In levels 4-5 the ADS is responsible for handling any failures. override KITT outside of KITT's
It should transition to a minimal risk condition by autonomous region of operation.

• turning on the hazard lights


• manoeuvering the vehicle to the road shoulder and then parking it before automatically summoning
emergency assistance.
This is called DDT fallback - the plan that is followed when a DDT performance-relevant system failure occurs.
This means that while performing the DDT, the level 4 and 5 ADSs must monitor vehicle performance.
In summary, levels 4-5:
The difference between a level 5 ADS and a level 4 ADS is that the latter is restricted by design to operate in a
specific domain (level 4 is said to be limited by Operational Design Domain (ODD)) whereas the former is not.

The ADS performs the entire DDT and DDT fallback, transitioning to a minimal risk condition without
any expectation that a user will respond to a request to intervene (in level 3, ADS assumes that a DDT
fallback-ready user is available to perform the DDT as required).
8 Ethical, legal and environmental impacts of digital

Level 4
Level 4 ADSs are limited by area/location i.e. geo-fenced; by speed (high or low); specific road types, e.g.
motorways only; the presence or absence of certain road features such as lane markings, road side traffic barriers;
lighting conditions, e.g. day time only, weather conditions; or parking only and others. This is what is meant by
operating in a specific domain.
Level 5
Level 5 is designed to operate in an unrestricted domain:

A vehicle with a level 5 ADS should, once programmed with a destination, be capable of operating
the vehicle throughout complete trips on public roads, regardless of the starting and end points or
intervening road, traffic, and weather conditions.

Table 8.1 shows the Society of Automotive Engineers (SAE) six levels of vehicle autonomy and the UK's
Department of Transport (DOT) levels.
Department for Transport levels
Full
High automation
automation
DRIVER
SAE J3016 Levels 0 to 5 (globally adopted standard)
ATTENTION
Level 0 Level 1 Level 2 Level 3 Level 4 Level 5
Automation
No Partial automation Conditional High Full
provides driver
automation but not self-driving automation automation automation
assistance
Manual control. The vehicle features
an automated
The human The vehicle can perform
system which
performs all multiple automated
responds to external
driving tasks events, e.g an functionalities in
(steering, adaptive cruise tandem such as
accelerating, control system steering AND brake/ The vehicle
braking, etc). which maintains acceleration - lane performs all
May have some vehicle's speed at a centering and adaptive The vehicle driving tasks
safe distance from cruise control at the Environmental
control systems performs all driving under all
vehicle ahead whilst same time. The human detection
but these tasks under specific conditions. Zero
driver controls capabilities. The
respond only to still monitors all tasks
steering. circumstances. human attention
internal events, and can take control at vehicle can perform
Alternatively, lateral Geofencing is or interaction
e.g. control positioning in a any time. most driving tasks,
Tesla Autopilot and required. Human is required.
of vehicle's lane is maintained, but human override
Cadillac (General override is still an Therefore, a
speed by a i.e. lane centering, is still required.
whilst the driver Motors) Super Cruise option. driver does
cruise control
system, and/OR controls the brakes systems both qualify not need to be
are used only and acceleration. as Level 2. Active present.
momentarily, e.g. Automation parking/self-parking,
anti-lock brakes, assistance provides e.g. Nissan's ProPILOT
steering OR brake/ Assist's hand-free and
autonomous
acceleration support foot-free operation.
emergency
but not both at the
braking. same time.

Table 8.1 Six Levels of Vehicle Autonomy


Ethical impacts of digital technology

Example 2 - Fatal crash involving Tesla Autopilot Model S, March 1st 2019
A Tesla Model S with Autopilot was on a dual carriageway with Autopilot engaged when a white-sided
articulated lorry crossed at a crossing point ahead of the Model S. Neither Autopilot nor the Model S driver
registered the presence of the sidewise-on articulated lorry against a brightly lit sky, so the brake was not
applied.
Autopilot is a Tesla product that enables the Tesla car to steer, accelerate and brake automatically within its
lane. Current Autopilot features require active driver supervision.

Tesla state that


• Autopilot is disabled by default;
• when drivers activate Autopilot, they are required to acknowledge that the system is new technology
and that it is "an assist feature that requires you to keep your hands on the wheel at all times", and that
"you need to maintain control and responsibility for your vehicle" whilst using it;
• everytime that Autopilot is engaged, the car reminds the driver to "Always keep your hands on the
wheel. Be prepared to take over at any time."
Tesla also state that
• the system will make frequent checks to ensure that the driver's hands remain on the wheel;
• visual and audible alerts will be made if hands-on is not detected and then the car will be gradually
slowed until hands-on is detected again.
This was the first known fatality in just over 130 million miles where Autopilot was activated. In contrast,
there is a fatality every 94 million miles among all vehicles in the US and a fatality approximately every 60
million miles worldwide.

Questions
21 State the level of driving automation in the range level 0-5 for the Tesla Autopilot Model S described in
Example 2 above.

22 State using the range level 0 to level 5 which level of automation applies in each of the following
A The car can drive itself completely, but only within a well-mapped area.
B The car can drive itself on certain roads under certain conditions, but a driver is still needed and the
driver must be receptive to a request to intervene from the Automated Driving System (ADS).
C The car manages both its speed and its steering on motorways but the driver must still pay attention to
driving conditions at all times and decide to take over immediately if necessary.
D The car is kept at a safe distance from the car ahead whilst travelling in the slow lane on a motorway
whilst the driver steers the car.
E The car can drive itself anytime, anywhere, under any conditions whilst the occupants of the car are
passengers whose only role in the driving is to tell the car where to take them.
F The car's speed can be set and maintained autonomously but every other aspect of driving is done by
the driver.

23 State three reasons why motorways are easier for autonomous driving systems than non-motorway roads.
8 Ethical, legal and environmental impacts of digital

Technology
Autonomous or self-driving vehicles must be able to "see" their environment in order to know where they can and
cannot drive, detect other vehicles on the road, stop for pedestrians, and handle any unexpected circumstances
they may encounter. For this purpose, autonomous cars use a range of sensors which may be classified as active or
passive.
Active sensors send out energy in the form of a wave. The returned energy contains information about the objects
that reflect this wave energy. Active sensors use high frequency radio waves in the form of radar, infrared light waves
in the form of lidar and high frequency (beyond the audible range) sound waves in the form of ultrasonic waves.
Passive sensors simply take in information from the environment without emitting a wave, e.g. a stereo camera,
infrared camera for seeing through fog and at night.
The range of sensors employed enable an autonomous car to have 360-degree vision, and thanks to lidar, radar, and
ultrasonic sensors, the car can see through fog and in the dark.
Other very important sources of information used by autonomous cars are GPS, high definition maps, Vehicle-to-
Vehicle (V2V) and Vehicle-to-Everything (V2X) communication.
High definition maps with a resolution of a centimetre provide an accurate, realistic representation of the road
network, including lane structure, traffic signs, traffic lights, lane geometry and road furniture, e.g. lamp posts,
crash barriers. Such maps reduce the amount of processing of sensor information that onboard computers in an
autonomous vehicle have to do to navigate a safe route to a destination.
Vehicle-to-Vehicle and Vehicle-to-Everything communication enable sharing of more environmental information
to enable autonomous vehicles to identify blindspots, avoid roadworks and traffic incidents, avoid collisions with
pedestrians/cyclists, animals or other vehicles on the road, and interact electronically with street furniture.
For example,
• Blindspot case: The lead vehicle in a convoy of three vehicles operating autonomously might slow abruptly
on encountering a cyclist. The presence of the cyclist could be communicated in real time to the two
vehicles behind which could also then slow their speed autonomously and drop back knowing now that
there is a cyclist hidden from view by the lead car.
• Unexpected situation: Vehicle A switches lane suddenly in front of the path of vehicle B on a motorway.
To avoid an accident, the sensors on both cars communicate with each other via V2V with the result that
vehicle A speeds up and vehicle B brakes autonomously.
• "Telepathy": Vehicle A can inform vehicle B that it is considering changing lane before making the decision
to do so.
• Optimising traffic flow: Vehicles can communicate with traffic lights to minimise wait times at junctions
and optimise traffic flow.
• Turning on street lights: Vehicles can turn on street lights by communicating wirelessly with a controller
mounted in each street light. When the vehicle is out of range, the controller can turn the light off thus
saving energy.
• Driving abroad: If a self-driving car is taken to mainland Europe can it cope safely with the switch from
driving on the left to driving on the right? Perhaps this is a case for geofencing and handing over to a
human driver. Alternatively, if it is connected to its manufacturer via a 5G network, on recognising a
change of country it could download the necessary software changes for driving on the right in a country
with different signage, road customs, value system, etc in realtime.
Ethical impacts of digital technology

A choice exists between a direct short-range wireless connection and a wireless network which supports far as well as
near coverage, if vehicles are to be interconnected. Connecting to a wireless network supports vehicle-to-network,
vehicle-to-cloud, vehicle-to-IoT (Internet of Things), in addition to vehicle-to-vehicle. Direct short-range wireless
only supports vehicle-to-vehicle communication.
Any wireless network that supports V2V and V2X will need to be capable of relaying information sufficiently
quickly to enable a decision to be made in a time that at least matches that of a human driver. To achieve on-all-the-
time coverage and necessary speed of response nationally, car manufacturers will need to use Fifth Generation (5G)
wireless networking. Current Fourth Generation (4G) wireless networking will not be fast enough.

Questions
24 List and describe three different technologies that a self-driving vehicle may use to accurately detect a
hazard.

25 Explain why is it helpful to have pre-mapped the environment in which a self-driving car is to operate
autonomously.

26 Describe one benefit that could follow if all road vehicles are self-driving and connected by a 5G wireless
network.

Ethics
When an individual reaches a conclusion or decision as to the morally right course of action they often draw on a
framework or set of principles to help their reasoning, e.g. our actions should do no harm. The framework or set of
principles is called an ethical framework or just, ethics. When applied to particular cases, the framework can provide
clear choices. Each ethical framework embodies the social norms and value system of the society which adopts it.
In the UK in 2018, more than 160,000 people were injured on the roads. Over 25,000 of these were seriously
hurt. 1,784 people died2. The large majority of road traffic accidents are caused when a driver makes the wrong
choice. By removing the driver from the decision-making process, autonomous vehicles hold out the possibility of
removing the source of most errors and therefore of significantly improving safety. For this reason, the mission of
encouraging and facilitating the adoption of autonomous vehicles on the roads of the UK is a moral one. Of
course, autonomous vehicles may never attain a perfect safety record but the evidence to date is that their safety
record is better than that of human drivers.
All driving involves risk. The technology within autonomous vehicles will use an "algorithm" that aims to minimise
the risk of injury to the occupants of vehicles, pedestrians, cyclists, other road users as well as the risk of damage
to property. This "algorithm" therefore must have an ethical component, as such it has been labelled the "moral
algorithm".
Who should decide this "moral algorithm"?
Human drivers operate in the complex environment of the UK's road network and their driving decisions reflect
the individual nature of each which ranges from risk-taker to risk-averse.
The "moral algorithm" will distribute risk among occupants of autonomous vehicles, pedestrians, cyclists, other
road users, and property. How should this be done and by whom?

2 Department of Transport - Reported road casualties in Great Britain:2018 Annual report.


8 Ethical, legal and environmental impacts of digital

Task
9 What is your answer to the ethical dilemma question posed in Example 3. Explain your answer.
Who do you think should decide on how the risk should be distributed? Explain your answer.

Example 3 - How should driving risk be distributed and by whom?


Example ethical dilemma:
Given no other option, should the autonomous vehicle (self-driving) harm several pedestrians by swerving, or
sacrifice its own passengers to save a greater number of passers-by?
Who should decide on the distribution of risk embodied in the "moral algorithm":
Software engineers who will design and write the software, the vehicle manufacturer who is responsible in
law for the autonomous vehicle or a public body regulator appointed by Government? Before answering this
question you may like to consider the following statements:
• Software engineers should decide on the distribution of risk because they possess superior technical
understanding and skill and therefore can make the right decision in all cases.
• The vehicle manufacturer should decide because they believe that liability in law won't ever arise since
their vehicle will be safer than a reasonable human driver.
• A respected authority with legislative powers who can set the parameters for the "moral algorithm" in a
way that will gain the trust of the public.

10 After reading Example 4 do you think that the "moral algorithm" dilemma is really relevant? Explain your
answer.

Example 4 - Is the moral algorithm really relevant?


1. Future autonomous vehicles should prioritise saving their own occupants in a no-win traffic situation,
i.e. where someone is likely to die. If you know you can save at least one person, at least save that one,
i.e. save the one in the car. The "moral algorithm" should therefore prioritize the safety of occupants of
the vehicle over pedestrians.
2. A "moral algorithm" that takes the decision to run over the pedestrian in a no-win traffic situation
would be unethical, unacceptable, and also illegal because for all these reasons, it is a decision in favour
of one person and thus against another.
3. Neither programmers nor automated systems are entitled to weigh the value of human lives.
4. The "moral algorithm" dilemma situation can be completely avoided by, for example, implementing a
risk-avoiding operating strategy in autonomous vehicles.
5. The ethical question of who to save won’t be as relevant as people believe, today, because it will occur
much less often in the future if autonomous vehicles are commonplace.
6. There are situations that human drivers, today, can’t handle or which, from a physical stand point, are
also unpreventable with both conventional and autonomous vehicles. However, autonomous vehicles
will be far better than the average driver.
7. Autonomous vehicles won’t drive into situations where the "moral algorithm" dilemma could happen
and will drive away from potential situations where those decisions have to be made at all.
8. Human drivers don't make ethical decisions, they react on instinct and are either lucky or unlucky so
why should we expect autonomous vehicles to do any better by employing a "moral algorithm".
Ethical impacts of digital technology

27 If a manufacturer offers different versions of its "moral algorithm", and a buyer knowingly chooses one
of them, is the buyer to blame for the harmful consequences of the algorithm's decisions? Explain your
answer.

The general consensus in the industry is that concerns over the so-called "moral Information
algorithm" problem – where a vehicle is unable to avoid a collision and is asked "The moral algorithm is a
to make a choice over which defined individuals it hits – are exaggerated, with term that is good for tabloid
most experts agreeing that autonomous vehicles would never be programmed to newspapers. There is no such
make such decisions. thing in the software that will
tell the car to hit the 80-year old
However safety regulations would be needed for other "decisions", such as in order not to hit the group of
when it is permissible for an autonomous vehicle to break the rules of the road kids."
(see task 11), and how should a vehicle respond when interacting with other Dr Heiko Schilling ("The Moral
Algorithm", December 2016)
road users, e.g. at cross roads where who goes first is resolved by an accepted
convention that the vehicle that starts to edge out, signals its driver's intention
to go first to the other vehicle's driver.

Questions
28 A person of good judgement will know when to disregard the letter of the law in order to follow the spirit
of the law, e.g. to briefly exceed the speed limit to get out of the way of an emergency vehicle flashing its
blue lights. Read Example 5. Who do you think should set the confidence level of safety to be
programmed into the software:
100% confidence level means the car always operates safely
Manufacturer
0% confidence level means the car never operates safely

An independent regulator appointed by Government?


Explain your reasoning.
29 Read the following article
[Link]

Explain why access to black box information from automated vehicles involved in crashes is important.

Road traffic law is broken if a vehicle crosses a double white line in the centre of the road.
Double white lines in the centre of the road are there for a good reason: highway engineers have identified that
this section of road is unsafe and for this reason want vehicles to stay on the left hand side of the road at all
times.
A self-driving vehicle programmed to follow the letter of the law refuses to cross a double white line to avoid
a drunken pedestrian who has stepped into the road, even though the vehicle knows that the other side of the
road is empty of traffic.
Rarely will a self-driving vehicle be absolutely certain that crossing a double white line is safe but if the
vehicle is reprogrammed to not always follow the letter of the law, then who decides what confidence level of
safety to program into the software, e.g. 98%, and how this level must vary depending on what the vehicle is
attempting to avoid, whether it is litter swept into its path by a breeze or a fallen pedestrian.
8 Ethical, legal and environmental impacts of digital

11 UK Autodrive is the largest of three UK consortia launched to support the introduction of self-driving
vehicles in the UK. One of the cities chosen by UK Autodrive for their trials of self-driving vehicles was
Milton Keynes in Buckinghamshire.
Investigate the design of the road network of Milton Keynes to discover what makes it suitable for the
trials of autonomous vehicles?

In summary, the main moral benefit of autonomous vehicles will be


enhanced road safety. The degree to which this will be realised is in Information
A driverless delivery lorry is being used
proportion to the degree to which
alongside normal traffic on public roads
• autonomous vehicles dominate the road network in Sweden.
• the inter-connectedness (5G) of autonomous vehicles The large lorry, called a T-Pod, weighs 26
tonnes fully laden and transports goods
• the support provided by the road network infrastructure, i.e. road
between buildings on an industrial
networks designed to assist autonomous vehicles. estate.
Legal The vehicle is not entirely autonomous,
The Automated and Electric Vehicles Act 2018 received Royal Assent on as a remote operator monitors it from a
19 July 2018. control room while it works.
The lorry is limited to 5km/h while
The Act uses the term ‘automated vehicles’ (AVs) when referring to mixing with human-driven traffic
driverless cars. and can make trips between only two
According to the Bill, locations on the industrial estate.
Advanced communications systems have
"a vehicle is 'driving itself' if it is operating in a mode in which it been placed along the route the lorry
is not being controlled and does not need to be monitored by an travels, so its remote human operator
individual." will never lose contact.

Therefore, the Act applies only to levels 3-5 automated vehicles and
excludes the current and near future semi-autonomous vehicles in which Information
the driver is expected to be monitoring the vehicle whilst in AV mode, i.e. A British driver pleaded guilty to
dangerous driving after another
vehicles that operate at levels 1 and 2.
driver took video of him sitting in the
The exclusion of current and near future semi-autonomous vehcles from passenger seat, while his Tesla S 60 drove
the scope of the Act means that accidents involving these vehicles may on its own with Autopilot. Autopilot is
have to be resolved by the courts, in cases that may well require complex classified as level 2 automation.
The incident took place on the M1 near
technical evidence and involve the manufacturer.
Hemel Hempstead on May 21st, 2017.
Under the Act an insurer or owner can be liable for the consequences of Hertfordshire Police reported that the
an accident caused by the actions of an AV at a time when it is not under car was set to drive at 40mph, and that
the immediate physical control of a human being: the driver had left the steering wheel and
controls unattended, and that there was
"Where heavy traffic on the road at the time of
(a) an accident is caused by an automated vehicle when driving the incident.
itself on a road or other public place in Great Britain, The driver was banned from driving for
(b) the vehicle is insured at the time of the accident, and 18 months, fined £1,800, and ordered to
carry out 10 days rehabilitation, and 100
(c) an insured person or any other person suffers damage
hours of community service.
as a result of the accident, the insurer is liable for that
damage."
Ethical impacts of digital technology

'Damage' in this context can include death, personal injuries or damage to Information
property, subject to certain specific limitations. This provision cannot be excluded The Automated and Electric
by the terms of insurance policies. Vehicles Act 2018 Act amends
The intention of the Act is for victims of accidents involving AVs to obtain the existing compulsory third
party insurance framework by
compensation quickly and easily, without prolonging the process with
extending it to cover the use of
complicated product liability claims against the AV technology manufacturers, or automated vehicles.
dealing with liability disputes between insurer and manufacturer.
The insurer remains free to pursue the manufacturer for any reimbursement
or contribution if it can be established that the manufacturer is liable for the accident in question. Of course,
manufacturers can claim a "state of the art" defence to escape liability by arguing that they could not have known
about a particular danger or danger in their product at the time of making or selling it.
Liability may be limited, however, where the accident is caused by
• modifications to software made by the injured party, or with their knowledge, that are prohibited under
the insurance policy, or
• failure by the injured party to update safety critical software when it becomes available. Software is
‘safety critical’ if it would be unsafe to use the vehicle without the updates being installed.
The criminal liability of Car vs Human
Where does liability reside when a road traffic offence is committed by an autonomous vehicle in which the vehicle
is driving itself - levels 3-5. The human user(s) is not the 'driver' and therefore should not be liable for any offences
which are committed while the car is in charge. This is the preliminary view of the UK Government which is
proposing a manufacturer authorisation scheme for autonomous vehicles.
The Government proposes that manufacturers who gain authorisation for their vehicles would be liable for road
traffic offences. These could include improvement notices, fines and where necessary suspension or withdrawal of
approval.

Questions
30 Under the Automated and Electric Vehicles Act 2018 Act
(a) Who can be liable in the first instance for the consequences of an accident caused by the actions of
an automated vehicle (levels 3-5) at a time when it is not under the immediate physical control of a
human being?
(b) Who is liable in the case of an accident that is the direct result of a failure to update safety critical
software:
• The insured person who knows, or ought reasonably to know, that the software to be updated is
safety-critical?
• The insurer?
(c) Who is liable in the case of an accident that is the direct result of software alterations made by the
insured person, or with the insured person’s knowledge, that were prohibited under the policy:
• The insured person?
• The insurer?
31 An insurer believes that the manufacturer of an automated vehicle that crashed in automated mode,
injurying the insured "driver" and writing off the vehicle, is at fault because the vehicle hit a road barrier
which it should have avoided. What defence might a manufacturer call upon to avoid product liability?
Ethical impacts of digital technology

The General Data Protection Regulation (GDPR) 2018 Information


The Internet of Things (IoT) can connect all types of devices to the Connected vehicle:
Internet to share information and thereby augment their capabilities and A vehicle that connects to other
understanding of their environment. Autonomous vehicles are connected vehicles and/or devices, networks
and services outside the vehicle
for this very reason: to share information from their on-board sensors, as
including the Internet, other
well as from smart phones of pedestrians and cyclists, traffic sensors, parking vehicles, home, work office or
detectors, etc. infrastructure.
Internet of Things(IoT):
The GDPR has taken a stronger line on privacy than its predecessor, the
The network of physical objects -
Data Protection Act 1998, by tightening control and imposing greater vehicles and devices - embedded
accountability on organisations which collect, store and use personal data. with electronics, sensors, software,
For example, the rules on consent and privacy notices are much tighter. and network connectivity that
enables them to collect and
Autonomous and connected vehicles thus present a problem because large
exchange data.
amounts of data will be collected and communicated via V2V and V2X. For
example, any journey to or from home in a connected vehicle will enable
identification and tracking of individuals and so will involve collection and use of personal data. This data could
potentially be used by any of the following:
• The car • Infrastructure
• Insurers • Police and other law enforcement agencies
• Other vehicles • Commercial organisations
• Traffic planners
In some cases, consent to use the data will be required, e.g. by a commercial organisation which has 'purchased'
access to the data and wishes to send marketing to individuals in the vehicle such as "we've noticed that you are
approaching a drive-through restaurant, would you like to get a meal as it is lunchtime?". In another case, insurers
must obtain consent to profile the vehicle owner's driving in order to determine what to charge the owner for
vehicle insurance. Anyone who has visited a website will recognise the all too common message:
Profiling
" We use cookies and similar methods to recognize visitors and remember their preferences. We also use them
to measure ad campaign effectiveness, target ads and analyze site traffic. To learn more about these methods,
including how to disable them, view our Cookie Policy. By clicking ‘accept,’ you consent to the processing of your
data by us and third parties using the above methods. You can always change your tracker preferences by visiting
our Cookie Policy."
Imagine, if everytime the driver took a trip in their autonomous and connected vehicle, they had to spend the first
ten minutes ticking or unticking consent boxes. This introduces the likelihood that regulators will have to legally
mandate personal data sharing to reduce the inconvenience of consent-giving. But how much data should be
shared?
GDPR requires that the organisation obtaining this consent also records this in order to prove that it has been
given.
GDPR also states that any data collected must be used strictly for purposes which have been notified and consented
to.
Autonomous car maunfacturers will be particularly exposed to GDPR because they will collect and process a lot of
data to enable monitoring of the vehicles that they sell so that they can better understand how the vehicles perform.
8 Ethical, legal and environmental impacts of digital

Questions
32 Why does the General Data Protection Regulation 2018 present a problem for the operation of
autonomous and connected vehicles on roads in the UK.

Cyber security of autonomous vehicles


Cyber attacks on connected, autonomous vehicles have the potential to threaten the safety and privacy of all road
users. As the number of connections of these vehicles with the external environment and third parties increases so
will the risks of cyber attacks. Example 6 shows what was possible in 2016.

In 2016, Hyundai had to update its Blue Link smartphone app to stop it releasing private data that could
be used, potentially, to break into and steal people's cars. The smartphone app uses the Blue Link bluetooth
connection to unlock the car and enable ignition. The vulnerable version of the smartphone app, in a separate
process, used HTTP to transmit personal information such as username, password, PIN, GPS location records,
encrypted with a fixed symmetric key, back to Hyundai. However, this encryption/decryption key could be
extracted by a hacker from the smartphone app's code and used to decrypt the data, transmitted between
smartphone app instance and Hyundai, to obtain the necessary information to break into the car. To get a
copy of the data in the first place, a hacker eavesdrops on the app's network connections. Luckily, Hyundai
became aware of the problem and fixed it before any cars could be stolen.

The modern car in 2020 has about 100 million lines of code (the Android operating system has 12 million).
Unlike the code in a modern aircraft which has been designed from the top-down to a mathematically rigorous
specification, and quality assured by proof that the code has the properties it ought to have, the code in the modern
car has evolved in a bottom-up way as more and more features became available - see Example 7. Much of the code
in the modern car is legacy code (code that is no longer supported) and some comes from open source libraries on
the Internet. Connecting this code to a network increases the chances of a hacker finding an access point into a
section of the code designed at a time when cyber security was not a threat.

Professor Phil Blythe, Professor of Intelligent Transport Systems, Newcastle University and Chief Scientific
Adviser for the Department of Transport has stated

Questions
33 State two kinds of cyber security threat that autonomous and connected vehicles could be exposed to on
UK roads?
34 Why should the owner of an autonomous and connected vehicle keep the vehicle's software up to date?
35 With the exception of new car manufacturers such as Tesla which have designed their autonomous and
connected cars from the ground up, modern cars have evolved over time with software and hardware
being bolted on to enable new features. Explain why the latter's approach to developing autonomous and
connected cars might not be the most cyber attack resilient.
36 Give two reasons why a cyber attack on a modern passenger jet is less likely to succeed than a cyber attack
on an autonomous and connected car?
Ethical impacts of digital technology

Environmental impact of autonomous vehicles


Autonomous vehicles have the potential for both positive and negative impacts on the environment.
Significant effects either way depend upon whether autonomous vehicles become commonplace, and the greenness
of the energy they consume. Even electric cars and hydrogen cars need recharging which consumes electrical energy
directly or indirectly, respectively. The hydrogen that fills the "tanks"of hydrogen-powered cars is made before it
goes into the car by splitting water, a process that consumes electrical energy.

Positive impact on the environment


Autonomous vehicles are able to drive closer to each other because their reaction times are faster than human
drivers. This should raise the road capacity which means less congestion. Less congestion means shorter journey
times and therefore lower energy consumption.
Vehicle-to-vehicle communication, vehicle-to-Cloud and vehicle-to-infrastructure enables
• braking and acceleration to be done in a smoother and more energy efficient manner
• an energy-optimal speed to be chosen for each section of a journey
• the most energy-saving route chosen in real time for the journey from A to B.
For example, traffic lights could be better coordinated at junctions to promote steadier flows of vehicles. These
traffic lights which are part of the road infrastructure would need to be connected into the communication network
shared with autonomous vehicles.
The accident statistics from public road trials conducted to date have demonstrated that autonomous vehicles are
safer than human drivers. Manufacturers may decide when autonomous vehicles dominate the highways and are
considerably safer than non-autonomous vehicles that they can dispense with many of the safety features currently
needed in non-autonomous vehicles, e.g side-impact bars. If this is done then the weight of a vehicle can be reduced
leading to a saving in the energy required to move the vehicle.
Negative impact on the environment
Autonomous vehicles should make travelling a lot easier and more convenient if the vehicle drives itself: "Let the car
take the strain"!
However, this is likely to increase the number of miles travelled as car owners decide to make trips that they
wouldn't have done otherwise. It might also encourage people to live further from work resulting in longer car
journeys. Autonomous vehicles would enable people who are unable to drive for whatever reason to take to the
road increasing the number of vehicles on the road or the number of journeys made. In areas such as city centres
where unoccupied parking spaces are difficult to find and/or expensive, an owner of an autonomous vehicle might
find that it is more convenient and cheaper to let the vehicle drive itself around and around instead of parking it.
The net effect would then be that energy consumption might go up because more journeys are being taken overall.
These journeys might also not be energy-efficient because the roads might become even more congested than they
are currently.

Questions
37 State two reasons why autonomous vehicles could have a positive impact on the environment.

38 State two reasons why autonomous vehicles could have a negative effect on the environment.

In this chapter you have covered:


■ The current ethical, legal and environmental impacts and risks of digital technology on society. Where data
privacy issues arise these are considered.
363

Common questions

Powered by AI

High-definition maps provide detailed road network data, allowing autonomous vehicles to anticipate road geometries, traffic signs, and signals accurately. This pre-mapped information reduces the computational load on the vehicle's onboard systems and enhances the ability to navigate safely by integrating real-time sensor data with map information .

V2V communication allows autonomous vehicles to share real-time information about their location, speed, and surroundings. This enhances traffic flow and safety by allowing vehicles to respond to dynamic conditions, such as sudden braking by another vehicle or road obstacles, thus preventing accidents and reducing traffic congestion .

Binary is used to represent all data and instructions in computer hardware because it aligns with the physical operation of a computer's circuitry, which utilizes on/off (1/0) states. This binary state system provides a straightforward and reliable method for instructing computing processes .

The von Neumann architecture facilitates communication through the system bus, which is subdivided into the address bus, data bus, and control bus. The CPU sends an address over the address bus to main memory and uses the control bus to initiate reading or writing. Data transfer occurs over the data bus. This setup allows for efficient execution of instructions and memory access .

Ethical concerns include the "moral algorithm" problem, where vehicles might theoretically have to choose between potential accident outcomes. While experts consider this exaggerated, safety regulations are necessary for scenarios like rule-breaking for safety or road interaction decisions. Addressing these involves setting clear safety guidelines and ensuring autonomous systems are programmed with safety as a priority .

To convert a decimal number to binary using successive division, you repeatedly divide the number by 2 and record the remainder. This process is continued until the quotient is zero. The binary equivalent is obtained by reading the remainders in reverse order, starting from the last division performed .

Hexadecimal numbers provide a shorthand for binary that makes reading, writing, and debugging machine code easier. Long strings of 1s and 0s are difficult for humans to manage, so hex provides a more user-friendly format. It reduces errors, as it requires fewer digits than binary, and makes maintaining and debugging code simpler .

Cache memory serves as a high-speed storage area that temporarily holds frequently accessed data and instructions. By storing this information closer to the CPU, cache memory reduces the need to access slower main memory, thereby alleviating the bottleneck that occurs due to the disparity between CPU and memory speeds .

Encrypting network communications protects the data from being intercepted and misused by unauthorized individuals. It prevents eavesdroppers from accessing sensitive information such as passwords, thus enhancing the security of the network .

Network protocols define the rules for data transmission across a network, enabling reliable communication between devices. They ensure data integrity and security, addressing issues such as error handling and message format. This standardized communication framework is crucial for the seamless operation and interoperability of diverse network systems .

You might also like