You are on page 1of 66

Networked Systems 3 - Notes

Lecture 1: Introduction to Networked Systems

What is a Networked System?

A Networked System is comprised by multiple, autonomous computing devices which
exchange data in order to perform some application goal. This exchange is explicitly
visible to the application. The system is aware of the network.

List some applications of Networked Systems

Digital Broadcast TV
Mobile Voice Telephony
Controller Area Networks that connect sensors with vehicles/aircrafts
Sensor Networks

List the properties that describe a Networked System.

The means of communication between systems across the network
The interconnection between the links that build a Wide Area Network (WAN)
The ways with which the information is exchanged across a single link

How are the messages transferred in a Networked System?

The messages whose size can be bounded are transferred from source to destinations
using a communication channel.

Which kinds of communication channels exist?

Simplex Communication: Sends information in one direction only
Half-Duplex: Sends information to both directions but not simultaneously
Full-Duplex: Sends information to both directions at the same time

Which is the purpose of the messages that are transferred in a communication

The messages that are transferred in a communication channel convey information.

Is the capacity of these channels unlimited?

No, there are physical limits that restrict the capacity of a channel.
Which is the physical form of a message?
physical form of a message is a signal which can be either a material object (e.g.
CD) or a wave (e.g. sound, light).

Which are the two types of signals?

Analogue: A smooth continuum of values
Digital: A sequence of discrete symbols

What is coding?
Coding is the mapping of information to symbols.

Describe the characteristics of Analogue Signals.

In their simplest form, their amplitudes directly code the values of interest
They can be arbitrarily accurate
They can be easily affected by noise and interference on communication channel
It is difficult to process them using Digital Electronics
They can be represented digitally
Applications: AM Radio, Analogue Telephones

Describe the characteristics of Digital Signals.

They comprise a sequence of discrete symbols from a fixed alphabet, not
arbitrary values.
Their underlying channel is almost always analogue
They use modulation to map a digital signal onto the channel
The systems that use them often use non-binary encoding (either 16, 64, 258
possible symbols)
We use the baud rate to calculate their speed

What is baud rate?

Baud Rate is the number of symbols transferred per second in a Networked System.

How is a signal conveyed via a channel?

Directly: Via electrical signals in a cable
Indirectly: By firstly being modulated onto an underlying carrier (e.g. Radio)

How is a link formed?

It is formed by the combining a signal and a communication channel.
What does a link do?
A Link connects one or more hosts, directly. Several links connected together form a

What is the name of the devices that are connecting these links?
The name of the devices that are connecting these links together in a network are called
either switches or routers, depending on the type of the network.

What is a Circuit Switched Network?

A Circuit Switched Network comprises of a circuit that is set up to accomplish the
communication between a Device A and a Device B which are exchanging messages
of arbitrary length. This circuit has a guaranteed capacity. It is able to block other
communications in the network since the the network capacity is limited.
Application: Traditional Telephone Network

What is a Packet Switched Network?

A Packet Switched Network transfers messages that are split into many packets
before they are transmitted. These packets are small and have a size constraint. It
allows multiple communications at the same time, sharing the bottleneck link. The
connectivity in such a system is guaranteed but the available capacity varies since it
depends on the number of people that are using the network.
Application: Internet

List all the basic components that build a Networked System.

Hosts: The source and destination(s)
Links: Physical realisation of the channel that conveys messages
Switches/Routers: Devices that connect multiple links

What is the purpose of Network Protocols and where are they layered?
Network Protocols give meaning to the messages that are exchanged and they are
layered on the top.
Lecture 2: Protocols and Layers

When does communication occur?

Communication occurs when two (or more) hosts exchange messages across a

When are these messages meaningful?

The messages that are exchanged throughout a network are meaningful when they
follow some well-known syntax and have agreed semantics.

What is a network protocol?

A network protocol is an agreed language for encoding messages along with the rules
defining what messages mean and when they can be sent. They define the behaviour of
a network. A large number of network protocols exists.

What is the difference between the different network protocols?

The difference between the different network protocols is on where they operate. Some
of them operate between hosts, some between routers and some between hosts and

What does a network protocol comprise?

A network protocol comprises different types of message which are known as Protocol
Data Units (PDU) which have their own syntax and semantics.

Describe a Network Protocols syntax.

It comprises different types of PDUs; each with a particular syntax
It describes which information is included on a PDU and how it is
PDUs can be formatted as either textual information or as binary data
Textual PDUs:
They have grammar and syntax that describes their format
(like a programming language)
Examples: HTTP/1.1, SMTP, SIP, Jabber
Binary PDUs:
They have similar rules that describe their format
Big Data or Little Endian
32 or 64 bit
Fixed or Variable Length
Alignment Requirements

Describe a Network Protocols semantics.

A Network Protocols semantics define when PDUs can be sent and what
response is needed.
Who can send PDUs
When PDUs can be sent
Roles for the hosts (e.g. Peer-To-Peer, Server & Client)
What are the entities that communicate and how they are named
How errors are handled
Semantics are commonly described using State-Transition diagrams
States indicate stages of protocol operation
Transitions occur in response to PDUs and may result in other PDUs
being sent

What is protocol layering?

Protocol Layering is a way to organise communication systems as a series of protocol
layers which provide well-defined interfaces. Each of the layers offer services to the
next higher layer which is implemented using the services of the lower layer. It is a
structured design that helps in reducing complexity. The lowest layer is the physical
communications channel and the highest level is the communicating application.

How does a network layer i work?

The peers in a network layer i communicate via layer i protocol, using lower layer

Open Systems Interconnection Model (OSI) Reference Model:

Order (from the Highest Level to the Lowest Level):
1. Application
2. Presentation
3. Session
4. Transport
5. Network
6. Data Link
7. Physical Layer
Open Systems Interconnection (OSI) Model Reference Schema:

Physical Level:
It defines the characteristics of the cable/optical fibre or the properties of the wireless
link used.
(i.e. size/shape, maximum length and type for cables/optical fibres and radio frequency,
transmission power, modulation scheme and type of antenna for wireless links)

Data Link Layer:

It structures and frames the physical layer bit stream by splitting it into messages and
detecting errors on them. It also performs Media Access Control which assign
addresses to hosts on the link and accesses the link arbitrarily to determine when hosts
are allowed to send messages. It also ensures fair access to the link and controls the
flow so that no hosts are overwhelmed.
(Example: Ethernet, 802.11)

Network Layer:
It interconnects multiple links to form a Wide Area Network (WAN) from source host to
destination host. It is responsible for data delivery, naming and addressing, routing and
admission/flow control.
(Example: IP)

Transport Layer:
It transfers data between a session level service at the source and the corresponding
service at the destination (End-to-End Transfer). Amongst others, It provides reliability,
ordering, framing and congestion control.
(Example: TCP)

Session Layer:
It manages multiple transport layer connections.
(Examples: Use of TCP/IP connections to transfer a website using HTTP, Use of SMTP
to transfer several messages over a single TCP/IP connection)

Presentation Layer:
It manages the conversation, representation and presentation of data. It deals with the
character sets and languages, the data markup languages, the data format conversion
and the content negotiation.

Application Layer:
It deals with the User Application Protocols but not the application programs
(Examples: Facebook API, Web Services, Grid Computing)

What is a protocol standard?

It is a formal description of a network protocol. Its main purpose is to ensure the
interoperability amongst the different implementations of each protocol.

Describe the different procedures followed during the setup of a protocol

Open VS Closed Standards Development Process
Free VS Restricted Standards Availability
Individual VS Corporate VS National Membership
Leading Technical Development VS Documenting Existing Practise
Lecture 3: Communications Theory

How are signals conveyed?

Sender varies a physical property of the channel over time and Receiver measures that
property. This property is either the voltage/current in an electric cable or the modulation
of a radio carrier. This operation can be modelled as a mathematical function f(t) where
t is the time and f(t) shows the variance of this property (Time Domain View).

What is the signal bandwidth?

Signal bandwidth is the transfer rate of data within a channel. It acts as the proxy for
information content. More complex signals convey more data but the amount of
information conveyed via this data depends on the efficiency of the encoding used.

How many ways of information encoding for transmission are there?

There are various ways to encode information for transmission which are either more or
less efficient in terms of data preservation.

More complex signals -> Higher Frequency Component -> Greater Bandwidth

What is Fourier Analysis?

Fourier Analysis is a mathematical method to derive frequency domain representation of
a signal. It states that every well-behaved periodic function can be constructed by
summing a series of sines and cosines waves of varying frequency and amplitude. The
difference between the highest and the lowest frequencies in this function is the signal

What is the use of producing a frequency domain view for a given channel?
Frequency Domain View lets us visualise the information content of a signal. Greater
amount of information leads to higher frequency components on the view.

What happens if someone limits the frequency range in a channel?

Limiting the frequency range of a channel distorts the signal since the signal content
itself defines the frequency range.

Do real channels offer unlimited bandwidth?

Real channels cannot offer unlimited bandwidth since there are fundamental limitations
based on the physical properties of a channel and the design of its end-points. A
channel can only convey a limited amount of information per unit time.
What is the Channel Bandwidth?
The Channel Bandwidth, denoted H, measures the frequency range (measured in Hz) it
can transport.

What does the Sampling Theorem state?

According to the Sampling Theorem, in order to accurately digitise an analogue signal,
one needs 2H samples per second, where H is the bandwidth of the signal. It builds on
the assumption that the channel is noise-free.

Maximum Transmission Rate:

Rmax = 2H log2 V
where Rmax is measured in bits per second and V is the number of discrete values per

What is the noise in a channel?

Real world channels are subject to noise which is a cause for the corruption of a signal.
It creates additive interference.

What can cause noise in a channel?

Electric Interference
Cosmic Radiation
Thermal Noise

What is the Signal to Noise Ratio?

It is the ratio of the Signal Power (S) over the Noise Floor (N) in a channel. It is
typically quoted in Decibels (dB) but not directly.
dB = 10 log10 S/N

Which is the capacity of a Noisy Channel?

The capacity of a noisy channel depends on the type of noise that it exists within the
channel. Noise can be either uniform or bursty; it can affect either some or all the
frequencies of a channel.

What is Gaussian Noise?

Gaussian Noise is a simple model that assumes uniform noise that impacts all
frequencies equally.
Maximum Transmission Rate of a Channel subject to Gaussian Noise:
Rmax = H log2(1 + S/N)
Which are the factors that limit the amount of information that can be
The amount of information that can be transferred within a channel is limited by both the
Bandwidth of the channel and the noise of the specific channel. These limits might be
reached but not exceeded.
Lecture 4: Physical Layer

What is the Physical Layer concerned with?

The Physical Layer is concerned with the transmission of raw data bits.

Which are the two different encoding techniques used?

Baseband Encoding
Carrier Modulation

Which are the physical characteristics of cables?

Size and shape of the plugs
Maximum cable length
Type of cable (Electrical Voltage, Current, Modulation)

Which are the physical characteristics of fibres?

Size and shape of the plugs
Maximum fibre length
Type of fibre (Single/Multi-Mode, Optical Clarity, Colour, Power Output,
Modulation of the Laser)

Describe the Unshielded Twisted Pair type of cable.

It uses two wires, twisted together in a spiral.
Each pair is unidirectional: Signal and Ground.
The twists reduce the interference and noise pickup (More twists -> Less Noise)
The cables can have length of several miles at low data rates.
Signal is becomes more sensitive to noise as the length of the cable increases.
Suitable for: Fast Local Area Networks (LAN), Slow Wide Area Networks (WAN)
Examples: Ethernet, Telephone Lines

Describe the Coaxial type of cable.

The wire core (signal path) is surrounded by a layer of insulation with a braided
outer conductor (ground shielding).
Each cable is a unidirectional data path.
It offers better noise resilience than the Unshielded Twisted Pair type of cable.
It can operate with higher data rates over longer distance.
It is very expensive.
Suitable for: Fast Local Area Networks (LAN)

Describe the Optical Fibres.

They are consisted of glass core and cladding, contained in plastic jacket for
They are somewhat fragile.
They act as a unidirectional data path: transmission laser at one end and a
photodetector at the other.
Optical Fibres are not sensitive to noise since light is not affected by
electromagnetic interference.
They have very high capacity.
They are very cheap to be manufactured.
They need relatively expensive lasers to operate.
Suitable for: Fast Wide Area Networks (WAN)

How is the signal encoded into the channel in Wired Data Transmission?
The signal is encoded directly onto the channel in Wired Data Transmission. It usually
occupies a single baseband channel. The voltage in an electric cable and the intensity
of light in an optic fibre varies. Multiple digital coding schemes are used which have
different complexity and resilience to noise.

List some digital coding schemes.

Non-Return to Zero (NRZ) Encoding
Non-Return to Zero Inverted (NRZI) Encoding
Manchester Encoding
4B/5B Encoding

Describe the Non-Return to Zero (NRZ) Encoding.

NRZ Encodes a 1 as a High Signal, 0 as a Low Signal.
There are some limitations with runs of consecutive same bit:
Baseline Wander (The x-axis of the signal appears to wander up and
down, instead of staying still. That causes the signal to shift from its
normal base.)
Clock Recovery

Describe the Non-Return to Zero Inverted (NRZI) Encoding.

NRZI encodes 1 as Change in Signal Value and 0 as a Constant Signal.
Solves the problems with consecutive 1s but does nothing with consecutive 0s.
Describe the Manchester Encoding.
Encodes 1 as a high-low signal transition and 0 as a low-high signal
Doubles the bandwidth needed
Avoids the problems with NRZ Encoding
It is fairly inefficient since only the 50% of the link capacity is actually used

Describe the 4B/5B Encoding.

Builds on the Manchester Encoding.
Inserts extra bits to break up sequences of the same bit.
Each 4-bit data symbol is changed to a 5-bit code for transmission
The above process is reversed at the receiver.
80% of the link capacity is used.

How is the signal encoded into the channel in Wireless Data Transmission?
Wireless links use Carrier Modulation rather than baseband transmission.

What are the factors that affect the performance of the signal encoding in
Wireless Data Transmission?
Carrier Frequency -> Affects the data rate and the propagation of the signal)
Transmission Power
Modulation Scheme
Type of Antenna

Describe the Carrier Modulation Encoding.

Carrier wave applied to channel at frequency C.
The signal is modulated onto the carrier. It is shifted from baseband to the carrier
Allows multiple signals on a single channel.
The carriers are spaced greater than bandwidth of the signal.

Describe the Amplitude Modulation (AM).

Encodes the signal by varying the amplitude of the carrier wave.
It is simple.
Has poor resistance to noise
Describe the Frequency Modulation (FM).
Encodes the signal by varying the frequency of the carrier wave.
It is more complex than AM.
Has more resistance against the noise.

Describe the Phase Modulation (PM).

Encodes the signal by varying the phase of the carrier wave.

How can we handle the transmission of more than one bits per baud?
More complex modulation schemes allow more than one bits to be sent per baud.
These enable the use of multiple levels of the modulated component and the
combination of modulation schemes. Extremely complex combinations of schemes are
usually used.

How can we handle the prone to interference that single frequency channels
This prone to interference that single frequency channels have can be mitigated by
repeatedly changing the carrier frequency for multiple times per second because the
noise is not very likely to affect all the frequencies. Each carrier frequency that is
selected for every specific time slot is chosen by using a pseudo-random sequence.
This process is kept as a secret between the sender and the receiver.
Lecture 5: The Data Link Layer

What is the purpose of the Data Link Layer?

The Data Link Layer provides arbitrary access to the Physical Layer. It identifies the
available devices and addresses them (Addressing). Additionally, it structures and
frames the raw bitstream so that it turns into a structured communications channel while
it detects and corrects any bit errors. Finally, it controls the access to the channel.
(Media Access Control).

What is Addressing in Networking?

Addressing is the process when all the devices in use are assigned to a name/address
in order to be identified within the Network.

List the two different types of Physical Links.


What is a Point-To-Point Physical Link?

A Point-To-Point Physical Link is a permanent link between two endpoints.

What is a Multi-Access Physical Link?

A Multi-Access Physical Link is a link to which multiple hosts are attached. Wireless
links are common examples of Multi-Access links but several hosts can also be
connected to a single cable to form a Multi-Access wired link. This type of link requires
host addresses to identify senders and receivers.

List the two different types of Host Addresses scope.


Describe a Link-Local scope Host Address.

Unique amongst the host connected to a specific link
Its scope is restricted to the boundaries of the link
Overcomes any privacy concerns
May Need change when connected to a different link
Describe a Global scope Host Address.
Unique and widely identified address between every link
Simpler to be implemented if the devices can move since it does not need to
change when it is connected to a different link
Leads to some privacy concerns

Why is Framing and Synchronisation necessary?

Physical Layer provides unreliable raw bit stream and that means that the bits that are
transmitted might be corrupted and the timing can be disrupted. So, the Data Link Layer
is responsible to correct these problems.

What is Framing?
Framing is a function provided by the Data Link Layer. It breaks the raw bit stream into
frames, transmits and repairs the individual frames and, finally, limits the scope of any
transmission errors.

List the components that comprise a Frame.

Start Code (Synchronisation and Timing Recovery)
Header (Host Addresses and Control of Information)
Data (Network Layer Protocol Data)
Error Detection

List the different ways to detect the start of a message and state the
problems/benefits related with the use of each.
Leave gaps between the frames
Physical Layer cannot guarantee timing
Precede each frame with a length field
Length can be corrupted during the transmission
Add a special start code (= a unique bit pattern) at the start of each frame
Enables synchronisation after an error occurrence:
Wait for next start code
Begin reading frame headers

List some of the qualities of a good start code.

Must not appear in the header, data or error detecting code
Must allow time recovery (Time is measured by the receiver)
Should generate a regular pattern after physical layer coding

When is Bit Stuffing needed?

Bit Stuffing is needed when start code appears in the data. It is a way to ensure that the
channel is transparent.

Describe the process followed during Bit Stuffing.

Sender sends a 0 bit after sending 5 consecutive 1s, unless it sends the start
If the Receiver sees 5 consecutive 1s, it looks at the sixth bit:
If the sixth bit is 0:
Bit Stuffing has taken place -> Removes 0
If the sixth bit is 1, it looks at the seventh bit:
If the seventh bit is 0:
Start Code
If the seventh bit is 1:
Corrupt Frame

How are errors caused in the Physical Layer?

Noise and Interference at the Physical Layer can cause bit errors. These errors are very
common in the Wireless systems but rare in the wired links.

How can errors be overcome in the Data Link Layer?

Errors can be overcome in the Data Link Layer by using error detecting code in each

List some common error detecting codes.

Parity Code (Detects all single bit errors) - Simple to be Implemented
Internet Checksum (Detects many multiple bit errors) - Simple to be Implemented
Cyclic Redundancy Code (CRC) (Fewer Undetected errors) - More Complex and

Describe the process followed by the Parity Code.

It is the simplest error detecting code
Makes use of the parity of data:
Count the number of 1 bits in the code:
Calculate the Parity of data (XOR of data bits)
If the number of 1 bits is even:
Parity: 0
If the number of 1 bits is odd:
Parity: 1
Transmits data with their Parity
Checks at the receiver

Describe the process followed by the Internet Checksum.

Sums data values
Sends them as a checksum in each frame
Receiver recalculates the checksum
If the two checksums correspond:
No errors
If there is a mismatch:
There is a bit error

Why are error correcting codes also necessary?

Error Correcting codes extend the error detecting codes and they are added as part of
the frame body. They allow the receiver to correct some of the errors without contacting
the sender. They are not the only means of repair; retransmission can be requested.

Describe the Hamming Code.

A very common and simple error correcting code
Sends n data bits and k check bits for each word
Each check bit codes parity for some data bits
Corrects all single bit errors

List the trade-offs of the different error correcting codes.

Amount of data added
Ability to correct multi-bit errors
Lecture 6: Media Access Control

How is the arbitrary access to the link accomplished in Point-To-Point links?

Point-To-Point links are usually comprised of two unidirectional links with separate
physical cables for each direction. Each of these directions needs framing but there is
no contention for the link. Automatic Repeat Requests (ARQ) with stop-and-wait or
sliding-window are used for the flow control.

What is Sliding-Window?
Sliding-Window is a protocol that is a feature of packet-based data transmission
protocols. It assures that the delivery of packets is done, reliably, in the appropriate
order. Each portion of the transmission is assigned a unique consecutive sequence
number. These numbers are used by the receiver to place the received packets in the
correct order, discarding duplicate packets and identifying any missing ones. There is
no limit on the size of the sequence number that can be required.

What is Stop-And-Wait?
Stop-And-Wait is a method used to send information between two connected devices. It
is a special case of the Sliding-Window protocol. It ensures that no information is lost
during transmission due to dropped packets and that packets are received in the correct
order. A Stop-And-Wait request sends one frame at a time. After sending each frame,
the sender does not send any other frames until it receives an acknowledgement (ACK)
signal. After receiving a frame, the receiver sends an ACK. If the ACK is not received
before a certain time (timeout), the sender sends the same frame again.

How is the arbitrary access to the link accomplished in Multi-Access links?

Multi-Access links usually share a bidirectional link with a single physical cable or radio
frequency for both directions. Nodes contend for access to the link.

When does a collision occur?

A collision occurs if two hosts transmit simultaneously and their signals overlap. The
product that is received from a collision is pure garbage. Collisions are very likely since
systems with multiple hosts are contention-based.

What is the purpose of the Media Access Control (MAC) protocols?

The Media Access Control (MAC) protocols avoid and manage collisions in a network.
List the different types of Media Access Control (MAC) protocols along with some
of their implementations.
Contention Based (ALOHA, CSMA/CD)
Token Based (Token Ring)
Slotted (TDMA)

List the differences between these types of protocols.

Degree of Fairness
Access Policy

What is a contention-based system?

A Contention-Based system is a system that is designed in such way so that multiple
hosts share a channel in a way that can lead to collisions.

Describe how a Contention Based Media Access Control protocol works.

Listens to the channel while/before sending
Detects whether a collision occurs/will occur
If no collision:
Send frame
If there is a collision:
Delay is randomised and increased to prevent repeated
Can be arranged to give priority to certain hosts/users/traffic
Retransmit data according to an algorithm to avoid/resolve a
It is built on probabilistic, variable latency access to the channel
It is cheap to be implemented
Hardware more readily available
Cannot guarantee real-time performance
Example: The ALOHA Network

What is the ALOHA Network?

A wireless network developed at the University of Harvard in 1970
The first wireless packet switched network
It used the simplest Contention-Based MAC
Data transmission is attempted whenever data is available
If a collision occurs:
Waits random amount of time
Repeats until successful transmission is achieved
Simple Implementation
Poor performance
Low channel utilisation
Long delays

Describe how Carrier Sense Multiple Access (CSMA) works.

A Contention-Based protocol
When propagation delay is low:
Listens before sending
If another transmission is active:
Backs-Off (As if a collision had occurred)
If link is idle:
Sends data immediately
Improved utilisation
Active transmissions are not disrupted
Only the new sender needs to back-off if the channel is active
Poor Worst Case Performance due to the arbitrarily long delays and
unpredictable variation caused by the repeated collisions
It is cheap to be implemented
Hardware more readily available
Cannot guarantee real-time performance

Describe how Carrier Sense Multiple Access with Collision Detection (CSMA/CD)
A version of the Carrier Sense Multiple Access (CSMA) but with Collision
Builds on the fact that the highest the propagation delay is, the collision rate is
Listens to the channel before and while transmitting data:
If a collision occurs:
Packets are corrupted
Stops sending
Back-off Interval is random
Avoids deterministic redundant collisions
Should increase with the number of collisions that
affect a transmission:
Repeated collisions lead to signal congestion
Reducing the transmission rate will
allow the network to recover
Initial Back-off Interval:
x seconds 50%
Interval for each repeated collision before success:
2x seconds 50%
Back-off Interval is random
The time for which the channel is blocked due collisions is reduced
Better performance than the plain Carrier Sense Multiple Access (CSMA)
Poor Worst Case Performance due to the arbitrarily long delays and
unpredictable variation caused by the repeated collisions
It is cheap to be implemented
Hardware more readily available
Cannot guarantee real-time performance

Describe how the Token-Based protocols work.

A token is circulated by the hosts when they have no data to send
Whenever a host wants to send a packet:
Waits for the token
Removes the token
Sends the packet
Restarts the token circulating
Token circulation enforces round robin transmission
Bounds the maximum wait time before host can transmit
Enforces fairness between the hosts of the ring
Reduces utilisation
It is expensive to be implemented
Hardware less widely available
Offers Stricter Performance Guarantees
Example: IBM Token Ring

Describe how the Slotted Media Access Control (MAC) works.

Split the channel access into transmission slots
Controller assigns each host with a transmission slot
A limited but guaranteed capacity is given to each sender
Delay variation due to channel access is limited
Fairness guarantee is provided
It is expensive to be implemented
Hardware less widely available
Offers Stricter Performance Guarantees
Example: GSM Mobile Phones

List and explain the two different types of Slotted Media Access Control (MAC).
Time Division Media Access (TDMA) - Controls when hosts can transmit data
Frequency Slots - Controls which frequency bands hosts use to transmit data
Lecture 7: Bridging

List the drawbacks from the use of a single link as assumed by the Media Access
Limited scalability of a system
Vulnerable to cable damage
Vulnerable to disconnection

What is a hub?
A hub is a cable in a box with no intelligence. It is a physical layer interconnection of
links (equivalent to running a longer cable). It does not improve the scalability of a
network but it eases the physical interconnection of cables/devices. Damage to its
vulnerable cables disconnects only a single host rather than partitioning the whole
network. It is largely obsolete at the moment since it was replaced by data link layer

What is a bridge?
A bridge is an intelligent device that understands and process data link layer frames,
identifies the location of hosts and forwards only the frames of interest. It also
understands the Media Access Control (MAC) protocol and joins multiple links together.
It needs zero configuration (Automation).
Example: Ethernet Switch

Describe how a bridge works.

Learns addresses on each link
Observe source addresses of packets
Graceful response to failure and node mobility due to Soft state time-out
Ensures that the knowledge of failed/disconnected devices
Forwards traffic as appropriate
Unicast Traffic based on host locations
Hashes from address to destination link
Flooding packets to unknown hosts
Multicast is based on group membership
Broadcasts traffic
Based on a learning protocol
All the hosts are found without any configuration
Flooding ensures that the connectivity is maintained even when protocol has no
Performance is always better than a hub
Poor scalability
Every bridge knows about every host

When does a loop occur in a Bridged Network?

In a Bridged Network, a loop occurs when packets are crossed in transit between two
bridges due to the fact that the host that the packet is going to be sent to does not exist.
This can be avoided by taking the appropriate countermeasures.

What is a Spanning Tree?

A spanning tree over a graph is a tree comprising all the vertices and some of the edges
of an undirected graph G. Edges are removed to eliminate loops, leaving only the
minimal set of edges that still connect all the vertices. It is a way to model a network.

What is the Spanning Tree Algorithm?

A distributed algorithm to build a spanning tree
Developed by Radia Perlman
Each bridge has a globally unique address
Bridge with the numerically lowest address is the root bridge
Every bridge informs its neighbours about the address that it thinks that
corresponds to the root bridge
Bridges may potentially update what they think the root bridge address is
Determines the root port (the port with the shortest path to the root bridge) of
each bridge, except from the root bridge
Select a designated bridge (the bridge with the shortest path to the root bridge)
Define the designated ports (the ports that connect the designated bridges to the
Enables all root ports and designated ports and disables all the others
Traffic is forwarded using only the enabled ports
Lecture 8: Network Layer (1): Internetworking

Which is the role of the Network Layer?

It is responsible for end-to-end delivery of data across multiple link-layer hops and
technologies and multiple autonomous systems. It is the first layer in the Open Systems
Interconnection (OSI) Reference Model that is end-to-end. It builds an internet.

What is an internet?
An internet comprises a set of interconnected networks.
Each of these networks is an Autonomous System (AS)
They are administered separately by making independent policy
and technology choices.
A common end-to-end network protocol.
Provides a single seamless service to the Transport Layer
Delivers the data packets
Provisions circuits
Addresses the end systems
A set of gateway devices
Also known as Routers
Implements the common network protocol
Hides differences in the link-layer technologies
Flow Control
Error Detection/Correction
Performs the least amount of translation necessary

What is the Internet Protocol (IP)?

A packet delivery service that provides an abstraction layer.
Simple and Easy
Can run over any Link Layer type
Best effort
No guarantees provided
Time taken to transit the network may vary
Packets may be lost, delayed, reordered, duplicated or corrupted
Packets that cannot be delivered are discarded
No need to setup
Uniform Network and Host Addressing
Uniform End-to-End Connectivity (depending on the firewall policy)
Transports protocols and applications are located above it
All the assorted data link technologies and physical links are located below the
Responsible for addressing, routing, fragmentation and reassembly.
Fundamental Service: Can Simulate a circuit over packets but not able to
simulate packets over circuit

List all the versions of the Internet Protocol (IP) that have been released.
IPv4 - The current production Internet
IPv5 - It was assigned to the Internet Stream Protocol
IPv6 - The next generation Internet

What was the Internet Stream Protocol?

It was an experimental multimedia streaming protocol developed between 1979 and
1995 but is no longer used. It was assigned the IPv5 version of the Internet Protocol

Which are the differences in the packets between the IPv4 and the IPv6 versions
of the Internet Protocol (IP)?
The IPv6 has:
A simpler header format
Larger addresses
Support for Fragmentation removed
Flow Label added

What is the Internet?

The globally interconnected networks running the Internet Protocol (IP)
Initially designed by Vint Cerf and Robert Kahn in 1974
Hour Glass Protocol Stack
Range of Data Link Layer Technologies:
Single Standard Network Layer Protocol
Internet Protocol (IP)
Range of Transport and Application Layer Protocols
Transport Layer:
Application/Presentation Layer:

Describe how Addressing works in Network Layer.

Every network on every host is intended to have a unique address
They may change address over time to give the illusion of privacy
There is difference between what is addressable and what is reachable
due to the fact that firewalls exist in both IPv4 and IPv6
Length of Addresses:
32 bits for IPv4 (Lack of IPv4 causes problems)
128 bits for IPv6

Describe how Fragmentation works in Network Layer.

Data Link Layer has a Maximum Packet Size (MTU)
IPv4 will fragment every packet that exceed the Maximum Packet Size (MTU)
If the MF bit of the protocol is set:
More fragments will follow
Reconstructs using the Fragment Offset and Fragment Identifier
If the DF bit of the protocol is set:
No fragments take place
Large packets are discarded
IPv6 does not support fragmentation.
Very hard to be implemented for very high rate links
End-To-End Principle

Describe how Loop Protection works in Network Layer.

Packets include a Forwarding Limit
Set to a Non-Zero number when the packet is sent
This number is reduced every time the packet is forwarded by any router
When the number becomes 0, the forwarding stops and the packet is
Stops the packets circling forever, if a network problem occurs and causes a loop
It is assumed that the Network diameter is smaller than the initial value of
the forwarding limit

Describe how Differentiated Services work in Network Layer.

End Systems can request special services from the Network
Some operations such as Telephony or Gaming may require low latency
over higher bandwidth
Emergency traffic may need to be prioritised
Software updates that happen in the background might ask for low priority
These Services are signalled with the Differentiated Service Code Point
(DSCP) field in the Header
This signal provide a hint to the Network but not a guarantee
Often stripped out at the Network boundaries
Difficult Economic and Network Neutrality issues
How is able to send DSCP?
How much are they charged for doing so?
IPv6 provides a Flow Label to group related traffic flows together

Describe how Explicit Congestion Notification works in Network Layer.

Network Congestion usually forces the Routers respond with packet dropping
Best effort packet delivery service
Transport Protocols detect the loss and request a retransmission if
Explicit Congestion Notification (ECN) gives Routers a way to notify that a
Signal Congestion is approaching.
If ECN=00:
Explicit Congestion Notification is disabled
If ECN=10 or ECN=01:
Routers monitor Link usage
Routers can change the signal to ECN=11 to notify for a congestion
that is imminent
If ECN=11:
Host needs to reduce its sending rate
If it is not reduced, the congested router will start dropping

Describe how Header Checksum works in Network Layer.

IPv4 header contains a Checksum to detect transmission errors
It is conceptually similar to Link-Layer checksum
Different algorithm is used
Protects the IP header only, not the payload data
Data must be protected by an upper layer protocol, if it is needed
IPv6 header does not contain a Checksum
It assumes that the data are protected by a Data Link Layer checksum

Describe how Transport Layer Protocol Identifier works in Network Layer.

Network Layer packet carry Transport Layer data as their payload
The appropriate field is filled in to determine what Transport Layer Protocol is
going to be used and pass the data to this upper-level protocol
Field that contains this data:
IPv4: Upper Layer Protocol
IPv6: Next Header
Legal Values managed by the IANA
TCP = 6
UDP = 17
DCCP = 33
ICMP = 1

Which of the two versions (IPv4, IPv6) of the Internet Protocol (IP) should one
IPv4 has reached the end of its life as a protocol
Insufficient Addresses available
IPv6 Is intended to be a long-term replacement for IPv4
Increase the number of the Address size
Allow more hosts to be added on the Network
Not clear if it is going to be widely deployed
Straightforward to build applications for both the protocols
getaddrinfo() will return the IPv6 address if it exists, otherwise it will
return the IPv4 address; all other socket calls will use the returned value
New code should support both
Lecture 9: Network Layer (2): Addressing

List some of the characteristics of the IP Addresses.

They specify the location of a Network interface
They are allocated hierarchically
They are fixed length binary values
IPv4: 32 bits
IPv6: 128 bits

Are the Domain Names and the IP Addresses the same?

The domain names are a separate Application Layer namespace.

Describe the structure of an IP Address.

Its the same for both IPv4 and IPv6.
Addresses are split into a Network and a Host part
A netmask describes the number of bits in the Network part
The Network itself has its Host part equal to zero
The broadcast address for a network has all the bits of the Host part equal to one
Allow messages to be sent to all hosts on a network
A host with several network interfaces would have one IP address per interface
Example: a laptop with both Ethernet and Wi-Fi Network Interfaces

Describe the classes of IP Addresses.

IP Addresses used to be allocated so that their netmask was a multiple of 8 bits
Class A -> A /8 network (~16 million addresses)
Class B -> A /16 network (65536 addresses)
Class C -> A /24 network (256 address)
The above terminology was pretty inflexible and led to a large number of wasted
Arbitrary length for the netmask was allowed in 1993

How is the IP Address Management handled by the IPv4 version of the IP

232 addresses were available
IANA administers the pool of unallocated addresses
Initially, it assigned them to large enterprises and Internet Service
Providers (ISP)
Now, they are assigned to Regional Internet Registries (RIRs):
afriNIC for Africa
APNIC for Asia, Pacific
ARIN for North America
LACNIC for Latin America and Caribbean
RIPE for Europe, Middle East and Central Asia
Allocations were made for 224 addresses per time
Regional Internet Registries allocate addresses to Internet Service Providers
(ISP) and large enterprises within their region
ISP allocate the addresses to their customers
All the available addresses for IPv4 were allocated by 3 February 2011

How is the IP Address Management handled by the IPv6 version of the IP

2128 addresses are available
Written as : separated hexadecimal
A single run of consecutive zeros can be compressed to an ::
The local identifier part of an IPv6 address is 64-bit long
Can be derived from Ethernet/Wi-Fi MAC Address
If IPv6 is deployed, it would solve the address shortage for a long time
Routers advertise network part
Split into a global routing prefix (= routing goop) and a subnet identifier
Routing prefix of up to 48 bits
Hosts auto-configure their address

What are the issues that arise regarding the deployment of IPv6?
Changes to every single router, host, firewall and application are required
Host changes done in Windows, MacOS, iOS and on various Linux distributions
Backbone routers generally support IPv6
Most Home routers and Firewalls do not support IPv6 yet
Many applications have been updated accordingly

What is Network Address Translation (NAT)?

Network Address Translation (NAT) is a methodology of remapping one IP address
space to another by modifying Network Address information in Internet Protocol (IP)
datagram packet headers while they are in transit across a traffic routing device. It is
widely deployed for IPv4. It seems simple since it requires no changes in the hosts but it
is hugely complicated for peer-to-peer applications. In addition, it is very difficult to
debug problems or deploy new classes of applications.
Lecture 10: Network Layer (3): Intra-domain Routing

Which layer is responsible for the Routing of data?

The Network Layer is responsible for the Routing of data from source to destination
across multiple hops.

Describe the process followed during the Routing of data.

Nodes learn a subset of the network topology and run a routing algorithm to
decide where to forward the packets destined for other hosts.
Each host usually have:
A simple view of the topology (its local network, everything else)
A simple routing algorithm (if it is not on my local network, send it
to the default gateway)
Gateway devices usually:
Exchange network topology information
Decide the best route to the destination based on their knowledge

Describe the Unicast Routing process.

Routing Algorithms to deliver a packet from a source to a destination
The choice of the specific algorithm is done with respect to the usage scenario:
Intra-domain routing
Inter-domain routing
Politics and Economics

Describe how the Intra-domain Unicast Routing is done.

Routing within an Autonomous System (AS)
Single Trusted Domain
No policy restrictions on who can determine the network topology
No policy restrictions on which links can be used
Efficient routing desired
Make the best of the available network
Find the shortest path to the destination
Two approaches available:
Distance Vector - The Routing Information Protocol (RIP)
Link State - Open Shortest Path First (OSPF) Routing
Describe how the Distance Vector Routing works.
Each node maintains a vector containing the distance to every other node in the
This Vector is periodically exchanged with neighbours
Each node knows the distance to all other nodes
The Routing table converges on a steady state
Links which are down or unknown have distance equal to
DIstance metrics keep exchanging distance metrics, even after the
Routing table is completed, to handle topology changes
Packets are forwarded along the route with the least distance to the destination.

What is the Count To Infinity Problem?

The core of the Count To Infinity Problem is the fact that if A tells B that it has a path
somewhere, there is no way for B to know if the path has B as a part of it. A is taken
offline at some point. During the Vector Updating Process, the distance of the route
from B to A that it used to be x is down and B does not receive a vector update from A.
C that previously reached A through B is not aware of this change yet and keeps
sending updates to B with respect to its old distance from A and leads B to incorrect
updates. At some point B forwards an update to C according to its new incorrect value
and updates Cs value incorrectly. This leads to infinite routing loops.

Provide some solutions for the Count To Infinity Problem.

1. Define How Big is Infinity:
Give a value x to the so-called Infinity. This bounds the time to count to infinity
and limits the duration of disruption. Network should never be more than x hops
2. Split Horizon:
When sending a routing update, do not send route learn from a neighbour back
to that neighbour. This will prevent loops that involve 2 nodes but it wont affect
loops that involve 3 nodes.
There is no general solution; Distance Vector Routing will always suffer from slow
convergence due to Count To Infinity Problem.

Describe how the Link State Routing works.

Nodes know the links to their neighbours as well as the cost of these links (Link
State Information).
This information is routed on the start-up
They reliably flood this information to give all nodes a complete Network Map.
Every node directly calculates the shortest path to every other node by using this
information as the Routing Table.
The flooding of Link State data ensures that all nodes know the entire
topology of the network
Each node uses the Dijkstras shortest path algorithm to calculate an
optimal route to every other node
Packets are forwarded with respect to the shortest path
Shortest Path is recalculated on every rooting update
The Link State Information is updated and routed when the topology changes
Each of these updates contains:
Name of the node that sent the update
List of the directly connected neighbours of that node as well as the
cost of the link to them
A sequence number
Each receiver compares this sequence number with that of the last update
from this node and if it is greater, it forwards the update on all the links
except the link from which it was received.
Eventually, all the network will receive the update.

Make a comparison between the Distance Vector and the Link State methods for

Distance Vector Link State

Simple to Implement More complex

Doesnt require routers to store much Requires each router to store a complete
information Network Map

Suffers from slow convergence Much faster convergence

Slow Convergence makes Distance Vector method unsuitable for large Networks.
Lecture 11: Network Layer (3): Interdomain Routing

How is the Interdomain Unicast Routing accomplished?

Find the best route to destination network
Treat each network as a single node without any reference to the internal
network topology

How does the Interdomain Routing between different Autonomous Systems (AS)
An Autonomous System may belong to an Internet Service Provider (ISP) or
other organisation that operates a network and wants to participate
Some organisations may operate more than one Autonomous Systems
For ease of organisation
Due to company mergers
Each of this systems is independently administered
Every Autonomous System is identified by a unique number allocated by the
Regional Internet Registry (RIR).
Routing Problem is to find the best path between the source AS and the
destination AS.
Treat every AS as node on the Autonomous System Topology Graph
Treat the connections between these AS as edges in the graph
Interdomain routing is between competitors (network operators and companies
that compete for customers), so an AS is unlikely to trust its neighbours
Routing must consider policy
Restrictions on who can determine your topology
Restrictions on which route data can follow
Prefer control over routing (Due to personal preferences and oppositions,
political differences or cost)

Describe the Autonomous Systems Topology.

Well-connected Core Networks
Core Networks need a Full Routing Table
Sparsely-connected Edges that getting service from the Core Networks
Edge Networks can use a Default Route to the Core Networks

What is the Default Free Zone (DFZ)?

The Default Free Zone (DFZ) in a Network is the region where there are no Default
How does the Routing works in the Default Free Zones?
The Core Networks that comprise the Default Free Zone are well-connected
Requires complete AS-topology information
Route is based on policy, not necessarily the shortest path
Use AS x in preference to AS y
Use As x only to reach addresses on the range
Use the path that crosses the fewest number of AS
Avoid the ASes located in a specific country

What is the Border Gateway Protocol (BGP)?

It is used by the Interdomain Routing.
BGP routers receive path vectors from neighbouring Autonomous Systems (AS)
giving possible routes to prefixes
These vectors are filtered based on the policy of each AS in the path from
the source
Decision process is complex and policy-driven
Choose the route to install for destination prefix based on multiple
Shortest Path
Does not always find a route
Even if one exists, may be declined due to policy reasons
Often not the shortest path
It is a poorly documented process since the mapping of business
goals to BGP policies is related to many operational secrets
External Border Gateway Protocol (eBGP) is used to exchange information
between the Autonomous Systems (AS).
Neighbouring AS configure an eBGP session to exchange routes
Runs over a TCP connection between the routers
Exchanges knowledge of the AS graph topology
Used to derive the best route for each destination
Installed in routers to control forwarding
Advertises lists of IP Address ranges (prefixes) and their associated
Autonomous System (AS) level paths. This information is combined to
form a routing table.
Each Autonomous System (AS) chooses what routes to advertise to its
Does not need to advertise everything it receives
Usually drops some routes from the advertisement depending on
the routing policy
A common approach is the Gao-Raxford rules
Internal Border Gateway Protocol (iBGP) is used to propagate routing information
between the routers in an Autonomous System (AS).
Handles the routing within the Autonomous System (AS)
Distributes information on how to reach external destinations
Lecture 12: The Transport Layer

Which is the role of the Transport Layer?

Isolates upper layers from the Network Layer
Hide Network Layers complexity
Make Network Layer appear reliable
Enhance the quality of service provided by the Network Layer
Provides a useful, convenient and easy to use service
An easy to understand service model
An easy to use programming Application Programming Interface (API)
The Berkeley Sockets - Widely used by application programmers
In contrast to the Network Layer API which is hidden in the internals
of an Operating System
Provides numerous functions
Congestion Control
Operates Process-To-Process, not Host-To-Host

What is Addressing and Demultiplexing in the Transport Layer?

The Network Layer address identifies a host
The Transport Layer identifies a user process running on a host
The Transport Layer provides a demultiplexing point where each service
has a unique transport layer address.

What is Reliability in the Transport Layer?

Network Layer is unreliable
Best effort packet switching is provided in the Internet
Even reliable circuits may fail
Transport Layer works on ensuring the Reliability of a Network
Enhances the quality of service provided by the Network Layer
Tries to match application needs
Provides appropriate End-To-End Reliability
Where is it better to place functionality? Within the Network or at its End Points?
Only put functions that are absolutely necessary within the Network and leave the rest
of the functionality to the End Points. Since the Network is not guaranteed 100%
reliable, the application will have to check the data anyway so there is no need to check
at the Network layer. It is better to check just one time at the End-To-End Transport
Protocol where the check is also visible to the application. The aforementioned method
is one of the basic principles of the Internet.

Is the need for Reliability the same for every application?

No, different applications require different reliability according to their nature. For
example, during e-mail and file transfer, all the data must arrive in the order they were
sent but with no strict timeliness requirement, whilst in voice/video streaming, a small
amount of data loss is tolerable but timely delivery is required.

What are the implications on the Network Architecture from the application of
Reliability functionalities?
Network Layer provides timely but unreliable service
Transport Layer adds the reliability, if it is necessary

Describe how the Framing works in the Transport Layer.

Applications may wish to send structured data
Transport Layer is responsible for maintaining the boundaries and frame the
original data, if this is necessary.

Describe how Congestion and Flow Control work in the Transport Layer.
Transport Layer controls the application sending rate
To match the rate at which network layer can deliver data - Congestion
To match the rate at which the receiving application can process the data -
Flow Control
This must be performed End-To-End, since only the endpoints know the
characteristics of the entire path
Different applications have different needs for Congestion Control
E-mail and File Transfer:
Elastic Applications: No concern about the sending rate
But still, faster is better
Voice or Streaming Video:
Inelastic Applications: Have minimum and maximum sending rates
Care about the actual sending rate
Large range of congestion control algorithms within the network constraints

List some commonly used Internet Transport Protocols.

The Internet Protocol provides a common base for the various transports
There is a large number of different protocols available that handle the Transport;
each of them makes different design decisions:
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
Datagram Congestion Control Protocol (DCCP)
Stream Control Transmission Protocol (SCTP)

What is the User Datagram Protocol (UDP)?

It is the simplest Transport Protocol
Exposes raw Internet Protocol (IP) service model to applications
Offers Best Effort Packet Delivery
Provides Framing
No Congestion Control
Adds a 16 bit port number to identify services
Useful for applications that:
Prefer Timeliness to Reliability
Are able to tolerate some loss of data
Are able to adapt to congestion in the Application Layer
Video Streaming

What is the Transmission Control Protocol (TCP)?

Reliable bit stream protocol
Packets contain sequence number to detect any data loss
Any lost packets are retransmitted
Data is delivered to higher layers in order, without gaps
Runs over the Internet Protocol (IP)
Adds Congestion Control
Adds a 16 bit port number to identify services
Does not provide framing
Delivers an ordered byte stream
The application must impose structure
Useful for applications that:
Require Reliable data delivery
Can tolerate some timing variation
File Transfer
Web Downloads
Instant Messaging
The default choice for most of the applications

What is the Datagram Congestion Control Protocol (DCCP)?

Datagram Service
TCP without reliability, UDP with connections and congestion control
Easier for NAT boxes and firewalls than UDP
The connection control algorithm (CCID) is negotiated at the connection setup
with range of algorithms supported
Adds 32 bit service code in addition to the port number
Application Examples:
Streaming Multimedia

What is the Stream Control Transmission Protocol (SCTP)?

Datagram Service
Ordered per Stream
Multiple Streams are supported within a single association
Multiple Connection Management
Failover from one IP to another, for reliable multi-homing
TCP-like Congestion Control
Application Examples:
Telephony Signalling

Which are the Deployment Considerations related to the Transport Layer?

IP is agnostic of the Transport Layer protocol. But, Firewalls perform a deep packet
inspection and look beyond the IP header to make any policy decisions. A secure
policy would be to disallow anything that cannot be understood. An implication to this is
the fact that it will be very difficult to deploy any new Transport Layer Protocols such as
the DCCP and SCTP in the Internet and that limits the evolution of the Networks in the
Lecture 13: TCP

What is the Berkeley Sockets API?

A widely used low-level C networking API
Largely compatible cross-platform
First introduced in 4.BSD Unix
Now available on the most platforms (Windows, MacOS, Linux)

What is a Socket?
A Socket provides a standard interface between a Network and an Application.
It is independent of the Network type
Commonly used with TCP/IP and UDP/IP but not specific to the Internet
Protocol (IP)

List the two types of Sockets.

Stream - Provides a virtual circuit device
Datagram - Delivers individual packets

What is a TCP/IP Connection?

A reliable byte stream connection between two computers
Most commonly used in a Server-Client fashion
The server listens on a well-known port
The client connects to that port
Once the connection is established, either side can write data into the
connection, where it becomes available for the other side to read.
The connection is represented by the Sockets API as a File Descriptor.

What is a port?
A port is a 16 bit number used to distinguish servers.

Describe the process followed when setting up the Berkeley Sockets API.
1. Create a new Socket - Create a new unbound socket, not connected to a
network, to be used as either a server or a client
2. Specify an Address and Port
a. The address can be either IPv4 or IPv6
b. The address is specified via the struct sockaddr
i. Could be modelled in C as Union but it was, eventually, declared in
a number of structs to abuse casting.
ii. The sa_data field is big enough to hold the largest address of any
iii. The sa_len and sa_family specify the length and the type of the
c. Treat the address as an opaque binary string.
d. Use either IPv4 or IPv6 addresses
i. To hold IPv4 addresses use struct sockaddr_in
ii. To hold IPv6 addresses use struct sockaddr_in6
These structs have the same size and memory layout as the struct
sockaddr but they interpret the bits differently to give structure to the
e. Cast the struct that it was selected to a struct sockaddr before calling the
socket routine
f. Create an Address
i. Either the default one using INADDR_ANY
ii. Or a specific IP Address using the inet_pton() method, if the
numeric IP is known
g. Convert port number using htons()
3. Implementing a Server
a. Bind to a port in a network interface
b. Listen for new connections on that port
i. The backlog is the maximum number of connections that the socket
will queue up in order for them to be accepted.
c. Accept new connections
i. Accept new connections in turn using a loop
ii. Create a new file descriptor connfd to be used for this connection
iii. The original fd remains open and can be used for another
4. Implementing a Client
a. Connect to the server
i. The addr parameter includes the IP Address and the port on which
the server is listening
5. Writing Data
a. Use the write() call
i. Sends data over a socket
ii. Blocks until all data can be written
iii. Returns actual number of bytes written or -1, if an error occured
6. Reading Data
a. Use the read() call
i. Reads up to BUFLEN bytes of data from collection
ii. Blocks until there are data available to read
iii. Returns the actual number of bytes read or -1, if an error occured
iv. Data is not null terminated

What is the role of the TCP Port Number?

Servers must listen to a known port
IANA maintains a registry of these ports
The distinction between system and user ports is pretty ill-advised and results to
security problems
There is insufficient port space available (more than 75% of the ports are
TCP clients themselves connect from a randomly chosen port in the ephemeral
The port must be chosen randomly to prevent attacks
Many systems use the entire port range for source ports to increase the
amount of the available randomness

How is TCP Connection Setup made?

TCP Connections use 3-way handshake
The SYN and ACK flags in the TCP header signal connection process
The initial packet has SYN bit set
Includes randomly chosen initial sequence number
The reply has also SYN bit set
Includes randomly chosen sequence number that acknowledges
the initial packet
The handshake is completed the acknowledgement of the second packet
Happens during the connect()/accept() calls
This combination ensures robustness
Randomly chosen initial sequence numbers give robustness to delayed
packets or restarted hosts
Acknowledgements ensure reliability

Which are the recording boundaries in TCP connections?

If the data in write() exceed the Maximum Packet Size (MTU) as defined in the
Data Link Layer, TCP will send the data as fragments.
Multiple small write() requests may be aggregated into a single TCP packet
The above imply that the data return by a read() call may not necessarily match
the data sent in a single write() call, even though, if it often appears to be a
Data may arrive in arbitrary sized chunks
Must parse and understand the data, no matter where it is split by the
network, since it is just a byte stream

How is Reliability accomplished in TCP?

All the application data are gathered into packets
Each packet has a sequence number and an acknowledgement number
Sequence number counts how many bytes are sent
Acknowledgement number specifies next byte expected to be received
Cummulative positive acknowledgement
Only acknowledge contiguous data packets
Sliding Window Protocol is used, therefore there are several
packets in flight
Duplicated acknowledgements may imply loss
TCP layer retransmits all lost packets
Data will be delivered in order, even after a loss occurs
This operation is invisible to the application
A read() for the missing data will be blocked until the data will arrive (Head
of Line Blocking)
Packet Reordering also causes duplicate ACKs
Gives the impression of a loss when the data are simply delayed
TCP uses Triple Duplicate Acknowledgement to indicate actual loss
Four Identical ACKs in a row
Causes slight delays in the response to a loss but it makes TCP more
robust in Reordering
Lecture 14: UDP and Network Address Translation

What is the User Datagram Protocol (UDP)?

UDP provides an unreliable datagram service
Identifies applications via a 16 bit port number
UDP ports are separate from TCP ports
Often used for Peer-To-Peer applications
Both Peers must bind to a known port
Voice-Over-IP (VoIP)

Describe the process followed when setting up the User Datagram Protocol
1. Create a new Socket
a. Specify SOC_DGRAM as the socket type
2. Bind it to a known port
3. Send a datagram
a. Use sendto() call to send a single datagram
b. Each call to sendto() can send to a different address, despite the fact that
the same socket is still used
c. A call to the connect() method can be used to connect to an address
i. This call only sets the destination address for future packets, since
there is no connection made at the UDP layer.
ii. Then, use the write() call to send the data
4. Receive a datagram
a. The read() call may be used to read a single datagram
i. Does not provide the source address of the datagram
b. Use the recvfrom(), instead to fill in the source address of the received
There is no need to make connect() or accept() calls since there are no connections in

How are Framing and Reliability accomplished in UDP?

Each UDP datagram is sent as exactly one IP packet
This packet may be fragmented in IPv4
The Reliability is not accomplished in the UDP
Packets may be lost, delayed, reordered or duplicated in transit
The application is responsible for correcting the ordering, repairing errors
and detecting duplicates
Generally, it is required by the user to include some form of sequence
number in each packet sent

List some of the guidelines followed when implementing UDP.

Congestion Control needs to be implemented in applications
Avoid congestion collapse of the network
Should be approximately fair to TCP
An algorithm is provided for doing this (RFC 3448)
Need to provide sequencing, reliability and timing to applications
Sequence numbers and/or Acknowledgments
Retransmission and/or Forward Error Correction
Timing Recovery

What is the Network Address Translation (NAT)?

IPv4 address space is exhausted
IPv6 is the long term solution
Network Address Translation (NAT) is a widely deployed work-around
Its use has serious consequences for the Transport Layer

How does Network Address Translation (NAT) work?

Hides several hosts on a Private Network behind a single public IP address
Rewrite packet headers at network boundary
Does not require changes to host or routers other than the NAT itself
Tries to give the illusion of more address space
Some client-server applications work without changes
Peer-To-Peer applications need several extensive changes before they can work
through a NAT
Most NATs provide a firewall to provide security since the NAT function itself
gives no security at all
Referral server on the public network used to discover external (mapped)
address/port on the NAT
Referral server used to exchange possible connection addresses with peer
Systematically tries to make a connection using all possible combinations of
Every possible network interface and protocol, mapped and local
Generates significant traffic overhead
How does Network Address Translation (NAT) affect TCP?
Outgoing connection creates state in NAT
Need to send data periodically
If not, NAT state will be timed out
Recommended time-out interval is two hours
Many NATs use shorter intervals
The server behind NAT requires configured mapping
Peer-To-Peer connections are difficult
Simultaneous open with external mapping service

How does Network Address Translation (NAT) affect UDP?

NATs tend to have short timeouts for UDP
UDP is not connection-oriented so it cannot detect the end of a flow
Recommended time-out interval is no less than two minutes
Many NATs use shorter intervals
The Voice-over-IP (VoIP) NAT traversal standards
recommend keeping a message alive for no more than 15
Peer-To-Peer connections are easier than TCP
UDP NATs are usually more permissive in the allowance of incoming
packets than TCP NATs
Many of the UDP NATs allow replies from anywhere to an open port
Lecture 15: Congestion Control

What is Congestion Control?

Congestion Control adapts the speed of transmission to match the available end-to-end
network capacity. It tries to prevent the collapse of the network due to congestion.

Where should the Congestion Control be implemented? In the Network Layer or

in the Transport Layer?
Congestion Control can be implemented in both Layers:
Network Layer:
Ensures that all transport protocols is congestion-controlled
Requires that all applications must use the same congestion control
Transport Layer:
Can optimise the congestion control for specific applications
Misbehaving Transport can congest the Network

Which are the two key principles for the Congestion Control?
The two key principles for the Congestion Control as which were first elucidated by Van
Jacobson in 1988 are:
Conservation of Packets
Additive Increase/Multiplicative Decrease in Sending Rate
These two principles together ensure the stability of the Network

What is meant by Conservation of Packets?

The network has a certain capacity
Network Capacity = Bandwidth x Delay product of the path
When in Equilibrium at that capacity:
Send one Packet for each Acknowledgment received
ACK Clocking - Each Acknowledgment clocks-out the next
Total number of packets in-transit is constant
The process described above reduces the sending rate as the network becomes
congested and delivers packets more slowly
What is meant by Additive Increase/Multiplicative Decrease (AIMD) in Sending
Adjust sending rate according to an Additive Increase/Multiplicative Decrease
(AIMD) Algorithm.
Start Slowly
Increase Gradually to find Equilibrium
Add a small amount of speed for each time interval without loss
For a Window-based algorithm:
wi = wi-1 + a where a = 1, for each Round-Trip Time (RTT),
Respond to Congestion rapidly
For a Window-based algorithm:
Multiply sending window by some factor <1 in every interval
that a loss occurs
wi = wi-1 x where = for each Round-Trip Time (RTT),
Faster Reduction than Increase, ensures Stability in the Transmission

How to adapt Transmission appropriately to Congestion Control?

For Sliding-Window Protocols:
Acknowledge each packet
Send new data only when an Acknowledgement is received
Adjust the size of the Window based on Additive Increase/Multiplicative
Decrease (AIMD) rules
Other types of protocols follow similar procedures

How is Congestion Control accomplished in the Internet?

It is provided by the Transport Layer
Dominant protocol is the TCP
The rest of the protocols try to be TCP friendly
Signals from the Network Layer notify for upcoming congestion in the Transport
Packets are discarded on Congestion
Modern TCP also uses ECN bits to be notified for Congestions from the
Network Layer, but they are not widely used

Describe how the Congestion works in TCP.

TCP is a Sliding Window Protocol
Measures the window size in bytes
Offers Slow Start
Estimate the bottleneck link capacity
Congestion Avoidance
Probe for changes in network capacity
Gives an approximate equal share of bandwidth to each flow sharing a link

How to choose the Initial Window Size (Winit)?

No information to begin with
Need to measure the path capacity
Start with a small window
Winit of one packet per round-trip is the only safe option (Equivalent to
Stop-And-Wait protocol) - Overly pessimistic solution
TCP uses a slightly larger initial window
Winit = min(4 x MSS, max(2 x MSS, 4380 bytes)) packets per
Round-Trip Time (RTT) where MSS (= Maximum Segment Size) =
(MTU - TCP/IP Header Size)
Increase until congestion
Need to increase rapidly to reach the correct value for the network
Each Acknowledgment for new data increases the window by 1 packet
per RTT
Slow, Additive Increase in Window:
wi = wi-1 + 1
In case a packet is loss, stop increasing the window immediately
Cummulative positive Acknowlegments used to detect Congestions
Triple Duplicate Acknowledgment
Packet lost due to Congestion
Acknowledgments stop arriving
No data reaching receiver
Link has failed completely somewhere
Time Period to wait before Assuming ACKs have
Trto = max(1 second, average RTT + (4 x RTT
If loss is detected by Triple Duplicate Acknowledgment:
Transient Congestion
Data is still being received
Multiplicative Decrease in the Window
wi = wi-1 x 0.5
Rapid Reduction in sending speed:
Allows congestion to clear quickly
Avoids congestion collapse
If loss is detected by Time-Out:
No packets were received for a long period of time most likely due
to a significant problem with network
Returns to Initial Sending window
Probe for the new capacity using slow start
Assume that the route has changed and nothing is known for the
new path

How does a Sliding Window Protocol works?

Stop-And-Wait Protocol:
Transmits a frame
Awaits positive Acknowledgement from receiver
If no Acknowledgment is received after a certain amount of time, the frame
is retransmitted
Sender is limited to one outstanding frame

How is Link Utilisation made?

It takes ts time to serialise a frame onto a link
ts = (frame size) / (link bandwidth)
Acknowledgement returns tRTT seconds later
U = ts/tRTT
The desired value for Link Utilisation is ~1.0
But U<<1.0 for a Stop-And-Wait Protocol
Utilisation is improved by allowing several frames to be outstanding

Which are the limitations from the use of TCP related to the Congestion Control?
It assumes loss is only due to Congestion
Too much traffic is queued in an Intermediate link
Some packets are dropped
The above are not always true:
Wireless Networks
High-Speed, Long-Distance, Optical Networks
Much research is made into improved versions of TCP for wireless links
Lecture 16: Session Layer and DNS

Which are the Higher Layer protocols in the OSI Reference Model?
Session Layer
Presentation Layer
Application Layer
All of them are typically implemented within an application or a library and they have
poorly-defined boundaries between them.

Which are the functions of the Higher Layer protocols?

Setup and Manage Transport Layer Connections
Name and Locate Application-Level Resources
Negotiate Supported Data Formats
Perform Format Conversion as needed
Present Data in an appropriate manner
Implement Application Semantics

What is the Session Layer responsible for?

For Managing Connections:
Find Users
Find Resources
Create Transport Layer Connections
Provide Middleboxes and Caches
For Naming Resources:
Uniform Resource Identifiers
Domain Name System (DNS)

List the different types of connections that an application may need.

Single Client and Server
Group of Clients and Server
Group of Clients and Multiple Servers
Server-Mediated Peer-To-Peer
Point-To-Point Peer-To-Peer
Any Source Multicast Group
Peer-To-Peer Group
Broadcast - Single Source Multicast
How are the Connections managed?
Participants are found
By looking-up a name in a directory (e.g. DNS, Web Search Engine)
By Server-Mediated Connection (e.g. Instant Messaging, VoIP)
Connection is set up
Direct connection to a named host (Leads to NAT issues)
Mediated Service Discovery followed by Peer-To-Peer Connection
A session membership may change

How does the User and Resource Mobility work in the Session Layer?
IP Addresses encode location
Mobility breaks Transport Layer connections
Session Layer must find new location and establish bright new connections
The Old Location may be redirected
Users might register a new location
Update a DNS name to point to the new IP Address
Using an Application-Specific-Server

How are Multiple Connections handled?

A single session may span multiple transport connections
The Session Layer is responsible for coordinating the connections

When are Middleboxes and Caches used?

Some protocols rely on Middleboxes or Caches
Web Cache
Optimises Performance
Moves Popular Content closer to Hosts
E-mail Server
Supports Disconnected Operation by Holding Mail until User
SIP Proxy and Instant Messaging Servers
Locate Users
Respond for Offline Users
The End-To-End argument applies again
Only add middleboxes when is absolutely necessary
How to find a Middlebox?
Manual Configuration
Looks up in a central directory service
Multicast Service Discovery
Transparent Redirection

How to find Resources used or referenced by an Application?

Examples of Resources:
E-mail Addresses
Phone Numbers
Objects in a Database
Parcels Being Shipped
Use a Uniform Resource Identifier (URI):
Uniform Resource Name (URN):
A Unique Resource Name
No Information on Where to Find or Where to Access the Resource
Uniform Resource Locator (URL):
A Unique Resource Name
Also Includes the Location and Access Method
Directory Service Used for URN:
URL Mapping

What is the Domain Name System (DNS)?

URL often refers to a host on a Network
It is desirable to use a human-readable hostname in URLs rather than an IP
The Domain Name System (DNS) translates from the hostname to an IP Address
DNS is an Application Layer protocol, running over the Network
Not necessary for the correct operation of the Transport or the Network Layers or
Early Internet did not use DNS
A flat file named hosts.txt was used that included all the host names and
addresses available
Maintained by NIC
Updated by email every few days
Installed manually in every host
Scaling problems
Proposed in 1983 as a Distributed Database of Host Names
Administered by IANA
Now Managed by ICANN
The US government asserts ultimate control over ICANN and therefore,
over DNS
Significant attempts to move control of national domains over the United
Nations (UN) and hence to the Nations concerned
The Attempts to set up alternate roots for the DNS with different
namespaces led to significant technical problems

How does the DNS operate?

Divided into zones (DNS Zones)
Zones follow a certain Hierarchy
One logical server per zone
The Domain Name delegation follows the aforementioned hierarchy
Hop-by-hop name look-up follows hierarchy via root
Results have Time-To-Live (TTL), cached at intermediate servers
Use getaddrinfo() method for converting the DNS hostnames and IP Addresses
between their human-readable text representations and their structured binary

What is the Time-To-Live (TTL)?

Time-to-live (TTL) is a value in an Internet Protocol (IP) packet that tells a network
router whether or not the packet has been in the network too long and should be

How to perform DNS lookups?

Prefer using DNS names to raw IP addresses
Use the getaddrinfo() method to perform the lookup
Returns a linked list of struct addrinfo values, representing addresses of
the host
Lecture 17: Presentation & Application Layers

What is the Presentation Layer responsible for?

The Presentation Layer is responsible for the Presentation, Representation and
Conversion of data. More specifically is responsible for:
Media Types
Content Negotiation
Channel Encoding
Format Conversion
Character Sets

What are the Media Types?

Data Formats themselves are often not very self-describing
Media Types are used to identify the format of the data
Formats are categorised into eight top-level types
These types have many sub-types
Each sub-type may have many parameters
Media-Types are included in protocol headers to describe the format of included

What is the Content Negotiation?

Many protocols negotiate the media formats they use
They ensure that both the sender and the receiver have a common format
they understand
Typically some version of offer-answer exchange
The Offer lists the supported formats in the order of preference
The Receiver picks the highest preference format it understands and
includes it in its Answer
Negotiation is accomplished in one Round Trip Time

What is Binary Data?

Data that cannot be represented within the textual character set currently in use
This data must be encoded appropriately to fit the character set in use
Many protocols can send this kind of data directly without being encoded in
textual format
Example: TCP/IP Headers
Two issues should be consider while sending this data without encoding:
Byte Ordering
Internet is big-endian and so data should be converted from their
little-endian PC format
Word Size
The actual size used by the different media types

Which issues should be considered when one designs a binary coding scheme?
Must be backwards compatible with text-only systems
Some systems support 7-bit ASCII only
Some systems enforce a maximum line length
Data must survive from the translation between character sets
Must not use non-printing characters
Must avoid escape characters that might be interpreted differently by the channel
Escape characters might be used to convert 8-bit characters into a format
that is suitable for the channel, if the 8-bit values are rare

How does 64 base encoding works?

Textual Encoding of Binary
Splits each group of 3 bytes (24 bits) into 4 6-bit values
Encodes them with respect to the corresponding Encoding Table
Uses = characters for padding
Encodes no more than 76 characters per line
Leads to approximately 33% of increase in data size (3 bytes -> 4 bytes)

What character set should be used to conform with the principles of

Internationalisation (i18n)?
A national character set like ASCII cannot be used
Need to identify the character set and the language
Complex to convert between character sets
Unicode is a possible solution
A single character set that can represent almost all characters from almost
every language
21 bits per character
Several representations available
Just represents characters
Still need a way to identify the language used

What is UT-8?
Variable-length coding of Unicode characters
Strongly recommended for the representation of data
Widely used in Internet Standard protocols
Backwards compatible with 7-bit ASCII characters
Codes in the ASCII character set can be encoded identically
All non-ASCII characters are coded with high bit set
No zero octets occur in UT-8
It can be represented as a string in C
For meaningful conversion, code the characters using UT-8 and specify the
The application-layer programmer need to worry about the manipulation of

What is the Application Layer responsible for?

The Application Layer is responsible for the functions that are specific to the application
Deliver an e-mail
Stream video
Retrieve a website

What kind of protocol syntax does the Application Layer use?

Used by high-level application layer protocols
Instant Messaging
Highly Optimised
Used by:
Audio/Video Data
Low-Level or Multimedia Transport Protocols
The protocols are designed for extensibility rather than optimality

How is Framing accomplished in TCP?

TCP Connection is reliable but does not offer Framing
The byte stream should be parsed
A structured protocol is required:
Textual-Request Response Format:
Send Request and Headers giving details
Receive a Structured Response
Tag-Stream Protocols:
Parse the Stream until the appropriate closing tag is seen
Binary Protocols:
Type-Length-Value (TLV) Structure
Ease of Parsing

How is Framing accomplished in UDP?

Provides Framing
Data is delivered a packet at a time
Application must organise data so that is useful if some packet is lost
Streaming video with I and P frames
How to reduce the Chatter of a Protocol?
The more chatty protocols take many round trips to complete a transaction
The Round Trip Time (RTT) is fixed by the speed of light and irrespective
of the network bandwidth
It often acts as a limiting factor in response time
It is desired to have the number of Round Trip per Transaction reduced
Send a transaction in single request
Get a single response
Specific Response Signalling
Useful to have an extensible framework for the response codes
Many applications settled on a three digit numeric code
First digit indicates the response type
Last two digits give specific error (or other response)
Allows signalling new error types
Get meaningful response from existing clients
Backward compatibility
Lecture 18: Security

What is Traffic Monitoring?

It is possible to intercept traffic on a network
Authorities from many countries around the world monitor traffic for legal reasons
To enable authorised wiretaps by police
There are good reasons why law enforcement needs to intercept some traffic
Unfortunately, pervasive monitoring is widespread

How to enforce Confidentiality in a Network?

Data must be encrypted to achieve Confidentiality
There are two basic approaches:
Symmetric Cryptography
Advanced Encryption Standard (AES)
Public Key Cryptography
The Diffie-Hellman Algorithm
The Rivest-Shamir-Adleman (RSA) Algorithm
The whole Encryption process evolves complex Mathematics

How does the Symmetric Cryptography work?

Function converts plain text into cipher-text
Suitable for bulk encryption
Cipher-Text is Binary data
May need base64 encoding
Conversation is protected by a secret key
The same key is used to both encrypt and decrypt the text

How does the Public Key Cryptography work?

Key split into two parts
Public Key
Widely Distributed
Published in a Well-Known Directory
Private Key
Must be kept Secret
Encrypt using Public Key
Decrypt needs the Private Key
Very Slow to Encrypt and Decrypt

How does Hybrid Cryptography work?

Uses a combination of both the Symmetric and Public Key Cryptography
Generates a random, ephemeral, session key that can be used with
Symmetric Cryptography
Session Key is too small
Uses a Public Key system to securely distribute this session key
Relatively fast process due to the size of the key
Encrypt the data using Symmetric Cryptography, keyed by the session key
Very good Performance
PGP for e-mail
SSL for web pages

How does the Authentication work?

Encryption can ensure Confidentiality
To tell if a message has been tampered with:
Use a combination of a Cryptographic Hash and Public Key Cryptography
to produce a Digital Signature
Give some confidence that there is no man-in-the-middle attack in
Also used to prove origin of data

How to create a Cryptographic Hash Function?

Generate a fixed length (e.g. 160 bit) hash code of an arbitrary length input value
Should not be feasible to derive input value from hash
Should not be feasible to generate a message with the same hash as another
MD5 and SHA-1

How do the Digital Signature Algorithms work?

Generating a Digital Signature
Generate a cryptographic hash of data
Encrypt the hash with a private key to give the Digital Signature
Verifying the Digital Signature
Re-calculate the cryptographic hash of data
Decrypt the signature using the public key
Compare the two aforementioned values
They should match

List some of the existing Secure Protocols.

Some of the existing Secure Protocols that give Confidentiality and Authentication are:
Transport Layer Security (TLS)
An enhancement to the Secure Sockets Layer (SSL)
Datagram TLS
Secure Shell (SSH)

How should the data be carefully validated before they are used?
Networked Applications, fundamentally, deal with data provided by un-trusted third
Data from the network may not conform to the protocol specification
Due to ignorance
Due to bugs
Due to malice and desire to disrupt services
Beware escape characters in user-supplied data
All user data should be sanitised before they are used
Stop malicious users from inserting control characters that
might disrupt the operation of any scripting language inside
the application
Therefore, all the data should be carefully validated before they are used by a system.

What is a Buffer Overflow Attack?

The C Programming Language does not check any array bounds
Programmer is responsible to ensure that the bounds are not violated
A mistake usually results in a core dump
The extra space acquired by a Buffer Overflow can be used for the
addition of executable code whose return address jumps into the existing
Buffer Overflow Attacks in the Network code are the primary source of security
All array bounds should be checked carefully
If the code can be crashed by the Network Traffic, it probably has an
exploitable buffer overflow somewhere.