COM347J1 Networks and Data Communications L1

Download Report

Transcript COM347J1 Networks and Data Communications L1

COM347J1
Networks and Data Communications
Lecture 6: Network Software and Bus
Structures and the Data Link Areas
Ian McCrum
Room 5D03B
Tel: 90 366364 voice mail on 6th ring
Email: [email protected]
Web site: http://www.eej.ulst.ac.uk
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
This version
Modified
26/10/04
L6/1/72
Network Software
• An important component of any network is the software that
controls communication.
• Such software can be very complicated. Breaking the software
into distinct modules helps simplify its design and enables
reusability.
– Consider that we want to write software to allow us to transfer a
file from one computer to another.
– One way is to write a single program that includes a windows
interface, the file transfer protocols and the software for interacting
with the network hardware
– This is a lot of code and chances are that it will take a long time to
debug this program.
– A more sensible approach is to use an existing (and well tested)
network access module.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/2/72
Services and Protocols
• A service is a set of primitives that a layer provides to
the layer above it, the service defines what operations
the layer will perform but not how. A service relates to
the interface between the two layers.
• A protocol is a set of rules governing the format and
meaning of the frames, packets or messages which are
exchanged by peer entities. Entities use protocols to
implement their service definitions, they can change
them so long as the service seen by user remains
unchanged.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/3/72
Principles of layers
• a layer should be created where a different level of
abstraction is required.
• Each layer should perform a well defined function
• The function of each layer should be chosen with an
international perspective.
• The layer boundaries chosen so that information flow
across interfaces is minimised.
• pragmatic in the choice of number of layers.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/4/72
Network Software Modules
•The file transfer program can call upon the services of the
Network Access Module.
Computer A
Computer B
File Transfer Program
File Transfer Program
Network Access Module
Network Access Module
Communications Subnet
• The Network Access Module performs all the tricky network communications
stuff, thus simplifying the implementation of the file transfer program.
• Furthermore, if the Network Access Module on a different network has the
same interface, then your file transfer program will work on that network too.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/5/72
Network Software Modules
•The Network Access Module will only provide a raw data transmission
service. If some data is corrupted, it is still left to the file transfer program
to send a request for the data to be retransmitted.
•There is no reason why we couldn’t have a module that did this for us. Let
us call this the Transport Module.
Computer A
Computer B
File Transfer Program
File Transfer Program
Transport Module
Transport Module
Network Access Module
Network Access Module
Communications Subnet
• Now the file transfer program calls upon the services of the Transport
Module, which in turn calls upon the services of the Network Access
Module.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/6/72
Peers
•Each module has a counterpart in the other computer.
These counterparts are sometimes called peers.
Computer A
CTL
Application
A_Send(dest.host,dest.SAP,APDU)
Transport Layer
SAP
T_Send(dest.host,TPDU)
Network Access
Computer B
APDU
HOST
Data
Application
TPDU
SEQ
APDU
Transport Layer
NPDU
TPDU
CRC
Network Access
Communications Subnet
• In a logical sense, each module effectively talks to its peer using the
same type of protocol data units (PDUs).
– The file transfer programs talk to each other by sending each other
Application Protocol Data Units.
– Similarly, the Transport Modules talk to each other by sending each
other Transport Protocol Data Units that encapsulate the APDUs.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/7/72
The Open Systems Interconnection Model
•Further modularization brings helps to simplify the design of network
software more. The OSI model has 7-layers.
Host A
Sending Process
Host B
Data
Receiving Process
PDU used
Application Layer
Presentation Layer
Session Layer
Transport Layer
Network Layer
Data Link Layer
Physical Layer
•
•
•
•
26/10/04
Application Protocol
Presentation Protocol
Session Protocol
Transport Protocol
Network Protocol
Data Link Protocol
Physical Protocol
Application Layer
APDU
Presentation Layer
PPDU
Session Layer
SPDU
Transport Layer
TPDU
Network Layer
Packet
Data Link Layer
Frame
Physical Layer
Bit
Each layer has a different level of abstraction.
Each layer performs a well defined function.
Layers require minimum data flow across the boundaries.
Designed to encourage international protocol standards.
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/8/72
1. The Physical Layer
Data Link Layer
Physical Layer
Link
•
The Physical Layer performs bit by bit transmission of the frames given to it
by the Data Link Layer.
•
The specifications of the Physical Layer include:
– Mechanical and electrical interfaces
– Sockets and wires used to connect the host to the network
– Voltage levels uses (e.g. -5V and +5V)
– Encoding techniques (e.g. Manchester encoding)
– Modulation techniques used (e.g. square wave)
– The bit rate and the baud rate.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/9/72
2. The Data Link Layer
Network Layer
Data Link Layer
Physical Layer
•
The Data Link Layer tries to make the potentially unreliable transmission of frames
appear to be reliable.
•
The Data Link Layer deals with:
– Inserting and extracting Network Packets into/from frames
– Adding error checking information to frames.
checking received frames for errors
– Sending requests for frames to be retransmitted if they are found to contain errors.
Also responding to such requests
– Ensuring the Network Layer receives data in the order in which it was sent over the
link
– Frame synchronisation
– Flow Control over the link
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/10/72
3. The Network Layer
Transport Layer
Network Layer
Data Link Layer
•
The Network Layer controls the operation of the local part of the network.
•
The Network Layer:
– Examines packets given to it by the Data Link Layer to see if they are
destined for this host or should be forwarded to another host
– Decides on the best way to route packets destined for other hosts
– Performs accounting tasks (such as counting the number of packets to
determine congestion levels)
– Performs protocol conversions when packets are routed over different
types of networks
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/11/72
4. The Transport Layer
Session Layer
Transport Layer
Network Layer
•
The Transport Layer controls the delivery of data between two hosts.
•
The Transport Layer:
– Fragments data streams from multiple sessions into packet sized portions
and passes them to the Network Layer
– Reassembles data streams from data in packets given to it by the Network
Layer
– Ensures delivery of data streams to appropriate sessions
– Performs host-to-host flow control to ensure data does not arrive faster
than the host can cope with
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/12/72
5. The Session Layer
Presentation Layer
Session Layer
Transport Layer
•
The Session Layer maintains a logical connection between two processes.
•
The Session Layer:
– Performs dialogue control functions and token management to keep track
of who is to transmit data next
– Synchronisation functions (e.g. inserting checkpoints into data stream so
that communication can be resumed from the last checkpoint after a
failure)
•
There may be multiple sessions (i.e. one for each communicating process).
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/13/72
6. The Presentation Layer
Application Layer
Presentation Layer
Session Layer
• The Presentation Layer performs data representation and syntax conversions.
• The Presentation Layer:
– Enables cross-platform communication by converting data representations
(strings, integers, floating-point numbers etc.) to and from network
standard formats
• Example: the sending host uses the EBDIC character set and the receiving host
uses ASCII. The Presentation Layer in the sending host takes the EBDIC code
and coverts it to Unicode. The Presentation Layer in the receiving host gets the
Unicode and coverts it to ASCII.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/14/72
7. The Application Layer
Process
Application Layer
Presentation Layer
•
The Application Layer provides an interface to a range of high-level network
services used by the communicating process.
•
Access to application services is through a set of calls to routines in a
communications library.
– There are routines for identifying a host, determining if that host is
available for communication and establishing a connection
– Data is typically sent and received in the same way as writing or reading
to and from a file
– There may also be routines for handling e-mail and file transfers
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/15/72
The Communicating Process
• The process provides the user interface and makes use of the routines
provided by the Application Layer to perform communication.
• The communicating process is not considered to be part of the OSI 7layer model.
• The process can just use the services provided by the Application Layer
or it can implement its own high-level protocols that it can send and
receive using the routines provided by the Application Layer.
– Of course, if a process does implement its own high-level protocol then
the process with which it is communicating must be able to understand
that protocol too.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/16/72
Connection-Oriented v.s. Connectionless
• A network layer may offer one (or sometimes both) of two types of
service to the layer above it:
• A connection-oriented service views PDUs as being part of an ongoing conversation between hosts.
– Successive PDUs arrive in the order they were sent.
– Received PDUs are usually acknowledged.
– Damaged or lost PDUs are usually retransmitted (to produce an
apparently reliable connection).
• A connectionless service views each PDU as a separate entity.
– Successive PDUs may not arrive in order.
– Received PDUs are not usually acknowledged.
– Damaged or lost PDUs are not usually retransmitted.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/17/72
The Network Dependent Layers
Network Layer
Data Link Layer
Physical Layer
Link
• The lowest three layers of the OSI 7-layer model are network
dependent meaning that they will be different for different types
of network.
• The layers above the network layer are network independent meaning
that the software from the transport layer upwards can be moved from
one network to another and still work.
– In the case of IEEE 802 networks, even the Network Layers can be the
same since the Data Link Layers in these networks use a common
interface called Logical Link Control (LLC).
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/18/72
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/19/72
Examples of Bus Structures
Repeater
Terminator
Integrated tap / transceiver unit
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/20/72
Examples of Bus Structures
• Segments of a bus (limited length due to
propagation) are linked by repeaters.
• A repeater is an amplifier which regenerates the
signals coming into it and passes them on (bidirectional) thus has no concept of data contents.
• Thus the overall size of network can be extended.
• Easy to implement, no security, no
acknowledgement, broadcasts possible
• What imposes an upper limit on the distance to be
connected using repeaters?
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/21/72
A more complex example
Terminator
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/22/72
Example of bridges
Bridge
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/23/72
Bridges
• Check incoming data for errors so that only
error free frames are forwarded.
• Only allows data to be forwarded when
their destination address is different from
segment from which they were received.
• Thus only communications within a
segment do not flood across the rest of the
network.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/24/72
Bridges
• Advantages
• Total number of segments can
increase. As can stations
• Can interconnect different
LANs
• Possible to mix different
protocols on different segments
• Easier to manage large
networks and improve security.
• Partitioning can increase
reliability, availability.
26/10/04
• Disadvantages
• As store and forward entire
frames - introduces small delays
• can become overloaded with
high traffic rates.
• Calculation of new check
sequences.
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/25/72
Ring Topology
Destination
Interface
ACK
“Talker”
26/10/04
data
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/26/72
Ring
• Data travels uni-directionally. (x counter rotating
rings)
• The data passes through each station’s interface, each
bit is read and retransmitted towards next station.
• Interface recognises data destined for its station by its
address and only passes that data up.
• Size of ring is determined by the physical extent,
propagation speed and number of stations.
• Can be large in extent but adjacent node separation
must not exceed a maximum distance.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/27/72
Ring access methods
• Token Passing Rings
– A token is a permission to transmit, must wait until it is
received before talking.
– Data circulates to destination and then to originator
acting as an acknowledgement.
• Slotted Rings
– mini-packets circulate, similar to carriages on a train,
whenever one marked empty is received data can be
inserted, it is then stripped off by originator.
• A monitor is required.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/28/72
Star and hub
The medium now consists of the interconnecting cables and
the hub itself. Another device will require more cable.
Considered to be more reliable when cable faults are
contemplated.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/29/72
Structured wiring
• Busses seriously damaged whenever
severed - two small segments and no
termination
– Multiple segments make them more robust.
• Rings die when severed, unless counterrotating ring is employed to loop back.
• Star looses the petal that was severed, but
hub failure is disastrous.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/30/72
Topological Ring with physical star appearance
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/31/72
Star shapes
• Petals with few stations organised as a star but still
topologically a ring.
– Under failure conditions a petal can be isolated and worked upon,
while remainder work usually.
• This structure is employed in LANs where each single
station is connected to a Multi-station Access Unit and the
network exists within the unit.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/32/72
Standards
• Medium Access Control
– IEEE 802.3
– IEEE 802.4
– IEEE 802.5
CSMA/CD
Token Bus
Token Ring
ISO 8802.3
ISO 8802.4
ISO 8802.5
• Bridges and Repeaters
• Where are each used to best advantage?
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/33/72
IEEE 802 protocol set
Layers
Logical Link Control
Medium Access
Control
Physical
26/10/04
Network
Network layer
802.2
802.3
802.4
Data
link
802.5
Transmission medium
ISO
Reference
Model
Physical
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/34/72
IEEE 802.3 CSMA/CD
• Carrier Sense Multiple Access / Collision Detect
– Ethernet
• 10 Base 5 ( 10Mbps baseband signalling 0.5in diameter cable
maximum segment length of 500m)
– Cheapernet
• 10 Base 2 ( 10Mbps baseband signalling 0.25in diameter cable
maximum segment length of 200m)
– Starlan
• 10 Base T ( 10Mbps baseband signalling unshielded twisted
pair cable drop cables circa 100m)
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/35/72
IEEE 802.5 Token Ring
• Token Ring
– slower rings
– faster rings
1 or 4 Mbits/s
16 Mbits/s
• Operates employing a Token made up of Start
Delimiter, Access Control and End Delimiter
• A Station wishing to transmit claims the token by
changing a bit in the access control field indicating
busy and inserted data at the end of this field.
• The frame rotates through the destination, marking
status and is removed by originator.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/36/72
IEEE 802.4 Token Bus
• Token Bus
– 5/10 Mbits/s
– Broadband / Carrierband
• logical 1 uses 1 cycle of bit frequency
• logical 0 uses 2 cycles of 2 * bit frequency
– enables noise filtering unlike baseband
• This is a logical ring even though implemented upon a physical
bus
• A station holding the token can send a number of frames of data,
and listens immediately after for ack
• Priority is possible and utilises target hold timers and target
token rotation time
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/37/72
1500m Ethernet configuration
Repeater
Terminator
Integrated tap / transceiver unit
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/38/72
Rules
• Between any two stations there should be a maximum of 3
segments with stations attached.
• Two point to point links of 500m or one of 1000m may fall
within the path between two stations also.
• Thus the maximum distance possible between two stations
is 2500m
• 100 taps max per 500m segment
• 1024 nodes maximum in total configuration
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/39/72
2500m Ethernet configuration
Point to Point links
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/40/72
Interface
Tap
Transceiver Unit
Drop cable
MAC Unit
Protocol control firmware
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/41/72
Transceiver schematic
Data
Control
Collision
detector
Jabber
control
Data
Control
Power
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/42/72
Jabber control
• A faulty device could continuously transmit
random data on to the cable (jabber)
• this would corrupt all other transmissions
• the jabber control will isolate the transmit
data path from the cable if certain
predefined limits are exceeded. (maximum
frame length violation)
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/43/72
Time Budget total round trip propagation delay
2,500m at 0.66c = 2 * 2,500m / (3x108 m/s *0.66)
= 25 x10-6s
electronics and transceiver cables
=20 x10-6s
Total = 45 x10-6s
equivalent of 450bits at 10Mbps
safety margin brings it up to 512 bits for a minimum frame
size or 51.2x10-6s
this ensures that a remote station which has started to transmit, whose
transmission is corrupted at the latest possible time will recognise the
collision has happened before it stops transmitting.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/44/72
Multiple Segment Ethernet
Backbone Segment
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/45/72
Bridge to extend overall LAN
length
A bridge can be considered to be a “forward if not local” device
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/46/72
Bridge operation
• receives all frames broadcast on the connected LAN
• are considered to be transparent as they only process data-link
layer (MAC) addresses. Forward any variety of upper layer
protocols.
• As each frame is received the source address is checked and
entered in a table of known local nodes
• A bridge can force responses from local nodes to elicit their
addresses so that they can be noted.
• Thus only frames whose destination addresses that are not in
the table are forwarded.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/47/72
Bridge use
• Can separate overloaded segments to relieve congestion
• can be used to extend overall length since 2,500m no longer
applies.
• Can translate between different networks ie Ethernet to token
ring or media UTP to fibre.
• Limitations
– should a non-local node be many LANs and bridges away all intervening
stations will RX frames
– non-existent addresses can be flooded onto all bridged LANs
– thus cannot support multiple paths
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/48/72
Data Link Protocols
•A data link protocol is the set of rules used to send data
over an individual link from one host to the next.
–Data link protocols vary from simple asynchronous
transmission to reliable sophisticated frame based
communications.
Network Layer
Network Layer
Data Link Layer
Data Link Layer
Physical Layer
Physical Layer
Device A
Link
Device B
• Typically the Network Layer passes packets to the Data Link Layer. The Data
Link Layer encapsulates the packets in frames and gives the frames to the
Physical Layer for transmission.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/49/72
Data Link Protocols
• The algorithm that controls the data link protocol resides
in the Data Link Layer.
• It makes use of various function calls in order to interact
with the layers above and below it.
wait_for_event(event_type *event)
from_physical_layer(frame *f)
to_physical_layer(frame *f)
from_network_layer(packet *p)
to_network_layer(packet *p)
26/10/04
–Halt process until event
occurs (event code passed
back).
–Pass up received frame.
–Send frame.
–Pass down data packet.
–Send packet to Network
Layer.
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/50/72
General Functions
• There are a number of other useful functions:
start_timer(seq_num k)
stop_timer(seq_num k)
start_ack_timer(void)
stop_ack_timer(void)
disable_network_layer(void)
enable_network_layer(void)
inc(k)
26/10/04
–Start countdown to timeout
event k (timeout period is a
system parameter).
–Stop timer k.
–Start countdown to
ack_timeout event.
–Stop countdown to
ack_timeout event.
–Forbids network_layer_ready
events.
–Allow network_layer_ready
events.
–Add 1 to k unless MAX_SEQ,
in which case reset k to 0
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/51/72
The Frame Structure
•The format of the frame structure typically looks something like this:
frame_kind kind seq_num seq
seq_num ack
packet data
– There can be three kinds of frame: data_frame, ack_frame and
nak_frame. The last two types do not carry data.
– For data frames, the packet of data passed down from the Network
Layer is put in the data field of the frame structure.
– In order to make sure that the packets are reassembled in the right
order, a sequence number is placed in the seq field of each frame.
– For reliable communications, it is important that correctly received
frames are acknowledged. The sequence numbers of correctly
received frames go into the ack field of the frame structure.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/52/72
An Unrestricted Simplex Protocol
•Here is a simple algorithm for sending data over a noise free link. We are assuming that
there is no transit delay and that the destination host has infinite buffer space.
– We start off by defining the data
structures we need to store the
packet and frame data.
– We get a packet from the
network layer and place it in
the data field of the frame
structure.
– Lastly, we pass the frame to
the physical layer for
transmission.
– Then we do it all over again.
26/10/04
start
define:
frame s
packet p
from_network_layer(&p)
s.data = p
to_physical_layer(&s)
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/53/72
An Unrestricted Simplex Protocol
•Here is a simple algorithm for sending data over a noise free link. We are assuming that
there is no transit delay and that the destination host has infinite buffer space.
•Data is only sent in one direction using this protocol.
The data is received by the destination host which uses the
following algorithm:
– Once again, we start by defining
the various data structures we
need to hold the data.
– Then we go into a loop in
which we wait for a frame
arrival event.
– When it happens, we get the
frame from the physical layer.
– We then pass it up to the
network layer.
– Then we wait for the next frame.
26/10/04
start
define:
frame r
event_type event
wait_for_event(&event)
from_physical_layer(&r)
to_network_layer(&r.data)
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/54/72
A Simple Stop-and-Wait Protocol
•The network layer in the receiving host may not always have enough buffer space to
cope with all the frames .
– We need to be able to tell the
sending host to pause until the
receiving host is ready. This is
called flow control.
– The destination host still works
the same way except it now
sends an empty frame back
to the sending host.
start
define:
frame r,s
event_type e
wait_for_event(&e)
from_physical_layer(&r)
to_network_layer(&r.data)
– This empty frame is used to
tell the sending host that the
receiving host is ready to accept
another frame.
26/10/04
to_physical_layer(&s)
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/55/72
A Simple Stop-and-Wait Protocol
start
The sending host now only sends one frame at a time.
It will not send another frame until it gets an empty
frame back from the receiving host.
– The algorithm works in exactly
the same way as the first
simplex algorithm except it now
waits for an empty frame sent
back from the receiving host.
– Only when the empty frame
arrives will the sending host
send another frame.
26/10/04
define:
frame s
packet p
event_type e
from_network_layer(&p)
s.data = p
to_physical_layer(&s)
wait_for_event(&e)
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/56/72
A Simple Protocol for a Noisy Channel
• Things become tricky when we take noise into account. Noise can
damage the data in frames. This is usually discovered when the
frame checksum (FCS) is tested.
– For simplicity, we will assume that the frame checksums will
automatically be checked on arrive and if an error is discovered
then it will generate a chksum_err event.
• Each frame is given a sequence number (either 0 or 1). The
sequence number alternatives for successive frames.
– When a frame is correctly received, its sequence number is
acknowledged by sending it back in the ack field of an empty
frame.
– When a frame is incorrectly received, no acknowledgement is
sent back and the sender times out.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/57/72
start
A Simple Protocol for a Noisy Channel
– The sequence number of the first frame is set
to 0.
– It is transmitted and then a timer is started.
– Sometimes a frame may be completely lost so
there may be nothing to acknowledge.
– If no acknowledgement is received by the
time
a timeout event occurs, the sender assumes
that its frame was lost completely and resends
it.
– If an acknowledge is received but has the
wrong sequence number, the sender assumes
that its frame was not received and resends it.
– If an acknowledge is received and the
sequence
number is correct, the sender sends the next
frame (with a new sequence number).
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
frame s,r
packet p
event_type e
seq_num n
MAX_SEQ=1
n=0
from_network_layer(&p)
s.data = p
s.seq = n
to_physical_layer(&s)
start_timer(n)
wait_for_event(&e)
e==frame_arrival
no
yes
from_physical_layer(&r)
no
r.ack==n
yes
from_network_layer(&p)
inc(n)
L6/58/72
A Simple Protocol for a Noisy Channel
frame s,r
event_type e
seq_num n
• The algorithm for the receiving host looks
like this:
– The receiving host waits for a frame
arrival.
– If the frame was damaged, it waits for
the sending host to timeout and send
the frame again.
– If the frame is correct then it gets the
frame and checks its sequence number.
– If the sequence number is correct then
the packet is passed to the network layer
and an acknowledgement is sent back to
the sender.
– If the sequence number is wrong, the
wrong sequence number is sent back.
start
MAX_SEQ=1
n=0
wait_for_event(&e)
e==frame_arrival
no
yes
from_physical_layer(&r)
no
r.seq==n
yes
to_network_layer(&r.data)
inc(n)
s.ack=1-n
to_physical_layer(&s)
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/59/72
Timeout
• Sometimes frames can be damaged by noise so much
that they are lost completely.
– We cannot assume that any frame (that includes
acknowledgement frames) will arrive.
– If an acknowledgement for a particular frame does not
arrive back in a reasonable time, the sender should
assume the worst case scenario - that it’s data never made
it to the receiving host.
– By a reasonable time, we usually mean the time it would
normally take to send a frame and receive an
acknowledgement (twice the transit delay plus a small
margin of safety to allow for the time it takes for a whole
frame to be received and processing time).
– After this time, the sender should retransmit the frame.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/60/72
Timeout
•The timeout mechanism can be shown using a time sequence diagram:
Host
A
Host
B
time
Send Frame
Host
A
Host
B
Frame
Lost
ACK
2Transit
Delay + a
safety margin
Re-send
Frame
–Left: sender successfully sends frame and receives an
acknowledgement.
–Right: frame is lost in transit. No acknowledgement arrives back in
a reasonable time so frame is retransmitted.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/61/72
Duplex Communication
•The protocols we have seen so far just send data in one direction. Of
course, data will usually flow in both directions.
Data
Header
Host A
Host B
Header
ACK
Data
– f frames are travelling in both directions anyway, it makes sense to
piggyback acknowledgements on these frames.
– This saves the overhead involved in sending separate frames just to
carry an acknowledgement.
– Of course, if no frames are due to be sent back, we will have no
choice but to send back a separate acknowledgement frame.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/62/72
Sliding Windows Protocol
• To keep track of the frames we use a technique called
sliding windows.
– Both sending and receiving hosts maintain a range of
sequence numbers called a window.
– The sender sends only the frames with sequence
numbers in its window. The window can only move on
when the first sequence number in the window has been
acknowledged.
– The receiver only receives frames with sequence
numbers in its window (any other frames are ignored).
Its window can only move on when it receives the frame
with the first sequence number in its window.
• The sliding window technique restricts the number of
frames that can be outstanding, which is good for flow
control.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/63/72
Sliding Windows Protocol
• Here is what happens if we have a 3-bit sequence
number and a window size of 1 on both sender and
receiver:
No Frame
to send
7
Got Frame
0 to send
0
7
Waiting for
Frame 0 ACK
7
0
7
0
0
6
1
6
1
6
1
6
1
5
2
5
2
5
2
5
2
4
3
4
4
3
Sending
Frame
7
7
0
3
4
3
7
0
Sending
ACK
0
7
0
6
1
6
1
6
1
6
1
5
2
5
2
5
2
5
2
4
3
4
Waiting for
Frame 0
26/10/04
Got ACK for
Frame 0
3
Getting
Frame 0
4
3
Got Frame 0,
Waiting for
Frame 1
4
3
Waiting for
Frame 1
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/64/72
Sequence Numbers
• Sequence numbers usually occupy a field with a limited
number of bits in the frame format.
– We do not want to have sequence numbers that are too
large because we will waste valuable bandwidth.
– The number of sequence numbers needs to be at least one
greater than the size of the largest window intended to be
used (a sliding window protocol can only work reliably if
there is at least one sequence number outside the
window!).
– Because sequence numbers occupy a whole number of
bits, the range of sequence numbers is usually 0 to 2m-1
where m is the number of bits used.
– For example, we could have a 1-bit sequence number.
This will be enough for a sliding window protocol with
window size 1.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/65/72
start
One-bit Sliding Window Protocol
•
This algorithm works as both sender and
receiver.
– Sequence numbers are either 0 or 1.
– Packets are put in the frame structure along
with its sequence number and the sequence
number of the last frame to be acknowledged.
– The frame is sent and the timer started.
– If a new frame arrives, check to see if its
sequence number is in the window.
– If not, then ignore its contents.
– Check the acknowledgement field and if
it acknowledges the last frame we sent
then advance our window.
– If any problems, re-send our last frame
otherwise send the next frame.
frame s,r
event_type e
seq_num n,m
packet p
MAX_SEQ=1
m=n=0
from_network_layer(&p)
s.data=p
s.seq=n
s.ack=1-m
to_physical_layer(&s)
start_timer(s.seq)
wait_for_event(&e)
e==frame_arrival
no
yes
from_physical_layer(&r)
no
r.seq==m
yes
to_network_layer(&r.data)
inc(m)
no
r.ack==n
yes
from_network_layer(&p)
inc(n)
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/66/72
Long Transit Delays
•
•
The one-bit sliding window protocol will work fine over short halfduplex links.
It is not so good over links with long transit delays. Imagine a link
that uses a geo-stationary satellite:
– The data rate is 50-kbps.
– The round-trip delay is 500msec
Up link
(that’s half a second).
– If we used the 1-bit sliding
window protocol to send
1000-bit frames, the
receiver will receive
the whole frame 270msec later.
– The acknowledgement will take a further 250msec to get back.
Out of 520msec, data is only being sent for 20msec.
– Only 20/520 = 4% of the link’s capacity is being utilised.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
Satellite
Antenna
Down Link
Ground
Station
L6/67/72
Long Transit Delays
• Rather than wasting so much channel capacity, a protocol can be
designed to send enough frames to keep the link working at full
capacity.
– Rather than just allowing one outstanding frame (like the onebit sliding window protocol does) we can allow up to 26
outstanding frames (enough to fill the 520msec round-trip
delay period).
– The sliding window of the sender need only be enlarged to 26.
To accommodate this, a 5-bit (0-31) sequence number would
be most suitable.
– With a sliding window size of 26, up to 26 frames and
acknowledgements can be in transit at any time.
– The real question is: “What happens when a frame is damaged
during transit?”
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/68/72
Go Back n
•One approach is to discard the damaged frame and all the frames that follow it.
–Eventually the sender will realise it has not received an acknowledgement
for the damaged frame within the timeout period. The sender will then
retransmit the damaged frame and all the frames that follow it.
Timeout interval
0
1
2
3
Ack 0
0
4
5
2
3
4
Ack 1
1
5
Ack 2
E
D
D
D
2
6
Ack 3
3
7
Ack 4
4
time
–The above time sequence diagram shows what happens when an
erroneous frame (E) is received. All following frames are discarded (D)
until the new copy of the erroneous frame is received.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/69/72
Go Back n
• The main advantage of go back n is that the receiver only needs to
maintain enough buffer space for one frame at a time.
– Packets must be passed up to the Network Layer in the order in
which they were sent by the Network Layer in the source host.
Only one packet needs to be stored at a time since the frames
will always arrive in the correct order.
• To implement the go back n, the sliding window of the receiver is
set to 1 (i.e. different from the sliding window of the sender).
– With a sliding window size of 1, the receiver will only accept
the frame with the next expected frame sequence number.
When a frame is damaged, the next expected frame sequence
number remains the same.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/70/72
Selective Repeat
• Go back n can waste a lot of link capacity by re-sending frames
that arrived perfectly the first time.
– If a link is particularly noisy, this waste can significantly
reduce the link’s throughput.
• With selective repeat, only those frames that are damaged are resent. Undamaged frames are stored until they can be passed (in the
correct order) to the Network Layer.
– The receiver must have enough buffer space available to
potentially store all the outstanding frames from the receiver.
– Much less of the link’s capacity is wasted since only the
damaged frames are retransmitted and the rest of the time the
link can carry useful data.
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/71/72
Selective Repeat
–Frames may arrive at the destination out of order. This means that the Data
Link Layer is responsible for ordering them before sending the packets they
contain to the Network Layer.
Timeout interval
0
1
2
3
Ack 0
0
4
Ack 1
1
E
3
5
2
6
7
Ack 1
Ack 1
Ack 1
Ack 5
4
5
2
8
9
Ack 6
6
10
Ack 7
7
time
– The selective repeat protocol can be implemented by setting the
receiver sliding window size to more than 1 (usually it is set to the
same size as the sender’s sliding window).
26/10/04
www.eej.ulster.ac.uk/~ian/modules/COM347J1/COM347J1_L6.ppt
L6/72/72