Microsoft PowerPoint – SN-2017-Sec12.pptx
12 Computer Networks
Networks
• To connect two computers together one requires only a point-point cable with
a channel for each direction.
– Such a cable would be attached to an I/O port on each machine supported by device
drivers and communication software.
• When there are many machines it is not feasible to connect every pair with a
separate cable.
• Instead we use a computer network which connects the end-systems or hosts
with a communications medium sometimes called a subnet.
– The medium allows any pair of hosts to communicate and supports many simultaneous
conversations.
• Networks are often classified by size:
– A local area network (LAN) has a subnet of limited size, both in distance covered and
number of hosts. May be owned by an organisation of any type.
– A wide area network (WAN) has a subnet of national or even global size with very large
numbers of hosts, usually owned by a telecommunications organisation.
Systems and Networks 12. Computer Networks 2
Switched and Broadcast Networks
• In a switched network the medium is a collection of
specialised computers called nodes, routers, or switches
connected by point-point links.
• Routers are special computers that receive messages
and forward them, usually to another router closer to the
final destination
– Eventually a router local to the destination delivers the data.
– Routers typically have physical links to several other routers;
run routing algorithms that tell them where to send messages.
• Most WANs and modern wired LANs are switched
networks.
• Not all networks use a switched subnet. Some use a
broadcast medium such that every host sees any
message sent (discriminate by host address in message).
– Examples include wireless networks and satellite networks
Systems and Networks 12. Computer Networks 3
Router
Host
Link
Hosts only accept message if address recognised
Hosts
Broadcast Medium
Transmitted message
goes to all
destinations
Systems and Networks 12. Computer Networks 4
Circuit and Packet Switching
• There are two approaches to the operation of a switched subnet.
• In circuit switching complete path set up through nodes from initiating host to
destination. Data flows along this path with no storage at nodes. Path is kept
alive until one host closes it.
– Propagation delays are predictable and limited
– Switch and link resources are used by a path even when there is no data.
– Originally developed for the telephone network.
• In packet switching messages broken into small units called packets. Sent from
one router to next (a hop), stored temporarily at each, until destination reached.
– Each packet carries the host address of the destination.
– Routers use this address to decide on next hop.
– More efficient use of network resources and more fault tolerant.
– Queues for outgoing links form at nodes and delays can be unpredictable
• In both cases many high level conversations are carried across one link at same
time. This is called multiplexing. Capacity of the link must be shared somehow.
The Communications System
• Ultimately we want to use networks to deliver useful applications:
web, email, ftp, video conferencing etc.
– Different communication requirements in terms of reliability, delays etc.
– As with the I/O handling, we do not want each application to have to
handle hardware directly.
• The communications system (CS) has much the same role in handling
access to the network that the OS has with local hardware.
– The CS handles transmission, packet formation, routing, reliability etc. All
is offloaded from the applications.
– The CS is distributed across hosts and routers each with its own portion
cooperating with all others.
– The CS instances on each host or router must follow the same protocol:
the rules of packet structure, types, conversation structure etc.
Systems and Networks 12. Computer Networks 5
Systems and Networks 12. Computer Networks 6
The Internet
• Networks are even more useful if they can be interconnected;
this is an inter-network.
• The Internet is a global internetwork consisting of tens of
millions of networks and billions of users.
• All constituent networks use packet switching with the same
packet protocol, known as Internet Protocol or IP.
• These networks are linked by means of nodes called IP routers.
• The networks making up the Internet are of many different
types. On the edge of the Internet the commonest are Ethernets.
These have their own internal nodes called Ethernet switches.
Systems and Networks 12. Computer Networks 7
Layers
• The CS offers services to applications. Building these services is complex. Some
are simpler and very general, others specific and complex.
• To simplify implementation the CS is generally constructed as a series of layers.
• Each layer offers services to the layer above and builds on the services of the
layer below using its internal (layer-specific) protocols.
• Using layers has several benefits:
– Can improve implementation of a service by rewriting the software for its protocol
– New services can be introduced without disturbing the rest of the system
– Can provide alternative protocols at a given layer (e.g. TCP vs UDP…)
• Internet CS has 4 defined layers, collectively defining the Internet Architecture.
– The Application Layer offers user-level services (protocols like HTTP, FTP etc).
– The Transport Layer gets messages from end to end if necessary breaking them up into
packet sized chunks and ensuring reliability (protocols are TCP and UDP).
– Network Layer uses only IP and routes IP packets from router to router.
– The Network Access Layer uses a variety of protocols (notably Ethernet and PPP) to get IP
packets across links between neighbouring routers
Systems and Networks 12. Computer Networks 8
Application Layer
• This layer is concerned useful things for the user, not details of comms.
• Most applications are organised as client-server
– Client presents the application to the user and issues requests.
– Server provides information in response to multiple clients
– Application Protocols define client-server interaction (e.g. HTTP defines web
browser-server interaction).
– Many different apps can implement the http protocol!
– The transport layer uses TCP to offer reliable data transfer service HTTP can use.
• We can write HLL programs to implement new applications at this level.
• Client-server is an asymmetrical form of communications. Another
approach is symmetrical (peer-peer).
IP Layer
• There are several versions of the IP protocol: current one is IPv4.
• An IPv4 packet or datagram is a self-contained chunk of data (up to 64Kbytes but
most commonly no more than1.5Kbytes) preceded by a fixed header of 20 bytes
(this can be optionally extended).
• Every interface on the Internet (on a host or a router) has a unique 4-byte IP address.
• Each IP packet header contains the address of its destination and of its source.
• Traditionally IP addresses are quoted for human consumption in dotted decimal
notation. The 4 bytes, starting from the most significant are turned into their decimal
equivalents and separated by dots E.g.
– 82 D1 F0 8016 becomes 130.109.240.128
– Exercise: Write this out in binary!
• A large message must be broken down (fragmentation) into multiple IP packets by
the sending transport layer and reassembled at the destination.
• Individual packets are treated as entirely independent by the network and may even
follow different routes (potentially arriving out of order).
Systems and Networks 12. Computer Networks 9
IP Routing
• An IP router will have several links. When a packet arrives, the router
must decide which link to forward it on.
• The packet is stored in router memory while the decision is made
• The decision involves looking up a routing table using the destination
address as an index.
• Once the decision is made the packet joins a queue for the chosen
outgoing link.
– The packet at the front of the queue is transmitted first.
– The busier the link the longer the queue.
• Routing tables are not fixed but are recomputed regularly via routing
algorithms which gather information from neighbouring routers.
Systems and Networks 12. Computer Networks 10
Transport Layer
• IP sends packets across the Internet from source to destination host.
• Packets may arrive in wrong order or even get lost.
• Transport Layer is responsible for converting this simple service into one able
to send messages between application processes.
• IP packet has no idea what is inside its data field: in fact the data field is usually
formatted as a transport layer segment.
• The most important Transport Layer protocol is TCP which attempts to deliver
data without error and in order to a chosen application.
• TCP uses its own protocol data units called segments, each with its own header.
When TCP is in use, each segment is carried in an IP packet.
• TCP recognises 216 different ports on each host, to which an application process
can attach.
– A TCP segment contains 16-bit source and destination port numbers in its header.
• A TCP connection is a two-way association between ports on 2 hosts. Data
streams in both directions across the connection, split into IP-sized segments
Systems and Networks 12. Computer Networks 11
TCP and UDP
• TCP is used to carry HTTP and FTP for example.
• The data passing over the Internet is structured like an onion: the IP packet
contains a TCP segment which contains, say, a part of an HTTP protocol unit
(remember it is the Transport Layer that does fragmentation).
• All TCP segments are checksummed to flag corrupted bits and numbered to
allow missing, out-of-order and duplicate segments to be detected.
– Correct packets are acknowledged by the receiver; corrupt and missing segments are
requested again.
– This can sometimes lead to duplication. Why?
• Another simpler protocol, UDP, is also used at the Transport Layer. This
avoids the mechanisms for reliability and merely ensures data is delivered to
the correct application.
– UDP is used where data correctness is less important than timeliness (e.g. signals,
streaming of video or music etc. but not file transfer or web browsing)
Systems and Networks 12. Computer Networks 12
ANC4 13
Internet Network Access Layer
• Can actually consist of complex sub-architecture with multiple sublayers.
• Provides data pipes between routers or routers and hosts.
• Different possibilities:
Broadcast Multiple Access
Non-broadcast
Multiple Access
(NBMA)
Point-to-point
LAPB, PPP
ANC4 14
Encapsulation
• Consider TCP connection to host attached to an Ethernet.
– On local net data is transmitted as Ethernet frames (max payload 1500bytes).
– Within each Ethernet frame is an IP packet
– Within each IP packet is a TCP segment
On any TCP/IP network,
– max IP packet size is called maximum transmission unit (MTU);
– max data in a TCP segment is called maximum segment size (MSS).
• In example above MTU=1500, MSS=1460 (if no options are used).
• Most systems will attempt to avoid necessity for fragmentation by using an
MTU which is the minimum of those in effect at the two ends of a TCP
connection.
Ethernet
Header
IP Header TCP Header TCP Data
Ethernet
Trailer
ANC4 15
IP Datagrams (IPv4)
• IHL (Internet Header Length) 4-bit field giving
number of words in header (5 common). Total
Length is in bytes (max 216 bytes).
• 6 bits DSCP allows for priorities but not widely
used; 2 bits ECN is for congestion control
• IPv4 allows a datagram to be split up by a router if
it encounters a network with a small maximum
packet size. Fragments from same datagram have
same Identifier. 3 flags: one unused, MF (More
Fragments) indicates more fragments to come, DF
means Don’t Fragment. In practice, router
fragmentation is avoided wherever possible.
• 13-bit Fragment Offset says where current fragment
comes in its parent datagram (units are 8 bytes).
• TTL (Time-to-live) used to limit packet lifetimes:
decremented each hop, kills packet when 0. Often
set to 30.
• Protocol field tells which type of payload datagram
is carrying: e.g. protocol 6 is TCP, 17 is UDP.
• Checksum is taken over the header only.
Version DSCP Total LengthECNIHL
Identifier Frag OffsetFlags
TTL Protocol Header Checksum
Source Address
Destination Address
Options
(usually absent)
Data
~ ~
32-bits
ANC4 16
TCP Segment Format
• Exchange of TPDUs called segments. Header of five 32-bit words. Each segment carries a sequence
number. TCP sees transmission as stream of (data) bytes. Every byte in stream has a number.
Sequence number of segment is number of its first data byte. Acknowledgement number, if present,
is number of next expected byte.
32-bits
Source port number Destination port number
Sequence number
Flags
Checksum
Acknowledgement number
Window size
Urgent pointer
Header
length
Options
(0 or more words)
Data
Header length (4 bits) gives number of 32 bit
words (including options).
Next 6-bit field is reserved
There are 6 1-bit flags: URG, ACK, PSH, RST,
SYN, FIN used for e.g. setting up connections.
Window size is number of bytes receiver will
accept (sliding window flow control)
Checksum is over TCP segment plus pseudo-
header.
If URG =1, urgent pointer gives number of
urgent bytes that follow sequence number.
Options have many uses: e.g negotiate MSS