A networking primer
SOFTENG 325
Software Architecture
The role of a network
Network
Host Host
Packets Message
Message
End systems (hosts) are connected by a network
A network provides a communication service that end systems use
to exchange messages
A message is a sequence of bytes
A message is split into chunks called packets; it is packets that are
actually sent across the network
SE 325 A Networking Primer 2
Networking fundamentals
Link
Switch
In general, end systems are not connected directly, but by one or
more switches
A switch takes a packet arriving on one of its incoming links and
forwards the packet on one of its outgoing links
A route (path) is a sequence of communication links and switches
that a packet traverses from source to destination hosts
SE 325 A Networking Primer 3
Circuit switched networks
In circuit switched networks, resources along a path are
reserved for the duration of a communication session
Each link has n circuits.
A dedicated connection between hosts
A and B is set up prior to any
Host A communication between these hosts.
Each circuit provides a bandwidth of 1/n
for the duration of the connection.
Host B
SE 325 A Networking Primer 4
Time-division multiplexing
(TDM)
One way of implementing a circuit is to use TDM
With TDM, time is divided into frames of fixed duration, and
each frame is divided into a fixed number of slots
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
Slot Frame
Time
Assume a circuit switched network where each link has a
bit rate of 1.536Mbps with frames divided into 24 slots,
and where the cost of setting up a connection is 500ms.
How long would it take to transmit a file of 640,000 bits?
SE 325 A Networking Primer 5
Packet switched networks
With a packet switched network, resources are not reserved, but used on
demand
Packets are transmitted over each link at the link’s full transmission rate
A packet switch stores a packet in its entirety before forwarding it on an
outbound link
Each packet switch along a path incurs a delay of L/R seconds where
L is the length of the packet
R is the transmission rate of the link
Total delay between two hosts is QL/R where Q is the number of links
Assume a path exists between hosts A and B that
involves two switches. The transmission rate of each of
the three links is 1.536Mbps and the maximum permitted
size of a packet is 64,000 bits. How long does it take to
transfer the file of size 640,000 bits?
SE 325 A Networking Primer 6
Queuing delay with packet
switched networks
If the arrival rate of packets at
switch X exceeds 1.5 Mbps,
congestion occurs causing X to
10 Mbps links queue packets
Queues are finite in size –
where a switch’s queue is full,
Queue of incoming packets are
packets at dropped
switch X
1.5 Mbps link
In general, queuing delays are
unpredictable; in practice they
are of the order of
microseconds to milliseconds
per switch
SE 325 A Networking Primer 7
Delivery order in packet
switched networks
Host X
Host Y
B D
E
A
C
F
Host Z
Network structures are self-organising in that routing tables stored
in switches are periodically updated to take into account congestion
and failed switches
E.g. the route packets follow between hosts X and Y might change
from [A,B,D,E] to [A,C,F,E]
When transmitting a large message from X to Y, packets might
arrive at Y in a different order to which they sent by X
SE 325 A Networking Primer 8
Efficiency
Scenario 1
Assume: With packet switching:
A 1Mbps link With 35 users, the probability
Users alternate between that 11+ are active
active periods, where they simultaneously is 0.0004
generate data at a rate of With up to 10 simultaneously
100kbps, and inactive periods active users (probability
Users are active 10% of the 0.9996), the aggregate
time arrival rate of data at the link
With TDM, the link can is <= 1Mbps. So, with up to
10 users, there is no queuing
support only 10 users in order delay
for each user to send data at With 11+ simultaneously
the rate of 100kbps active users, the queue for
the link will grow, causing
some users to experience
delay
Packet switching can match the performance of circuit switching
while simultaneously allowing for more users of the network.
SE 325 A Networking Primer 9
Efficiency
Scenario 2
Assume:
10 users
One user generates one thousand 1000-bit packets; remaining users remain
quiescent
With TDM and a 1Mbps link with 10 slots per frame, transmission of the
1M bits takes 10 seconds
With packet switching, the full link rate (1Mbps) can be used to send
the 1M bits within 1 second
Circuit switching can underutilise bandwidth.
Give an example of an application where circuit switching
would be more appropriate than packet switching.
What class of applications would be better served by
circuit switching?
SE 325 A Networking Primer 10
The Internet protocol
The Internet protocol (IP) is a network protocol that conforms to
the packet-switching model and which moves packets between
Internet hosts
Key features of IP:
Each host on the Internet is uniquely identified by an IP address
An IP address is a 32 bit number
Packet switches (routers) are special purpose computers that contain
routing tables. On receipt of an IP packet, a router uses its routing
table to forward the packet towards its destination
Header
Source IP address Destination IP address Data
Up to 64 Kilobytes
SE 325 A Networking Primer 11
IP as a communication
service
A communication service such as IP can be described by four
properties:
Performance
Link transmission rate and other performance properties are determined by
the underlying link type(s) of a path
Reliability – two measures:
Validity, a service is valid if a packet that has been sent will eventually be
delivered to the destination host
Integrity, the message received is identical to the one sent, and no
messages are delivered twice
Ordering
A service provides ordered delivery if packets are delivered in the order in
which they were sent
Synchronicity
A synchronous service is one that can guarantee an upper bound on the
transmission time of a packet
IP is an unreliable service that offers no ordering guarantees.
SE 325 A Networking Primer 12
Network heterogeneity
Example Range Bandwidth Latency
(Mbps) (ms)
LAN Ethernet 1-2 Km 10-1000 1-10
WAN IP routing Worldwide 0.010-600 100-500
Wireless WiFi (IEEE 0.15-1.5 Km 2-54 5-20
LAN 802.15.1)
Wireless GSM, 3G Worldwide 0.010-2 100-500
WAN
SE 325 A Networking Primer 13
Network heterogeneity
Ethernet Wireless
LAN WAN LAN
IP
Network heterogeneity is masked by overlaying different
networking technologies and protocols with a ‘virtual
network’ layer, IP
SE 325 A Networking Primer 14
Protocol stacks
Application layer protocols, e.g. HTTP, FTP, DNS
Application
Transport protocols (e.g. UDP and TCP) extend
Transport the network layer with a process-to-process
delivery service
Network
Network protocols (e.g. IP) provide a packet
delivery service between hosts
Link
Physical
Despite the IP network layer being unreliable, transport layer protocols can be
developed to provide reliable delivery and other value added services.
SE 325 A Networking Primer 15
UDP: a simple transport
protocol
UDP (User Datagram Protocol) is a simple Internet
transport protocol
Beyond basic integrity checking of packets, UDP makes no
attempt to address the (lack of) reliability and ordering of IP
UDP is an unreliable transport protocol that does not offer ordering guarantees.
A UDP packet is sent to a (host/port) pair
A host is represented by an IP address
A port at the destination host is used by a process on that host to
listen for incoming packets
A (host, port) pair uniquely identifies a
A port is a 16 bit number process on an Internet host.
Ports in the range 0 to 1023 are well-known port numbers
Port 80 -- HTTP, port 21 -- FTP, etc.
Source port # Source port # Length Checksum Application data
SE 325 A Networking Primer 16
Sockets and ports
browser
A socket is a programming
abstraction which provides an
endpoint for communication
Socket bound to ([Link]), 80)
Messages sent to a particular
Internet address and port
number can be received only Port 80
by a process whose socket is Web server
bound to that Internet
address and port number [Link]
A socket is associated with a browser
transport protocol – typically
either TCP or UDP
Process Socket
IP host Port
SE 325 A Networking Primer 17
UDP checksum
011001100110000001010101010101011000111100001100
The UDP checksum is included 0110011001100000 Word 1
for error detection 0101010101010101 Word 2
Essence of approach 1000111100001100 Word 3
The sender:
Sums the 16 bit words 0110011001100000
comprising the UDP packet 0101010101010101
Performs 1s complement on 1011101110110101 Total of words 1 and 2
the sum – this is the
checksum value added to the 1000111100001100
UDP packet
Any overflow is wrapped 1011101110110101
0100101011000010 Total of words 1, 2 and 3
around
The receiver adds all 16 bit
words, including the 1011010100111101 1s complement of total
checksum – if the total is not
a sequence of 16 1s the
packet is corrupt 0100101011000010 Total of words 1, 2 and 3
1011010100111101 Checksum value
1111111111111111
SE 325 A Networking Primer 18
1. Receiver uses an API to create a UDP
socket, binding it to a particular port.
2. Sender uses an API to create a UDP
socket, binding it to any local port.
3. Sender calls the socket’s send( ) operation
supplying the destination IP address,
Host Host
destination port number and data to send.
2 3 1 10 4. The UDP layer creates a UDP packet,
Sender Receiver filling in the packet’s fields.
UDP 4 UDP 9 5. The IP layer creates an IP packet and fills
in the source and destination IP address
IP 5 IP 8 fields. The IP packet encapsulates the UDP
6 packet.
6. The IP layer forwards the packet, sending
it to a router.
7. Each router examines the IP packet
header and forwards the packet.
IP 7 IP 7 IP 7 8. On arrival at the destination host, the IP
layer unpacks the IP packet to get the
enclosed UDP packet.
Router
9. The UDP layer places the UDP packet in
the queue for the socket associated with the
destination port.
10. The receiver makes a receive( ) call on
its socket and retrieves the packet’s
contents.
SE 325 A Networking Primer 19