Lecture Notes Fit1047
Lecture Notes Fit1047
Lecture Notes Fit1047
0 0 0000
1 1 0001
F 15 1111
Tasks:
3.a Convert the base 16 number 123C9F to base 10 using both methods
Fast method = place base number, multiply by base, proceed to add next base
number, then multiply by base, until add final base number.
E.g. 1 * 16 5 + 2 * 16 4 + 3 * 16 3 + 12 * 16 2 + 9 * 161 + 15 * 16 0 = 1,195,167
Convert 1286 from base 10 to base 16
3.c Convert the hexadecimal (base 16) number AFC934B2D to binary without the
use of addition, subtraction, multiplication, or division
Simply convert every specific hexadecimal digit into a 4 line bit to solve.
Negative binary numbers
Sign and magnitude
Use one bit as the sign bit. The leftmost bit represents its sign, 0 means positive,
1 means negative. E.g. 8-bit number 11010110 is -86, as leftmost bit 1 is
negative, and the seven bits represent 86.
One’s complement
Simply by flipping all bit values. If leftmost bit is 0, the number is positive
Important rule with adding/subtracting, If the final carry (leftmost bit) is 1, carry it
to the end.
Error Detection – Binary data is just strings of bits, if there is an error we need
to check
Methods:
Parity bits – adding a parity bit to binary data is to detect that one single bit has
changed. Usually at the end of a byte.
E.g. Electrical signal causes a byte data transmission to send wrong data.
1 1 0 0 1 1 0 1
= 205
1 1 1 0 1 1 0 1
= 237
In order for a computer to determine if a byte transmission is correct, it would
initiate an even parity check or an odd parity check
For an even parity check, the parity bit would be a zero
E.g. 00110110
For an odd parity check, the parity bit would be a one
E.g. 00111011
This allows so that any distortion in the byte will immediately notify the computer
that its wrong. However, if two bit’s have been altered, then the computer
recognizes it’s the same even/odd result, hence a problem.
Checksum – Counting the number of bits
A specific number is agreed upon.
43 52 43 30 31 30
43 52 43 30 31 30 5
43 52 43 29 31 30 5 = 228/16 = 14 remainder 4
There is a small problem however as there can be a chance that multiple errors
can cancel each other out e.g.
43 54 43 28 31 30 5 = 229/16 = 14 remainder 5
Remainder = 10
AND Table
A B A*B
0 0 0
0 1 0
1 0 0
1 1 1
OR Table
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
NOT Table
A ¬A
0 1
1 0
Universal gates:
NAND gates
´ .
NAND is AB
NOR gates
A B ´B.
A+
0 0 1
0 1 0
1 0 0
1 1 0
Null Law
AND Form OR Form
0*A=0 1+A=1
Idempotent Law
AND Form OR Form
A*A=A A+A=A
Complement Law
AND Form OR Form
A ∗ Á = 0 A+ Á = 1
Commutative Law
AND Form OR Form
A*B=B*A A+B=B+A
Associative Law
AND Form OR Form
(AB)C = A(BC) A+(B+C) = (A+B)+C
Distributive Law
AND Form OR Form
A+(BC) = (A+B)(A+C) A(B+C) = AB+AC
Absorption Law
AND Form OR Form
A(A+B) = A A + AB = A
DeMorgans Law
AND Form OR Form
A´. B = Á+ B́ ´ B ) = Á ∗ B́
( A+
There is one large group with 4 1s that is covering the complete space for A=1
There is another group for the two 1’s, where C = 1 and B = 0
Hence we can simplify the function to F(A,B,C) = A + B́C
Rules of K-Maps:
1. No group can contain 0
2. Groups must be horizontal/vertical/square but never diagonal
3. Groups must be in power of 2’s
4. Groups must be as large as possible
5. Groups can overlap
6. Groups can overlap around the map
input/output devices.
(ALU), a number of
Unit (CU).
Registers – store temporary results and move instructions and data around
memory.
CPU's
7. Executes instructions
Compilers
execute machine code. A compiler takes a program and translates it into a lower
level language. C++ translates into machine code. Java translates into byte code.
Interpreters
Machine code
instructions, each line being just a sequence of bits. The program is stored in
memory.
0001000000000100
0001000000000100
A protocol that a CPU uses to understand machine code is called the Instruction
Set Architecture (ISA). Different CPUs have different ISA’s. A CPU must be able
to do 3 things:
CPU COMPONENTS
Memory
Main memory is like a sequence of locations, each of which can store one value.
Each value has a fixed width, a fixed number of bits. A program can read the
value stored in the location, and change it. In order to determine that, programs
need to be able to know which memory location they want to read or change.
That is why each location gets an address, by labelling the locations, starting
from 0. One memory location stores one byte, this is byte-addressable memory.
In MARIE, one memory location stores one word. In order to address 2n memory
Registers
A very fast memory location inside the CPU. Can only store a single word. There
registers used by the CPU. Two special purpose registers are the
executing
Arithmetic logic unit (ALU) – Responsible for performing basic computations like
addition and multiplication, as well as Boolean logic operations like AND and OR.
Control Unit (CU) – Responsible for coordinating all components of the CPU. E.g.
it can switch the memory into “read” or “write” mode, select a certain register for
reading or writing, and tell the ALU what kind of operation to perform. All this is
1. Fetch – CU transfers instructions from main memory into the IR, then
Bus(s) – Responsible for connecting the components inside the CPU, as well as
to I/O devices.
1. 16 bit words
2. Only 16 instructions
4. Instructions are one 16-bit word, composed of a 4-bit opcode and a 12-bit
address
Registers
MBR (Memory Buffer Register)– Holds the data read from or written to
memory
executed
Instructions
Each instruction in MARIE is a 16-bit word. The leftmost 4 bits represents the
opcode, which tells us what kind of instruction it is. The remaining 12 bits
E.g., the opcode 0001 means “Load the value stored at the address mentioned in
inAC
Notice how instructions use the AC register as temporary storage. Now we can
Load 4
Add 5
Store 6
Halt
Two more special Opcode’s are used to perform stronger programming. They
allow jumping to different parts of the program depending on certain conditions.
(depends on X)
SkipCond 000: If the value in AC is smaller than 0, then skip the next
instruction.
SkipCond 400: If the value in AC is equal to 0, then skip the next
instruction.
SkipCond 800: If the value in AC is greater than 0, then skip the next
instruction.
SkipCond skips the next instruction if the condition is true, so ‘else’ part should
go right after the skipCond, and the ‘then’ part comes after.
Indirect addressing
Instead of accessing the value stored at location x, we can use the value stored
at x as the address at which the actual value we want to use is stored. E.g.
ADDRESS VALUE
Now a Load 102 instruction = look into
100 3 address 102, find the value 100, and load the
Data Paths- Describes how all functional units are connected together
MAR
MBR
4 PC increments by 1 PC ← PC+1
performs action
being executed
instructions in RTL
Load X 7. AC ← MBR
Store X 6. MBR ← AC
7. M[MAR] ← MBR
Add X 7. AC ← AC + MBR
Subt X 7. AC ← AC – MBR
SkipCond X 6. If MAR = 0x800 and AC>0 then PC ← PC + 1
Jump X 6. PC ← MBR
Clear 5. AC ← 0
AddI X 7. MAR ← MBR
8. MBR ← M[MAR]
9. AC ← AC + MBR
JumpI X 7. PC ← MBR
LoadI X 7. MAR ← MBR
8. MBR ← M[MAR]
9. AC ← MBR
StoreI X 7. MAR ← MBR
8. MBR ← AC
9. M[MAR] ← MBR
JnS X 6. MBR ← PC
7. AC ← MBR
8. AC ← MAR
9. PC ← AC + 1
Combining both RTL and Control signals, The Add X instruction will look like this
Combinational Circuits
Circuits are collections of Boolean gates connected by wires. They include inputs
and outputs.
A B Carr Resul
y t
0 0 0 0
0 1 0 1
1 0 0 1
AND GATE
1 1 1 0
XOR GATE
Half Adders – In order to construct a circuit that implements the function above
we look at the outputs. For Carry, we can see that it is 1 only when both inputs
are 1, hence an AND gate. For Result, we can see that it is 1 only if one of the
Full Adders – A half adder is only half-useful. It can only add up two bits and
produce two new bits as output, so it cannot construct adders for larger numbers.
t
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 0 1
0 0 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 1
ALU
Inputs:
Outputs:
Memory-mapped I/O architecture – I/O registers are mapped into the address
Programmed I/O
How does the program get notified that new input is available? Through a
Program is used that goes through an infinite loop to check if the I/O registers
has new data to read, and if it does, it calls a subroutine to process the new data.
If polling is too fast, will waste computing power, if too slow, system will feel
laggy.
Interrupts
Modern approach, makes the hardware notify the CPU when new data is
available. The CPU interrupts its current activity and jumps into a special
Components of a computer
BIOS vs UEFI
BIOS has very limited space, only 1024 kilobytes, and only works with specific
hard-drives up to 2.2 terabytes. Cannot work with future and current technology.
UEFI is Unified Extensible Firmware Interface, a programmable interface. It
works as a non-volatile memory, but is a software, acting as a BIOS.
1. Manages peripherals
2. Manages files
3. Manages Memory- Virtual and secondary
4. Manages interface
Week 6: Security
Learning Objectives:
Introduction to Cryptography
principals.
The same key is used for encryption and decryption. Most symmetric algorithms
boxes.
problem and a large random number, a key-pair is generated, so that the private
key cannot be derived from the public key without solving the mathematical
Example, RSA
by c7.
Scalability – Each pair of sender and receiver needs a unique secret key.
Piece of code used to authenticate a message, confirm that the message can
from the stated sender and has not been changed. Verifiers possess a secret key
to detect changes.
A algorithm that maps data of any size to a bit string of a fixed size which is
The only way to recreate the input data from a hash function's output is to
They are used in digital signatures for storing and comparing passwords.
possible messages
A small change to a message should change the hash value so much that
it does not look correlated at all with the old hash value
MD5
SHA-256 - recommended
SHA-384
SHA-512 - recommended
2. Memory management
The notion of process is quite important, and you need to know what the
A program is the code that you write, the sequence of instructions (and
possibly data). ∙
by a computer.
same program, e.g. some web browsers start a process for each open window.
Abstraction in OS
Virtualisation:
The OS kernel
Modern operating systems have many different functions. The core functions is
The kernel implements process called ‘Timesharing’, this allows a single CPU to
process A into Ready state and switch B into Running state, else, just handle
kernel mode and calls interrupt handler in the OS. OS can then switch processes
or kill processes. E.g. in Windows task manager if program not responding, can
Managing processes
be in one of 3 states
Challenges:
Performance:
overhead
Control:
Limited Direct Execution – Limiting access to the CPU as well as the I/O
But what is the main reason for virtualizing the memory in Limited Direct
Execution?
processes
When application code runs directly on the CPU. This creates problems like
“How to restrict what the program can do without affecting efficiency?” or “How to
Kernel mode: code is run without any restrictions. OS runs in kernel mode.
User mode: Only a limited subset of instructions can be used, E.g. no I/O
Without I/O instructions, a process cannot simply access parts of the computer
e.g. the network, record sound, manipulate mouse, access hard disk.
System calls:
Special CPU instructions that let user mode call OS functions e.g.
Allocate memory
Software Interrupts
happened
1. CPU has user and kernel mode in order to control I/O and memory access
operations
interrupts
Process Scheduling
Policies that the OS uses in order to switch between processes. The OS needs
to decide how long each process gets to use the CPU before it switches to a
different process.
First-come first serve – Processes take turns, average turnaround time high, as
processes get roughly equal access to the CPU. Problem however, some
processes may be more important than others and is more important, e.g.
playing a video.
Learning Objectives:
1. Name and describe the functions of the different layers of the Internet
Model
3. Understand and analyze the HTTP and SMTP application layer protocols
Network Components:
Types of networks:
can communicate with each other without going through a router. Speed
and BNs across locations, e.g. across a country. This network is usually
In most cases, a client will communicate with a server, and they together provide
an application to the user. There are four main tasks application to perform:
Data access logic – how application manages its data. E.g. updating data
something
allowing multiple users to work on the same files together. In this architecture,
the client performs the presentation and application logic, while the server
while the server performs the rest. This is common is web applications where
webpages renders the page to users screens, but any action the user does is
each other with each client implementing all aspects of the application.
2. Data link layer - defines the interface between hardware and software.
3. Network layer – responsible for routing, decides which path a packet takes
Protocol Data Units – A formal language that defines how two applications talk to
The World Wide Web – The largest application layer besides electronic mail
HTTP – a standard set of commands that is understood by all web browsers and
servers
Request-response cycle
Electronic Mail
Simple Mail Transfer protocol (SMTP) – sender uses the protocol to send a
message to a mail server. This forwards to the recipients mail server. The
recipient then uses either the Post Office Protocol (POP) or the Internet Message
Learning Objectives:
Look at Media Access Control (Data Link layer): when is a device allowed
to transmit?
link layer:
address)
Network Cables:
Physical Layer:
signals (copper wires), radio waves (air), and light signals (optical fibre).
Digital data: Discrete values like 0 and 1, or alphabets. Steps from one symbol to
Transmission types:
Analog FM radio
Digital transmission:
Digital signals are typically transmitted through copper cables. It encodes 0s and
positive voltage
Bipolar encoding – Use both positive and negative voltage to achieve bigger
difference in signal
Analog transmission:
Amplitude = volume
In order to transmit data using analog waves, we can simply modify each of
these parameters.
A high frequency
is interpreted as
Multiple different amplitudes and phases allow for packing of more data. By using
four different amplitudes and two different phases, we can now encode a unit
Modems
The process of turning digital data into analog signals is called modulation, the
modem.
MAC tries to solve the problem that only one device is allowed to transmit at the
2. Contention-based MAC
Ethernet
Original Ethernet technology is implemented through a single large cable that all
devices were connected to. Nowadays Ethernet mostly uses UTP cables
(cable)
the network, if it detects any other signal other than its own signal, it
the frame and transmits a jam signal instead, telling all other devices that
To solve the problem of two devices both detecting a collision and start a signal
device waits a random amount of time before re-transmitting, allowing the latter
to go first.
Original Ethernet LAN was implemented through a shared bus topology where all
devices share a single bus. A consequence of this approach is that all devices
receive all messages, even the ones that were not meant for them. Because of
this, each device needs a destination address, when all devices receive the
message, each device checks whether the destination address equals its own
address. Only the intended recipient will process the message and other devices
discard it. Each LAN would use a unique address, a MAC address, usually
something happens, the entire network would be affected, hence a star topology
is created. The central component was a hub. This made the network behave as
if all computers
were still
connected to a
makes it so the
signal it receives
Damaging frames.
with switches.
Switched Ethernet
star topology, this mean that the circuit is no longer shared, and messages are
sent directly from one device to another, rather that broadcasting them to the
entire network. The device that enables this kind of networking is called a switch.
must know who to send it to. A switch works by first sending a broadcast
message to all ports, but before broadcasting the frame with the destination MAC
address, it also broadcasts the source MAC address. The switch stores this info
message, B delivers its source MAC address as well, allowing the switch to know
that B is connected to port 1. This way after a single frame from each connected
device, the switch has learnt all the MAC addresses and does not have to use
broadcasting anymore.
Radio waves are used to communicate, There are 2 main bands that WLAN
devices use, 2.4 GHz, and 5GHz. Higher frequencies mean higher transmission
rates, however that have stronger attenuation, meaning that they become weaker
WLAN Topology
The simplest possible setup for a wireless network is just a number of devices
original shared Ethernet besides having no central hub. A device sends a frame
into the network, and the receiver identifies the frame by checking the destination
MAC address. However most wireless networks use a central Access Point (AP):
This is an infrastructure BSS. The access point is connected to the rest of the
network using cable-based Ethernet. All communication is done through the AP.
This means if clients want to communicate, they have to send the frame to the
AP which then relays to the latter, like a hub. Still, all devices can hear all
We can connect multiple BSS to form an Extended Service Set (ESS). Multiple
access points work together. They are all connected to the same cable-based
network, and have been installed so that the areas that they cover overlap. They
Each access point can cover an area of maybe 50x50 meters depending on the
technology, frequency used, material of walls etc. As soon as the signal is too
weak between an AP, the laptop will switch connections automatically. This
occurs entirely on the data link layer, meaning that higher layers wouldn’t even
WLAN MAC
own transmission until the other transmission has finished. However, there is a
problem with this. If two laptops are on the opposite side, the AP in the middle
receives no problem, however the opposite laptop signal has become too weak
WLAN device will wait for an acknowledgement from the AP that the frame
the device knows something has gone wrong. If both devices keep re-
longer.
Controlled access. The device can send a short request to send (RTS)
message to the AP, after getting a clear to send (CTS), the device will
Week 10: TCP/IP, network and transport layers, and the Internet
Learning Objectives:
Look at Media Access Control (Data Link layer): when is a device allowed
to transmit?
Enable routing
IP addresses
Every device that needs to send/receive or route messages require at least one
IPv4 addresses is version 4 of the internet protocol and is 32 bits long and
two bytes identify a network. The next two bytes identify the subnet. Subnet
mask is a way to tell us how many bits of an IP address are used for the network
plus subnet identifier. E.g. for our example, 24 bits identify the network and
subnet, so we can write the AP including its subnet mask as 130.194.66/24. The
subnet mask tells us which part of an IP address identifies the network and
subnet, and which part identifies the device inside the subnet.
In general, each subnet corresponds to a single LAN, meaning all devices inside
a LAN should belong to the same subnet. Let us assume that all the subnet
130.194.76.191, it can see that the first 24 bits with the destination address is the
same, meaning they have the same subnet, in this case the client sends the
wants to send a packet to 130.194.66.42. The first 24 bits are different, the client
must then send the packet to a router in the .76 subnet, making it the routers job
to deliver the packet. This kind of network structure is very common, where
different
LAN’s are
connected
using
routers to a
backbone
network.
IPv4 addresses are not enough to hold the world’s addresses in the future, so
IPv6 are created and are 128 bits. The first 23 bits identify a Regional Internet
When an ISP requires a new block of addresses, the RIR provides this. The ISP
has to use the first 32 bits (23+9) it was given, then it can freely choose the next
identify subnets within its organization. The complete second half of the address
Address Resolution
computer needs to send a packet to its gateway router, how does it find out the
address
Many root servers delegate requests to servers for every top-level domain like
server until one of them knows the answer or can tell us that the name does not
exist.
This method is only required within a LAN. The MAC address is required
whenever we want to send a packet to a device inside our LAN. The Address
Resolution Protocol (ARP) comes in. The laptop sends an ARP request packet
as a broadcast; the router will then receive the packet and send a reply with its
MAC address.
Routing
The main function of the network layer. A router is a device that is connected to
multiple networks, and routing means to forward a packet from one network into
another. Without routers, internet would not function as there would just be a
huge collection of individual networks that cannot communicate with each other.
Routing Tables
Routers use routing tables to make the decisions where to send packets. A
routing table contains entries for different networks, and for each network it would
tell the router which other router can handle that network. Below is a network with
5 routers and their corresponding routing tables. Router A just contains a default
gateway, meaning it needs to send to gateway C for any packet whose location
is outside its own LAN. For A to send a packet to H, iterative DNS occurs where
Real routing tables cannot contain a list of all possible destination addresses (this
means routers would have to know EVERY single computer in the internet).
Instead, they map entire networks to destination routers. Routers use hierarchies
130.194.66.43. A router may check only the first two bytes 130.194.x.y and see
that any address with this 130.194 entry should be sent to router X. router X may
then look the next 8 bits and say any packet with prefix 130.194.66 should be
dynamically when the network changes. There are two types of dynamic routing
protocol:
to a network and the target router for that network. Router chooses the
path with fewest ‘hops’ through other routers. Protocols include EIGRP
network, measuring speed. So may choose path with more ‘hops’ but
Transport Layer
splits up application layer messages into short segments, making sure the
segments arrive correctly, and reassembles them in the correct order into the
original message at the destination. TCP is used by many major application layer
Addressing applications
to be an address at the transport layer too. Each application has a port number,
between a server and a client. The client picks a random port number for its
browser. Fixed server port is used to identify a web server application e.g. 80
How does TCP set up a reliable channel, by splitting up large application layer
messages into short chunks and to make sure these packets arrive correctly?
Data Link Layer, meaning that the receiver must acknowledge every packet, and
if it is not acknowledged within a certain time-out, the sender will send it again.
A typical TCP session between a client and a server consists of three phases.
Client send a special SYN (synchronize) packet to the server with a completely
choosing its own random sequence number, 734 and the clients sequence
number +1. Finally, the 3-way handshake ends with client sending an ACK back
indicating it received it, and adding 1 to the server’s number. During the actual
transmission, both client and server can send data at any time.
Now the client sends 9 bits worth of data from 3186 and 3195. The server sends
an ACK packet when it received the 18 bytes, so it uses 3186+19 = 3204 as the
ACK number. The server knows it received all the data so sends a “thanks!”
message to the client, which is 7 bytes. The client acknowledges this by replying
ACK with 735+7 = 742 and sends FIN (finalize) packet. The server
acknowledges this by adding 1 to the FIN number, then replies with FIN packet
The internet
The internet is a collection of all devices running the TCP/IP protocol connected
Learning Objectives:
Be able to explain the role of TLS and HTTPS in the TCP/IP stack
Malware
Security Protocol
Every layer in the Internet model consists of a main protocol. There is a security
Protocol Layer
HTTP Application
TLS- Transport Layer Security
TCP Transport
IP Network
Ethernet Data Link
Physical
SSL/TLS
Transport Layer Security (TLS), and its predecessor Secure Sockets Layer
computer network. Main aim is to provide privacy and data integrity between
two communicators.
To create the shared key, process called “Diffie –Hellman key exchange” is used
certificate contains
Subject name
Issuer name
Trusted Certificates
automatically reveals websites with these certificates when browsing the internet.
Certification revocation
Firewall – Form of security that filters traffic, defines what can get through and
what is blocked
Packet filter firewall – Operates on Network layer, filters traffic based on source
Works by inspecting the first few bytes TCP in an IP packet and identifies
destination port.
address
The internal network should not be directly accessible, but web server or mail
These are not direct security functions, but hides information from outside
attackers
Social networks
Monitors networks and system activities. Alert when potentially malicious activity
activities
Monitoring examples
Find anomalies
Reaction examples
detection. Signature-based is fast, generally less false alarms, and does not
Privacy issues