Download תקשורת מחשבים ואלגוריתמים מבוזרים

Document related concepts
no text concepts found
Transcript
Computer Communication
and Distributed Algorithms
202-2-1131
Data link layer
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
1
Data link layer
Application
Presentation
Session
Transport
Network
Link
Physical
The 7-layer OSI Model
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
2
Data link layer
Motivation:

The basics of the
data link service:




Error detection and
correction.
Multiplexing –
Multiple access to
the channel
Accessing network
resources using the
link layer.
Overview:




Link layer services
Error detection and
correction.
Multiplexing protocols and
local networks (LANs).
Link layer technologies:

Ethernet – Local area
network protocol.
Representation of
different Link layer
technologies
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
3
‫‪Data Link‬‬
‫‪Layer services‬‬
‫‪4‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Data link layer – Communication framework
PDU (protocol data unit) – Data is transferred as units. May
include control data, addresses, or content.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
5
Data link layer- Communication framework
 Physicly connecting two devices.


host-router, router-router, host-host
Data unit: A frame.
application
Ht M transport
network
Hn Ht M
link
Hl Hn Ht M
physical
M
data link
protocol
phys. link
network
link
physical
Hl Hn Ht M
frame
adapter card
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
6
Data link layer services

Discrete messages, channel access:




Framing the data, adding a header and a trailer
A physical address to every header to identify source
and destination.
The physical address is not the IP address
A reliable delivery between two connected
physical devices:


Low throughput with low noise is rarely used.
Usually a wireless channel with errors is used.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
7
Data link layer services

Flow control:


Controlling the data transmission between two
computers (Sender and receiver).
Error detection:


Occur as a result of weakening the signal along the
cables, and noise.
The receiver detects the presence of errors.



Sender retransmits.
The receiver solves the problem by himself.
Error correction:


The receiver identifies the bit errors without
retransmission
Named FEC – Forward error correction.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
8
Implementation

Adapter – An extension card connected to the
motherboard.


E.g. Ethernet card.
Usually includes RAM, Link interface, host bus.
application
Ht M transport
network
Hn Ht M
link
Hl Hn Ht M
physical
M
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
data link
protocol
phys. link
©
adapter card
network
link
physical
Hl Hn Ht M
frame
9
‫מסגרות )‪(Frames‬‬
‫‪10‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Motivation

In stead of sending the data in one block, we break the
data to a series of frames:



Allows a smaller buffer size.
When the sending time is longer the probability for an error is
bigger, and retransmission is needed.
Better use of shared resources. (e.g. Multiplexed transmission)
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
11
Identifying frames

Counting bytes (A basic data unit of 8
bits).

This method is used to identify a frame.
Byte stuffing – Sending special
characters to identify the beginning or
the end of the frame.
 Bit stuffing – Sending a binary flag in
the beginning and the end of the frame.


The two methods are used.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
12
Frames
Starting and ending the frame with a
special binary code.
(Byte/Character stuffing)
 Starting and ending with a binary flag (bit
stuffing).

‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
13
Character Count
character count
5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3
frame 1
5 characters
frame 2
5 characters
frame 3
8 characters
frame 4
8 characters
one-bit error
5 1 2 3 4 7 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3
frame 1
frame 2
Now a character count
5 characters
(wrong)
Even if the bit checksum can identify an error, and the destination
knows that the frame is faulty, it cannot say when the next frame
starts.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
14
Byte Stuffing


Also referred as Character Stuffing.
ASCII characters are used as delimiters of the
frame. E.g. DLE STX and DLE ETX.
DLE STX
beginning
of frame



user data
DLE ETX
DLE(0x10): Data Link Escape
STX(0x02): Start of TeXt
ETX(0x03): End of TeXt
end of
frame
Problem: What if DLE is part of the data?
Solution: The sender adds additional DLE to the
data stream before every original DLE. (Stuffing)
The receiver removes the DLE before sending the
data to the communication layers above.
(Destuffing)
‫תקשורת מחשבים ואלגוריתמים‬
)2011-2012 ‫מבוזרים (חורף‬
©
15
Byte Staffing
user data 0x10
DLE stuffed at the sender
DLE destuffed at the receiver
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
16
Bit Stuffing

Every frame begins and ends in a special pattern called
flag byte [01111110].
flag
01111110
user data
beginning
of frame


01111110
end of
frame
Problem: The flag pattern may appear in the data
stream.
Solution:


Every time the link layer finds five continuous values 1 in
the data stream ([11111]) it will automatically add the
value 0 to the outgoing data stream.
When the receiver find five values of 1, it will automatically
remove the next 0.
‫תקשורת מחשבים ואלגוריתמים‬
)2011-2012 ‫מבוזרים (חורף‬
©
17
‫‪Bit Stuffing‬‬
‫‪18‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫‪Example: PPP protocol‬‬
‫‪19‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫‪Dealing with‬‬
‫‪errors‬‬
‫‪20‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Errors
Information may become faulty during
the transmission.
 Example: 1 bit error.


Example: a burst of errors.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
21
Dealing with errors
Frames
data:
include additional
 Discover
errors or validation.
 Additional data by the sender.
 Testing by the receiver.
 Trying to validate data by
statistics (Not absolute).
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
22
Error detection
EDC - Error Detection and Correction bits.
D represent a data protected by error detection and may include a
header
• Error detection is not 100% proof! Why?
- The protocol may miss some of the errors, but that rarely
happens.
- Longer EDC produces better error detection.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
23
Error detection 1: Parity check


Parity bit is a bit used as a check digit where its value signals if the
number of bits with the value of 1. Every word is added a bit to create
an even number of ‘1’. Two types of parity bits:

Even parity bit equals 0 if the number of ‘1’ values is even, and
equals 1 for uneven.

Odd parity bit equals 0 when the number of ‘1’ vales is odd, and
equals 1 for even.
Adding a parity bit in a bit stream allows error detection but do not
allow correction.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
24
Parity Checking - ‫בדיקת זוגיות‬

The parity bit is added to each data unit, where
the numbe of ‘1’ values is even. (or odd in odd
parity bit).
‫תקשורת מחשבים ואלגוריתמים‬
)2011-2012 ‫מבוזרים (חורף‬
©
25
Parity Checking - ‫בדיקת זוגיות‬

One dimensional parity check: Adding one bit
to every byte (7 bits) complimenting to an
even number of ‘1’ values.
‫תקשורת מחשבים ואלגוריתמים‬
)2011-2012 ‫מבוזרים (חורף‬
©
26
2D parity check
A two dimensional parity check: done by a longitudinal row check (LRC) and a
vertical row:
VRC
10110111
11010111
00111010
11110000
10001011
01011111
01111110
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
LRC
27
Checksum





Checksum is an error detection code that allow error
detection. It is a type of redundancy check.
The Checksum adds an additional part to the message which
is a result of a known function applied on the message.
It is possible to apply the function on the message and
validate that the result is identical to the result added to the
message.
The efficiency of the redundancy check depends on the
function chosen. The most simple redundancy function is the
identity function. Given a message M the output will be the
message itself.
Different Checksum methods include: Parity check, Modular
sum, CRC.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
28
Checksum



This function allow an efficient error detection. It do not
allow error correction because we cannot know if the error
was in the message or in the checksum.
Another simple function is given a message M the output will
be MM and when data is sent using the checksum there are 3
versions and in a case of an error we can compare and fix by
majority.
Checksum is the redundancy of the sum of all the bytes in
the data. Example: assume 4 bytes, 0x25, 0x62, 0x3F,0x52.
The sum is 0x118. We remove the carrier bit and get 0x18.
Calculating the Two’s complement gives 0xE8. That is the
“Modular sum” checksum.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
29
Calculating One’s complement
Representing negative numbers in a
simple way where we can subtract by
adding the negative of the number.
Calculating One’s complement:
Turn “1” to “0” and “0” to “1”
0 1 1 0 1 1 0 0
1 0 0 1 0 0 1 1
We would like that the addition would give zero.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
30
Calculating two’s complement
Solution: We calculate one’s complement and
add 1.
Calculating Two’s complement
1. Turn “1” to “0” and “0” to “1”
2. Add 1.
0 1 1 0 1 1 0 0
10 0 1 0 0 1 1
+ 1
1 0 0 1 0 10 0
31
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
31
‫חיסור בעזרת משלים ל – ‪1‬‬
‫קלט‪ Y ,X :‬מספרים בעלי "גודל" של ‪ n‬סיביות‪ ,‬מיוצגים ע"י משלים ל –‪ 1‬בעזרת ‪ n+1‬סיביות‪.‬‬
‫חשב‪ X + Y :‬והשאר התוצאה ב – ‪.1’s comp.‬‬
‫ביצוע‪ :‬א‪ .‬חבר ‪.X + Y‬‬
‫ב‪ .‬אם יש נשא סופי חבר אותו אל התוצאה (נשא מעגלי)‬
‫דוגמא ע"י ‪:n=3‬‬
‫‪X3 X2 X1 X0‬‬
‫‪Y3 Y2 Y1 Y0‬‬
‫‪c1 c0‬‬
‫‪c2‬‬
‫‪c3‬‬
‫‪Z3 Z2 Z1 Z0‬‬
‫‪2-4‬‬
‫‪0 0 1 0‬‬
‫‪1 0 11‬‬
‫‪11 0 1‬‬
‫‪-0010 = -2‬‬
‫‪C‬‬
‫נשא סופי‬
‫‪5-3‬‬
‫‪0 1 0 1‬‬
‫‪11 0 0‬‬
‫‪-0100‬‬
‫שלילי‬
‫נכונות‪:‬‬
‫ע"י חלוקה‬
‫למקרים‬
‫בדומה ל –‬
‫‪2’s comp.‬‬
‫‪-0011‬‬
‫‪1 0 0 01‬‬
‫©‬
‫‪+‬‬
‫‪0 0 10‬‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫‪32‬‬
‫דוגמאות לחיסור בעזרת משלים ל–‪1‬‬
‫דוגמא לתרגיל‬
‫חיסור ‪:‬‬
‫‪1 1 0 1 0‬‬
‫‪ 1 1 0 1‬‬
‫חיסור בעזרת המשלים ל‪:1 -‬‬
‫המשלים ל‪ 1 -‬של ‪ 01101‬הוא ‪.10010‬‬
‫‪0‬‬
‫‪1‬‬
‫‪0‬‬
‫‪1‬‬
‫‪0‬‬
‫‪0‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪0‬‬
‫‪0‬‬
‫‪1‬‬
‫‪0‬‬
‫‪1‬‬
‫‪0‬‬
‫‪1‬‬
‫‪1‬‬
‫‪33‬‬
‫(יש נשא)‬
‫‪1‬‬
‫‪‬‬
‫‪1‬‬
‫‪0‬‬
‫‪‬‬
‫‪0‬‬
‫דוגמא לתרגיל‬
‫חיסור ‪:‬‬
‫‪0‬‬
‫‪1‬‬
‫‪0‬‬
‫‪1‬‬
‫‪1‬‬
‫‪0‬‬
‫‪0‬‬
‫‪0‬‬
‫‪0‬‬
‫‪0‬‬
‫‪‬‬
‫‪1‬‬
‫חיסור בעזרת המשלים ל‪ :1 -‬המשלים ל‪ 1 -‬של‬
‫‪ 100000‬הוא ‪.011111‬‬
‫‪0‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪0‬‬
‫‪0‬‬
‫‪1‬‬
‫‪0‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪1‬‬
‫‪0‬‬
‫‪‬‬
‫‪0‬‬
‫‪1‬‬
‫אין נשא‪ .‬שלילת המשלים ל‪ 1 -‬של התוצאה היא‪:‬‬
‫‪-000110‬‬
‫חיסור בעזרת משלים ל –‪:2‬‬
‫קלט‪ X,Y :‬מספרים בינאריים בעלי ‪ n‬ספרות וספרת סימן )‪ (n+1‬מיוצגים‬
‫ע"י ‪2’s Complement‬‬
‫‪Xn-1Xn-2…X0‬‬
‫‪Yn-1Yn-2…Y0‬‬
‫קלט‪X,Y :‬‬
‫‪Xn-1Xn-2…X0‬‬
‫‪+‬‬
‫‪Yn-1Yn-2…Y0‬‬
‫חבר‪X+Y :‬‬
‫‪Zn-1Zn-2…Z0‬‬
‫נשא‬
‫‪Xn-1Xn-2…X1 X0‬‬
‫‪Yn-1Yn-2…Y1Y0‬‬
‫‪Z=X+Y‬‬
‫נשא סופי‬
‫בדוק גלישה ‪overflow‬‬
‫‪34‬‬
‫©‬
‫התוצאה הנה חיובית ‪ /‬שלילית בייצוג ‪.2’s Comp.‬‬
‫התעלם‬
‫מנשא סופי‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫דוגמא‪ ,n=3 :‬חשב ‪ -5 + (3)  3-5 ‬נזדקק ל ‪ 4 -‬סיביות (‪ )1+‬ביט סימן‪.‬‬
‫‪:3-5‬‬
‫‪–5=01012‬‬
‫‪10102‬‬
‫‪+‬‬
‫‪1‬‬
‫‪10112‬‬
‫‪:5-3‬‬
‫‪3 = 00112‬‬
‫‪0 0 11‬‬
‫‪1 0 11‬‬
‫‪1 1‬‬
‫שלילי‬
‫‪111 0 2’s Comp.‬‬
‫‪-2  - 0 0 1 0 2‬‬
‫‪– 3 = 0 01 1 2‬‬
‫‪5 = 01012‬‬
‫‪0101‬‬
‫‪‬‬
‫‪1101‬‬
‫‪11002‬‬
‫‪+‬‬
‫‪1‬‬
‫‪11012‬‬
‫‪0 1‬‬
‫‪1‬‬
‫‪0 010‬‬
‫©‬
‫נשא סופי‬
‫"התעלם"‪.‬‬
‫”‪“1‬‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫‪35‬‬
Error detection 2: Modular sum calculation
Sender does the following:
 Data is divided to k parts. Each
part is n bits long.
 Add all parts and use Two’s
complement.
 This is the checksum.
 The checksum is delivered with
the data.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
36
Modular sum calculation
The receiver performs the following:
 Data unit received is divided to k
parts. Each part is n bits long.
 Add all parts.
 Add the checksum.
 If the result is zero the data is
accepted. Otherwise it is rejected.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
37
‫‪38‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Modular sum example
Assume a 16 bit block sent and using 8 bit Modular
sum checksum.
10101001 00111001
We add the numbers using the Two’s complement.
10101001
00111001
-----------Sum 11100010
‫סיכום‬
One’s complement 00011101
1-‫המשלים ל‬
Two’s complement 00011110
The sent pattern: 10101001 00111001 00011110
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
39
Modular sum example
When the reciever receive the pattern and there are no errors,
10101001 00111001 00011101
When the receiver sums all the three parts he is
supposed to get a series of zeros. That means there are
no errors in transmission.
10101001
00111001
00011110
Sum
00000000
means that the pattern is OK.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
40
Modular sum example
Assuming there is a burst of 5 error bits which affect 4 bits.
10101111 11111001 00011101
When the receiver sums the three parts:
10101111
11111001
00011110
Partial Sum
1 11000110
the pattern is corrupted.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
41
Modular sum

Advantages:



Easy to calculate.
Small size.
Disadvantages:

Do not discover all errors

Example: 2nd bit is flipped in every part.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
42
‫)‪Cyclic redundancy check (CRC‬‬
‫‪Cyclic redundancy check (CRC) is a error detection code or a hash‬‬
‫‪function used to find errors in data transfer. Before data transfer CRC is‬‬
‫‪calculated and added to the transferred data.‬‬
‫‪ After the data transfer the receiver verifies using CRC that the data‬‬
‫‪transmitted with no errors. The CRC is common because of the ease of‬‬
‫‪binary hardware implementation, the ease of mathematic computation‬‬
‫‪and the efficiency in discovering common errors of noisy channels.‬‬
‫‪ ‬אופן הפעולה‬
‫‪ ‬שמסתכלים על כל וקטור באורך ‪ n‬כפולינום שמקדמיו הם קואורדינטות הווקטור‪CRC .‬‬
‫משתמש בפולינום המוגדר בפולינום יוצר מדרגה ‪ .r‬סוגים שונים של קוד ‪ CRC‬משתמשים‬
‫בפולינומים יוצרים שונים‪.‬‬
‫‪ ‬בהינתן פולינום יוצר מדרגה ‪ r‬ובהינתן הודעה ‪ M‬שברצוננו לקדד‪ ,‬עלינו לבצע את הפעולות‬
‫הבאות‪:‬‬
‫‪‬‬
‫‪.1‬‬
‫‪.2‬‬
‫‪.3‬‬
‫‪‬‬
‫‪‬‬
‫‪43‬‬
‫נוסיף ‪ r‬אפסים מימין להודעה‪.‬‬
‫נחלק בפולינום (תוך שימוש בחילוק של השדה מודולו ‪)2‬‬
‫נחסר את השארית תוך שימוש ב‪ xor -‬במקום בחיסור רגיל‪.‬‬
‫נצרף את התוצאה שקיבלנו מימין להודעה המקורית ונשלח‪.‬‬
‫כמו בכל קידוד ‪ ,Checksum‬הצד המקבל יבצע את שלבים ‪ 1‬ו‪ 2-‬ויוודא ש‪r -‬‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫הביטים האחרונים שנשלחו זהים לתוצאה שהתקבלה‪.‬‬
‫(חורף ‪)2011-2012‬‬
‫©‬
Cyclic Redundancy Check (CRC)






A popular error detection technique.
A binary data string length K represents a polynomial of
degree K. the K bits are the coefficients for the polynomial
G(x) with K powers of x, xk-1 to x0. 110001 represents the
polynomial G(x)=x5+x4+x0.
Possible generating polynomials:
G(x) = x16 + x15 + x2 + 1
CRC-16 (‫ סיביות בדיקה‬16)
G(x) = x16 + x12 + x5 + 1
CRC-16 ITU (‫ סיביות בדיקה‬16)
G(x) = x32 +x26 +x23 +x22 +x16 +x12 +x11 +x10 +x8 +x7 +x5
CRC-32 (‫ סיביות בדיקה‬32)
+x4 +x2 +x+1

This allows detection of one bit error, two bit error, up to 16
bit errors. 99.997% probability of detection 17 bit errors,
99.998 probability of detecting 18 bit errors and above.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
44
Cyclic Redundancy Check (CRC)


Every binary vector with n elements may
represent a polynomial where the elements are
the coefficients. CRC uses a r ranked generating
polynomial. Different CRC methodes use
different generating polynomials.
Given a polynomial ranked r and a message M:
1.
2.
3.

Add r zeros to the end of the message.
Divide by the polynomial.
Subtract the residue using XOR.
Add the result to the original message
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
45
CRC Algorithm



Sender has d data bits => D, as a binary number.
Sender and receiver choose an r+1 generating
pattern => G.
Choose r bits => R, such that:



<D,R> is divided by G
Receiver knows G, devides <D,R> by G. If the result is not
zero: Error detected.
Used in ATM, HDCL.
:XOR ‫טבלת‬
‫תקשורת מחשבים‬
‫ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬

46
©
CRC Example
D=101110, d=6, G=1001, r=3
=> <D,R> = 101110000
Want:
D.2r XOR R = nG
equivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by G,
want reminder R
R = remainder[
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
‫בחילוק עושים‬
‫ בין הביטים‬XOR
D.2r
]
G
©
47
‫‪Multiple Access‬‬
‫‪Protocols‬‬
‫‪48‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים‬
‫מבוזרים (חורף ‪)2011-2012‬‬
MAC (Multiple Access Control)
3 types:
 Channel Partitioning



Random Access



The channel is divided to timeslots.
Allocating timeslots to an edge for an exclusive use.
Allow collision.
Recovery after collision.
Taking turns

Monitoring the channel tightly to avoid collisions.
Advantages: Efficiency, equality,
simplicity, Distribution.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
49
TDMA MAC Protocol
TDMA: time division multiple access




Access to the channel is given by a queue. Stations
get a limited time to transmit when it gets the
entire bandwidth. The stations broadcast one after
another.
Time slots lengths are constant. Each cycle all
stations broadcast one time slot.
Unused timeslots are wasted.
Example: LAN with 6 stations. Stations 1,3,4
broadcast while the timeslots of stations 2,5,6 are
unused.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
50
FDMA MAC Protocol
FDMA: frequency division multiple access



Example: LAN with 6 stations. Stations 1,3,4 broadcast while the frequencies of stations
2,5,6 are unused.
frequency bands

The entire bandwidth is divided to equal frequency sub channels. Between
two sub channels a safety distance is defined – unused bandwidth.
Every channel get a sub channel with a constant frequency range.
Unused broadcast time is lost.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
51
CDMA(Code Division Multiple Access)




In CDMA broadcasts from all stations are divided over the time-frequency by
coding. CDMA is based on Spectrum Spread, that is distributing the original data
over a bigger bandwidth.
The source uses a chipping sequence to code the data over the entire bandwidth.
The receivers use their own chipping sequence to decode and transmit the data to
the target. Mainly used in satellite and cellular communication.
Encoded signal = Original data X Chipping sequence.
Decoding = Encoded signal X Chipping sequence.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
52
‫‪CDMA Encode/Decode‬‬
‫‪53‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫‪CDMA: two-sender interference‬‬
‫‪54‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Random Access protocols

When an edge has a packet to be sent




Two or more stations broadcast together =>
Collision.
MAC random access protocols detail:



The station will send the package over the entire bandwidth
of the channel. Rate R.
No priority for one station over the other.
How to discover a collision
How to recover from a collision (e.g. delay and
retransmission).
MAC protocols
ALOHA
 ALOHA slotted
 CSMA
and CSMA/CD
‫ואלגוריתמים מבוזרים‬
‫תקשורת מחשבים‬

)2011-2012 ‫(חורף‬
©
55
ALOHA protocol




Background – during the 70s the Hawaii university were developing a protocol for
channel access. Two main versions for the protocol: Pure Aloha and Slotted Aloha. The
difference between them is in the time division. The Pure Aloha protocol do not use
discrete timeslots while the Slotted Aloha uses them.
Pure Aloha – The basic idea is simple, users transmit when they have something to
transmit. When a collision occurs framed are destroyed. The broadcasting station
identifies collisions by listening to the channel. In case of a collision a random delay is in
order, followed by retransmission. If the time is not random than a collision will happen
again. Systems with shared channels in this fashion are called Contention systems.
Aloha transmission scheme:
Users transmit frames in a predefined length. When two frames are in the channel at the same time there is a
collision and both frames are lost. Notice that even if only the first bit of the new frame collides with the last bit
of the frame, the two frames are lost and will be retransmitted.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
56
Pure ALOHA


Pure Aloha: Simpler and uses no synchronization.
A frame is sent:


Sent with no wait to the time slot.
Collisions will grow:

A frame sent at time t0 will collide other frames sent between
times [t0-1, t0+1]
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
57
Pure ALOHA Efficiency
The analysis of the efficiency of a channel using this protocol.
What it the percentage of frames that will arrive to the destination
with no collisions.
 Frame time – the time needed to transmit a frame.
S - The average frame creation frequency. The transmission rate, l is
assumed to have Poison distribution. If S>1 the rate is higher then
the channel transmission rate. In this case almost every frame would
suffer from collisions. We must define 0<S<1 to have a reasonable
transmission.
G – Broadcast attempt rate. Assumed to have Poison distribution as
well. Of course, S<=G since there are more broadcast attempts than
actual data transfers. When the rate is low G~S and when the rate is
high S~P0G.

P0 – The probability of having a successful transmission.
We assume that the next frame will not be created until the current
frame is transmitted.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
58
Pure ALOHA Efficiency
t – Time needed to send a frame.
t0 – The transmission start time.
If a user sends another frame between t0 to
t0+t, it will collide with the grey frame.
Also, any frame starting between t0+t to
t0+2t would collide with the frame.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
59
‫‪60‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Pure ALOHA Efficiency


The quiet interval is 2t. The time delay needed in order to avoid a collision.
The probability of creating K frames in one time frame is given by the Poison
distribution:
K G
PK  
G e
K!
P0  e G

The probability of having no frames is:

During 2t interval the broadcast attempts are 2G and the probability of no frames is:

The rate of frame creation is:

We can see that the maximum throughput is when G=0.5, and:
P[0]  e 2G
S  G  P[0]  G  e 2G
S


1
 0.184  18.4%
2e
The maximum throughput is very low.
We can try to optimize by manipulating G but if we enlarge the broadcast frequency
too much the probability of no collisions is lower. Tradeoff!
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
61
‫‪Throughput vs. offered traffic‬‬
‫‪62‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Slotted Aloha
In 1972 the Slotted Aloha method was published, aimed to double
the throughput.



The method suggested divide the time to intervals where one frame
would fit a time slot.
This attitude needs a synchronization between the users. May be done
by beeping by one of the stations.
Method:



Time is divided to slots which fit a frame.
The edge waits with a frame and will transmit at the next slot time.
If a collision is detected: Retransmit at the next time slot with the probability P. Repeat until
successful transmission.
©
Success (S), Collision
(C), Empty (E) slots
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
63
‫‪Slotted Aloha Efficiency‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫‪‬‬
‫בשיטה זו‪ ,‬התחנה אינה רשאית לשלוח מידע כל הזמן‪ .‬התחנה נאלצת לחכות לתחילת מקטע‬
‫הזמן הבא‪ .‬אינטרוול השקט קטן פי ‪ 2‬והוא כעת ‪ t‬בלבד‪.‬‬
‫‪G‬‬
‫‪G‬‬
‫ההסתברות לחוסר התנגשות כעת היא ‪ P[0]  e‬ולכן ‪. S  e  G -‬‬
‫כפי שניתן לראות‪ Slotted Aloha ,‬מגיע לשיא כאשר ‪ , G  1‬בתפוקה מקסימאלית‬
‫‪1‬‬
‫של ‪ ,  0.368‬פעמיים מהתפוקה המקסימאלית של ‪.pure Aloha‬‬
‫‪e‬‬
‫במקרה האופטימאלי נוכל להגיע בפרוטוקול זה להסתברות של ‪ 37%‬למקטעים ריקים (אי‪-‬‬
‫שידור)‪ ,‬הסתברות של ‪ 37%‬הצלחות‪.‬‬
‫עבודה ב‪ G -‬גבוה יותר תקטין את מספר המקטעים הריקים‪ ,‬אך תגדיל את מספר‬
‫ההתנגשויות‪ .‬הסתברות לכך ששידור ידרוש ‪ K‬ניסיונות (כלומר‪ K  1 ,‬התנגשויות‪ ,‬הצלחה‬
‫אחת)‪:‬‬
‫‪P  e  G (1  e  G ) K 1‬‬
‫‪K‬‬
‫התנגשות‬
‫‪‬‬
‫‪‬‬
‫‪k 1‬‬
‫פעמים‬
‫חוסר התנגשות פעם אחת‬
‫‪G k 1‬‬
‫‪G‬‬
‫‪e‬‬
‫‪‬‬
‫) ‪E   kPk   k e G (1  e‬‬
‫מספר ניסיונות ממוצע לשידור (תוחלת)‪:‬‬
‫מספר השידורים הממוצע תלוי בצורה מעריכית ב‪ ,G -‬ולכן עלייה קטנה בעומס‪,‬תגרום עלייה‬
‫אקספוננציאלית במספר ניסיונות השידור ובכך תוריד את הביצועים בצורה חדה‪.‬‬
‫‪k 1‬‬
‫‪64‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
Slotted Aloha Efficiency



This method to not allow starting of transmission at any given
time. The station has to wait to the next interval. The quiet
interval is now halved to only t.
G
The probability of no collision is now: P[0]  e
Resulting:
S  e G  G
As shown slotted aloha has its maximum efficiency when G=1 and
is equal: 1
e


 0.368
That is twice the throughput of Pure Aloha.
Using the optimal case we may get a probability of 37% of empty
slots and 37% of successful transmission.
The probability that a transmission will take K transmission
attempts, that is k-1 attempts and one success is:
PK  e  G (1  e  G ) K 1

The mean transmission attempts (Average):
E   kPk   k e G (1  e G ) k 1  e G
 Average transmission attempts depends
exponentially on G
k 1
©
65
Carrier Sense multiple Access – CSMA



Slotted Aloha allows a maximal throughput of 1/e. This is very low since
there is no ability to identify if the channel is free or occupied.
In many Local Area Networks the stations can identify what the other
stations are doing and change their behavior accordingly. These networks
may perform much better than Slotted Aloha.
Protocols that listen to the broadcast and change behavior are called
Carrier sense protocols.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
66
Carrier Sense multiple Access – CSMA
Persistent and Non-persistent CSMA
 1 Persistent CSMA





When a station has some data to transmit, it first listens to the channel and checks if
someone else is already transmitting. When a station recognizes that the channel is
free it transmits a frame. If there is a collision the station waits a random time and
starts again.
This protocol is called 1 Persistent since the station is transmitting in probability 1 in
case that the channel is free.
Propagating time has a major effect on the performance of this protocol. There is a
chance that another station started sending a packet, both stations check the
channel. If their signals didn’t reach the other station, the other station will sense a
free channel and start to transmit as well. Collision will occure.
If the propagating time is zero, there are still going to be collisions because if two
stations would like to transmit at the same time as a third station they both are
going to wait until the end of transmission to start their own transmission at the
same time. Still, this protocol shows a significant improvement from Pure Aloha since
the stations wait until the end of the third transmission.
Intuitively there is an improvement from both Aloha protocols.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
67
CSMA

p persistent CSMA



This protocol is used in slotted channels. When a station is ready to
transmit it checks the channel, if it is free it will transmit in
probability p, or wait until the next segment in probability q=1-p. If
the station waits it will go over the protocol again and transmit in
probability p or wait in probability q and so on... This happens until a
frame is transmitted or until another station started to transmit.
The graph shows the throughput as a function of transmission
attempts. The delays are not referred.
For a very high transmission rate queues start to build and the buffer
needs to grow. Transmission that was once bursting is turning into a
constant data flow, and we can switch to TDM system. There is a
transmission at every timeslot and the throughput is 100% when we
disregard the delay.
68
©
CSMA/CD - CSMA with Collision Detection







Another performance increase will be achieved when the stations will stop their
transmission in case of a collision detection.
If two stations sense a free channel and start to transmit at the same time, they
both will detect the collision almost immediately. The stations will stop their
transmission immediately in stead of finishing the transmission of the frames.
A fast transmission stop saves time and bandwidth.
CSMA/CD is used on LAN networks over the MAC layer.
CSMA/CD uses the following model:
At a certain time a station stopped transmitting. Any station may transmit now. If
two or more stations decide to transmit together there is going to be a collision, a
station may identify a collision by watching the power or the width of the transmitter
pulses.
When a station identifies a collision, transmission is stopped, a random time is
waited, and retransmission will be attempted. That is why the CSMA/CD model
alternates between contention slots and data frames. Quiet times appear where no
station is transmitting.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
69
CSMA/CD
CSMA/CD:




Collisions are detected shortly after they occur.
A collided transmission is stopped, and lowers
transmission loss.
Retransmission may be forced.
Collision detection:



Easy with cabled LAN: Measuring signal channel,
comparing transmitted signal to the received signal.
Difficult in wireless: Since the receivers may miss the
collision.
In practice the network has a “jamming time” to make
sure everyone received the collision signal.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
70
“Taking Turns” MAC protocols
data
data
Polling:
 The master is inviting
the slaves to transmit
poll
according to a queue.
master
 Typically silent devices
are used.
 Issues:

slaves


‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
Overhead- wasted time
Reaction time- the time
between the invitation and
the beginning of the
transmission.
One failure vulnerabilityThe master may have
problems.
71
“Taking Turns” MAC
T
Token passing:


(nothing
to send)

Controlled token pass between one
edge to another.
Token message.
Issues:
-Token overhead – wasted time
-Reaction time- Between
receiving the token and
transmitting the data.
-One failure vulnerability –
Token issues.
T
data
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
72
MAC protocols overview

How to use shared media?


Channel divided by time, frequency, or code.
Random, dynamic division.




ALOHA, S-ALOHA, CSMA, CSMA/CD
Carrier sensing easy to implement over wired
technology, difficult over wireless.
CSMA/CD is used over Ethernet.
Taking Turns


Choosing the transmitting edge by a central
processor or a token.
Bluetooth, FDDI (Fiber Distributed Data Inteface),
IBM Token ring.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
73
MAC protocols overview
Channel partitioning MAC protocols
 High efficiency in high loads
 Not efficient on low loads: Access delay, 1/N bandwidth
is assigned even if only one computer is active.
Random access MAC protocols
 Efficient in low load: One edge can utilize the entire
channel.
 Not efficient on high load, multiple collisions.
Taking turns
 Most efficient for high or low load.
 Sensitive failure points.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
74
‫‪LAN Technologies‬‬
‫‪75‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
LAN technologies
Until now we covered Data Link layer issues :
 Services, error detection/correction, multiple access.
Next: LAN technologies
 Addressing – accessing network resources.
 Ethernet – LAN protocol.
 Network devices that find the route of datapackets to
their destination: Hubs, bridges, switches.
 IEEE - 802.XX netork standards. Among them is
802.11.
 PPP – point to point protocol
 ATM – High throughput protocol.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
76
MAC Addresses and ARP
 32-bit


IP address:
network-layer address
used to get datagram to destination IP subnet
 MAC
(or LAN or physical or Ethernet)
address:


function: get frame from one interface to
another physically-connected interface (same
network)
48 bit MAC address (for most LANs)

burned in NIC ROM, also sometimes software
settable
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
5-79
LAN Addresses and ARP
Each adapter on LAN has unique LAN address
1A-2F-BB-76-09-AD
LAN
(wired or
wireless)
Broadcast address =
FF-FF-FF-FF-FF-FF
= adapter
71-65-F7-2B-08-53
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
5-80
LAN Address (more)




MAC address allocation administered by IEEE
manufacturer buys portion of MAC address space
(to assure uniqueness)
analogy:
(a) MAC address: like Social Security Number
(b) IP address: like postal address
MAC flat address ➜ portability


can move LAN card from one LAN to another
IP hierarchical address NOT portable

address depends on IP subnet to which node is attached
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
5-81
ARP: Address Resolution Protocol
Question: how to determine
MAC address of B
knowing B’s IP address?
137.196.7.78
1A-2F-BB-76-09-AD
137.196.7.23
137.196.7.14
LAN
71-65-F7-2B-08-53
137.196.7.88
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
Each IP node (host,
router) on LAN has
ARP table
ARP table: IP/MAC
address mappings for
some LAN nodes

< IP address; MAC address;
TTL>
TTL (Time To Live):
time after which
58-23-D7-FA-20-B0
address mapping will
be forgotten (typically
0C-C4-11-6F-E3-98
20 min)
©


5-82
ARP protocol: Same LAN (network)
A wants to send
datagram to B, and B’s
MAC address not in A’s
ARP table.
A broadcasts ARP query
packet, containing B's IP
address
dest MAC address = 
FF-FF-FF-FF-FF-FF
all machines on LAN 
receive ARP query
B receives ARP packet,
replies to A with its (B's)
MAC address
frame sent to A’s MAC
address
‫ואלגוריתמים מבוזרים‬
‫(תקשורת מחשבים‬unicast)
)2011-2012 ‫(חורף‬

A caches (saves) IP-toMAC address pair in its
ARP table until information
becomes old (times out)
soft state: information 
that times out (goes
away) unless refreshed

ARP is “plug-andplay”:
nodes create their ARP
tables without
intervention from net
administrator





©
5-83
DHCP: Dynamic Host Configuration Protocol
Goal: allow host to dynamically obtain its IP
address from network server when joining
network
support for mobile users joining network 
host holds address only while connected and 
“on” (allowing address reuse)
renew address already in use 
DHCP overview: 
1. host broadcasts “DHCP discover” msg 
2. DHCP server responds with “DHCP offer” 
msg
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
©
3. host
requests IP address:
“DHCP request”  5-84
)2011-2012
‫(חורף‬
DHCP client-server scenario
A
223.1.2.1
DHCP
server
223.1.1.1
223.1.1.2
223.1.1.4
223.1.2.9
B
223.1.2.2
223.1.1.3
223.1.3.1
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
223.1.3.27
223.1.3.2
©
E
arriving DHCP
client needs
address in this
(223.1.2/24) network
5-85
DHCP client-server scenario
DHCP server: 223.1.2.5
DHCP discover
arriving
client
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
DHCP request
time
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
5-86
Addressing: routing to another LAN
walkthrough: send datagram from A to B via R
assume A knows B’s IP address
88-B2-2F-54-1A-0F
74-29-9C-E8-FF-55
A
111.111.111.111
E6-E9-00-17-BB-4B
1A-23-F9-CD-06-9B
222.222.222.220
111.111.111.110
111.111.111.112
R
222.222.222.221
222.222.222.222
B
49-BD-D2-C7-56-2A
CC-49-DE-D0-AB-7D
two ARP tables in router R, one for each IP
network (LAN)
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©

5-87
A creates IP datagram with source A, destination B 
A uses ARP to get R’s MAC address for 111.111.111.110 
A creates link-layer frame with R's MAC address as dest, 
frame contains A-to-BThis
IP isdatagram
a really important
A’s NIC
sends– frame
example
make sureyou
understand!
R’s NIC receives frame

R removes IP datagram from Ethernet frame, sees its 
destined to B
R uses ARP to get B’s MAC address 
R creates frame containing A-to-B IP datagram sends to 
B
88-B2-2F-54-1A-0F
74-29-9C-E8-FF-55
A
E6-E9-00-17-BB-4B
111.111.111.111
222.222.222.221
1A-23-F9-CD-06-9B
222.222.222.220
111.111.111.110
111.111.111.112
‫ ואלגוריתמים מבוזרים‬CC-49-DE-D0-AB-7D
‫תקשורת מחשבים‬
)2011-2012 ‫(חורף‬
R
222.222.222.222
B
49-BD-D2-C7-56-2A
©
5-88
Ethernet
LAN is a dominant technology:
 Inexpensive – about 20$ for a 100Mbps device.
 Common over the LAN.
 Less expensive and simpler than token technologies and ATM.
 Bitrates: 10, 100, 1000 Mbps
Metcalfe’s Etheret sketch
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
90
Ethernet frames

The framing includes the following:
 Framing, the ability to identify the beginning and the end
of a message.
 Addressing: Fields that include source and destination
addresses.
 Error detection: Redundancy codes designed to find
transmission errors.
Preamble - Sets of bits101010 used to declare the
frame existance.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
©
)2011-2012 ‫(חורף‬
91
Ethernet frames




Addressing: 6 Bytes, accepted by all the LAN
devices, unused if the address do not match.
Type: Defines the data type that is going to be
on the data field. Allows us to work with several
higher protocols, IP, DECNET, or IPX.
Data: The size of the data field is between 46 to
1500.
CRC: The receiver check for errors. If there are
errors the frame is not used.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
92
Ethernet implementation


The Ethernet is based on CSMA/CD - Carrier Sense Multiple
Access/Collision Detection.
Network access in 4 steps:
1.
2.
3.
4.
Sensing – The station checks if there is a carrier, that is if someone is
transmitting.
The station waits 9.6 microseconds, and if there is no broadcast at the
time the station is transmitting but keeps monitoring.
The frame transmitted is distributed all over the network. It is possible
that another station have been waiting and starts to transmit. In this
case both stations detect collision and stops the transmission.
Both stations would try to transmit again later. The probability that
they would try to transmit at the same time again is lowered by using a
special algorithm, BACK OFF algorithm, implemented over the NIC.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
93
CSMA/CD Algorithm
A: sense channel, if idle
then {
transmit and monitor the channel;
If detect another transmission
then {
abort and send jam signal;
update # collisions;
delay as required by exponential backoff algorithm;
goto A
}
else {done with the frame; set collisions to zero}
}
else {wait until ongoing transmission is over and goto A}
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
94
Ethernet’s CSMA/CD
Jam Signal:
 Make sure that all others are aware of the collision.
48 bits
Exponential Backoff:
 Make sure that the transmission is getting adjusted
to the current load.

Heavy load: longer wait.
First collision: choose K out of {0,1}; the delay is
K X send time of 512 bits. (on a 10 Mbps it is 51.2
microseconds)
 N-th collision choose K out of {0,1,…, 2n-1} .
 After 10 collisions or more choose K out of
{0,1,2,3,4,…,1023}. ©
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
95

)2011-2012 ‫(חורף‬
Ethernet: 10Base2



10:10Mbps 2: Maximum cable length 200m.
Thin coaxial cable in bus technology.
Amplifiers are used to connect many
segments.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
96
Ethernet 10BaseT and 100BaseT




Frequency of 10/100 Mbps is called fast Ethernet.
T: Twisted Pair.
Uses Hub to connect computers with twisted pairs, that’s why
this technology is called Star topology.
CSMA/CD is applied by the hub.
twisted pair
hub



Maximum distance between the computer and the hub is 100m.
Hub may disconnect noisy adapters.
Hub may statistically monitor the throughput for the Admin.
Ethernet 1Gbit





Uses the standard Ethernet frame.
Allows point to point and broadcast to all the LAN.
Uses CSMA/CD with short distances for high
efficiency.
Buffered Distributors in stead of hubs.
Full Duplex needed for 1Gbps point to point.


Half duplex – data can flow only in one direction at a
certain time.
Full duplex – data may flow both directions at the same
time.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
98
Token Ring



Since CSMA is based on contention, it may not be efficient.
Token Ring systems use a different approach.
Network access is given to the station that holds the token. Than
the token is passed to other stations until reaching a station
waiting to submit a message.
Two topologies: Token passing rings and token passing
busses. Token passing ring the ring topology defines the logical
topology- the order of message passing. The token passing bus
is more flexible, the order of message passing is determined by
tables stored at each station. If there is a station that do not
initiate messages (such as a printer), it may only end the cycle,
and will not be included in the tables. If one station needs high
priority it may appear several times in the tables.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
99
Token passing rings and token passing busses
Token passing busses: Stations are
physically connected on a bus
but organized as a ring by the
software.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
Token passing rings: The ring topology
defines the logical topology, the
order of message passing.
LAN extension
 Motivation:
Distance limitation.
 Lower performance with more users.

 Devices:
 Hub
 Repeater
 Bridge
 Switch
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
101
Hub - ‫מרכזיה‬
The Hub is a central point to the
entire network. A differen cable
connect each computer to the
Hub.
HUB



Each Ethernet frame is sent from one port to
all the other ports.



Hardware
Creates one LAN segment
Logically distributes the signals.
Every signal goes to all the ports.
Single collision segment
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
102
Repeaters - ‫מגבר משחזר‬
Ethernet segment
Ethernet segment
R
Direct connection
Repeater



Repeater – connects two segments of the same network and allows extension
of the distance between the two ends of the network. The repeater is acting
when a transmission is received in one of its ends, cleans the signals,
amplifies the signal and transmits it on the other side. A repeater do not
confine the broadcast segments or collision segments.
Each communication media uses its own repeater. different devices exist for
different media, for example, fiber optics and wireless.
It is possible to extend the network with a repeater and renew weak signals.



Hardware.
Connects two LAN segments.
Copies a signal from one segment to another.



Amplifies the signal.
Adds noise and collisions.
Full duplex - Works on both ways at the same time.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
Bridges





Bridge connects two LAN networks
Bridge, as opposed to a HUB, differentiate the collision segments of each
sub network. It learns the network and knows how to route packets to
the right port according to the MAC address and a bridging table.
The bridge learns the topology dynamically and the bridge is transparent
to all the clients. When a packet is received the bridge keeps the source
address and the port received if not already exists and the current time.
If the destination address does not exist in the table, the bridge will send
a copy of the packet to all other ports according to CSMA/CD. If the
address exists, packets will be directed to the port.
The bridge will delete records when their aging time is high over a
predefined time.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
104
Bridges



Link layer hardware.
Connects two LAN segments.
Frame delivery






Do not extend noise or collisions.
Learns the addresses and filters.
Transparent


Stores and sends Ethernet frames.
Examines the frame header and selectively sends the frame according
to the destination’s MAC.
When the frame is sent to the LAN segment, CSMA/CD is used in order
to access the segment.
Computers are not aware of the bridge existance.
Plug-and-play, Self-learning.

Bridge does not need to be configured.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
105
Bridges differentiate the load


Bridge breaks the local network to smaller
segments.
The bridge filters packets:


Frames of the same segments are not sent to other
segments.
The small LAN segments are different collision
segments.
collision
domain
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
LAN segment
bridge
©
collision
domain
LAN segment
= hub
= host
106
Bridge learning algorithm
Listens in mixed mode, all frames are
copied and analyzed.
 Looks at the source addresses of
incoming frames.
 Prepares a list of the computers on each
segment.
 Retransmits only if needed.
 Always retransmits on
broadcast/multicast.

‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
107
Bridge learning algorithm
A bridge has a bridge table.
 Writing to the bridge table:




LAN addresses of the edges, the ports and the
current time.
Old records are deleted (60 min. lifetime).
The bridge learns which computers could
be accessed through each port.


When a frame is received, the bridge learns
the sender’s position, LAN segment.
A record of the tuple sender-position on the
bridge table.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
108
Bridge example
Assume that C sends a frame to D and D returns
another frame to C.
The
bridge receive a frame from C.
C do not appear on the bridging table.
Since D do not appear on the bridging table the bridge
sends a frame to ports 2 and 3.
Frame is received by D
109
©
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
Bridge example


D creates a frame for C and sends it.
The bridge receives the frame.


Notice that now D is on port 2 in the bridging table.
The bridge knows that C is on port 1 and selectively
transmits the frame on port 1.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
110
‫‪Spanning tree algorithm‬‬
‫‪112‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬
‫אלגוריתם של עץ פורש‬
Spanning Tree Algorithm

A bridges network is a graph.

Usually the graph is hierarchal.



Spanning tree may find a sub graph that spans
all the edges with no loop.



If the bridge is at the end of the hierarchy it fails – LAN could be
disconnected.
If the same data is duplicated too many times over the LAN –
May even cause a network failure.
Spanning – All LAN segments are included.
Tree – one topology without loops.
Distributed protocol:


Determines which bridge is the root.
Every bridge directs ports that are not part of the tree
to other ports.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
113
Spanning Tree example
B8
B3
B5
B7
B2
B1
B6
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
The protocol:
1. Choose a root.
2. For each LAN choose
the closest bridge to
the root.
3. All LAN bridges send
packets towards the
bridge closest to the
root.
B4
©
114
Spanning Tree example
B8
Spanning Tree:
B3
B5
B1
B7
B2
B2
B1
Root
B5
B7
B8
B6
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
B4
B4
©
115
Switch
High performance, doubles the bridge
interfaces.
 Physically similar to HUB.
 Logically similar to bridge.






Works on the packets.
Understands addresses.
Forwards a message only when needed.
Enhanced forwarding algorithms
Allows full duplex.
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
)2011-2012 ‫(חורף‬
©
116
‫‪Typical setup‬‬
‫‪117‬‬
‫©‬
‫תקשורת מחשבים ואלגוריתמים מבוזרים‬
‫(חורף ‪)2011-2012‬‬