Post on 13-Jan-2016
Computer Communication and
Distributed Algorithms
202-2-1131
Data link layer
תקשורת מחשבים ואלגוריתמים © (2011-2012מבוזרים )חורף
1
©
Data link layer
Application
Physical
Link
Network
Transport
Session
Presentation
The 7-layer OSI Model
תקשורת מחשבים ואלגוריתמים מבוזרים 2(2011-2012)חורף
©
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.
Representation of different Link layer technologies
Overview: Link layer services Error detection and
correction. Multiplexing protocols and
local networks (LANs). Link layer technologies:
Ethernet – Local area network protocol.
תקשורת מחשבים ואלגוריתמים מבוזרים 3(2011-2012)חורף
©
Data link layer – Communication framework
PDU (protocol data unit) – Data is transferred as units. May include control data, addresses, or content.
תקשורת מחשבים ואלגוריתמים מבוזרים 5(2011-2012)חורף
©
Physicly connecting two devices. host-router, router-router, host-host
Data unit: A frame.
applicationtransportnetwork
linkphysical
networklink
physical
M
M
M
M
Ht
HtHn
HtHnHl MHtHnHl
framephys. link
data linkprotocol
adapter card
Data link layer- Communication framework
תקשורת מחשבים ואלגוריתמים מבוזרים 6(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 7(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 8(2011-2012)חורף
Implementation Adapter – An extension card connected to the
motherboard. E.g. Ethernet card. Usually includes RAM, Link interface, host bus.
adapter card
applicationtransportnetwork
linkphysical
networklink
physical
M
M
M
M
Ht
HtHn
HtHnHl MHtHnHl
framephys. link
data linkprotocol
תקשורת מחשבים ואלגוריתמים מבוזרים 9(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)
11תקשורת מחשבים ואלגוריתמים
(2011-2012מבוזרים )חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 12(2011-2012)חורף
©
Frames
Starting and ending the frame with a special binary code. (Byte/Character stuffing)
Starting and ending with a binary flag (bit stuffing).
תקשורת מחשבים ואלגוריתמים מבוזרים 13(2011-2012)חורף
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
character count
frame 15 characters
frame 25 characters
frame 38 characters
frame 48 characters
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 2(wrong)
frame 15 characters
one-bit error
Now a character count
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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 14(2011-2012)חורף
©
Byte Stuffing Also referred as Character Stuffing. ASCII characters are used as delimiters of the
frame. E.g. DLE STX and DLE ETX.
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)
DLE STX user data DLE ETX
beginningof frame
end offrame
DLE(0x10): Data Link EscapeSTX(0x02): Start of TeXtETX(0x03): End of TeXt
15תקשורת מחשבים ואלגוריתמים
( 2011-2012מבוזרים )חורף
©
Byte Staffing
user data 0x10
DLE stuffed at the sender
DLE destuffed at the receiver
תקשורת מחשבים ואלגוריתמים מבוזרים 16(2011-2012)חורף
©
Bit Stuffing Every frame begins and ends in a special pattern called
flag byte [01111110].
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.
01111110 user data 01111110
beginningof frame
end offrame
flag
תקשורת מחשבים ואלגוריתמים 17( 2011-2012מבוזרים )חורף
©
Errors
Information may become faulty during the transmission.
Example: 1 bit error.
Example: a burst of errors.
תקשורת מחשבים ואלגוריתמים מבוזרים 21(2011-2012)חורף
©
Dealing with errors
Frames include additional data:Discover errors or validation.Additional data by the sender.Testing by the receiver.Trying to validate data by statistics (Not absolute).
תקשורת מחשבים ואלגוריתמים מבוזרים 22(2011-2012)חורף
©
Error detectionEDC - 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 23(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 24(2011-2012)חורף
©
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).
תקשורת מחשבים ואלגוריתמים 25(2011-2012מבוזרים )חורף
Parity Checking - בדיקת זוגיות
One dimensional parity check: Adding one bit to every byte (7 bits) complimenting to an even number of ‘1’ values.
© תקשורת מחשבים ואלגוריתמים 26(2011-2012מבוזרים )חורף
©
2D parity check
1 0 1 1 0 1 1 11 1 0 1 0 1 1 10 0 1 1 1 0 1 01 1 1 1 0 0 0 01 0 0 0 1 0 1 10 1 0 1 1 1 1 10 1 1 1 1 1 1 0
VRC
LRC
A two dimensional parity check: done by a longitudinal row check )LRC( and a vertical row:
תקשורת מחשבים ואלגוריתמים מבוזרים 27(2011-2012)חורף
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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 28(2011-2012)חורף
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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 29(2011-2012)חורף
Calculating One’s complement
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
Representing negative numbers in a simple way where we can subtract by adding the negative of the number.
We would like that the addition would give zero.
תקשורת מחשבים ואלגוריתמים מבוזרים ©(2011-2012)חורף
30
31
Calculating two’s complement
Calculating Two’s complement
1. Turn “1” to “0” and “0” to “1”
2. Add 1. 0 1 1 0 1 1 0 0
1 0 0 1 0 0 1 1 + 1
1 0 0 1 0 1 0 0
Solution: We calculate one’s complement and add 1.
© תקשורת מחשבים ואלגוריתמים מבוזרים
(2011-2012)חורף 31
1חיסור בעזרת משלים ל –
סיביות.n+1 בעזרת 1 סיביות, מיוצגים ע"י משלים ל –n מספרים בעלי "גודל" של X, Y קלט:..s comp’1 והשאר התוצאה ב – X + Y חשב:
.X + Yא. חבר ביצוע:(נשא מעגלי)ב. אם יש נשא סופי חבר אותו אל התוצאה
:n=3דוגמא ע"י
X3X2X1X0
Y3Y2Y1Y0
Z3Z2Z1Z0
c0c1c2c3
C
נכונות:ע"י חלוקה
למקרים בדומה ל –
2’s comp.נשא סופי
1 0 1 1 1 1 0 10 1 0 0 2 - 4
-0100
שלילי -0010 = -2
1 0 0 0
0 0 1 11 0 1 0 5 - 3
-00111
+
0 0 1 032תקשורת מחשבים ואלגוריתמים מבוזרים
(2011-2012)חורף ©
1011
01011
: 1חיסור בעזרת המשלים ל- .10010 הוא 01101 של 1המשלים ל-
10110
1
00110
01001
01011
)יש נשא(
דוגמא לתרגיל: חיסור
000001
01011
: המשלים 1חיסור בעזרת המשלים ל- .011111 הוא 100000 של 1ל-
100111
111110
010110
של התוצאה 1אין נשא. שלילת המשלים ל- -000110היא:
1דוגמאות לחיסור בעזרת משלים ל–
33
דוגמא לתרגיל: חיסור
:2חיסור בעזרת משלים ל –
)n+1( ספרות וספרת סימן n מספרים בינאריים בעלי X,Y קלט:s Complement’2 מיוצגים ע"י
X,Yקלט:
X+Yחבר:
overflowבדוק גלישה
Z=X+Y
Xn-1Xn-2…X1 X0
Yn-1Yn-2…Y1Y0
Zn-1Zn-2…Z0
נשא
נשא סופי התעלם
מנשא סופי
.. s Comp’2התוצאה הנה חיובית / שלילית בייצוג
Xn-1Xn-2…X0
Yn-1Yn-2…Y0
Xn-1Xn-2…X0
+Yn-1Yn-2…Y0
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
34 ©
5 = 01012 – 3 = 0 01 1 2
1 1 0 1 2 0 1 0 0
1 0 1 1
1 0 1 0
10
) ביט סימן.1 סיביות (+4 נזדקק ל - 3-5 ) 3 + (5-, חשב n=3דוגמא:
1“1”
נשא סופי "התעלם".
3 = 00112 – 5 = 0 1 0 1 2
1 0 1 1 22 0 1 0 0 -
0 1 1 1
1 1 0 11 1 0 0
11
שלילי-2
2’s Comp.
35
1 0 1 0 2
+ 1
1 1 0 0 2
+ 1
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
©
:3-5
:5-3
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 36(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 37(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 00011110The sent pattern: 10101001 00111001 00011110
תקשורת מחשבים ואלגוריתמים מבוזרים 39(2011-2012)חורף
©
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 0011100100011110
Sum 00000000 means that the pattern is OK.
תקשורת מחשבים ואלגוריתמים מבוזרים 40(2011-2012)חורף
©
Modular sum exampleAssuming there is a burst of 5 error bits which affect 4 bits.
10101111 11111001 00011101When the receiver sums the three parts:
1010111111111001 00011110
Partial Sum 1 11000110
the pattern is corrupted.
תקשורת מחשבים ואלגוריתמים מבוזרים 41(2011-2012)חורף
©
Modular sum
Advantages: Easy to calculate. Small size.
Disadvantages: Do not discover all errors
Example: 2nd bit is flipped in every part.
תקשורת מחשבים ואלגוריתמים מבוזרים 42(2011-2012)חורף
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.
אופן הפעולהוקטור באורך CRC כפולינום שמקדמיו הם קואורדינטות הווקטור. nשמסתכלים על כל
מדרגה יוצר בפולינום המוגדר בפולינום קוד r.משתמש של שונים סוגים CRC משתמשים בפולינומים יוצרים שונים.
מדרגה יוצר פולינום הודעה r בהינתן את Mובהינתן לבצע עלינו לקדד, שברצוננו הפעולות הבאות:
p נוסיףr .אפסים מימין להודעה p ( 2נחלק בפולינום )תוך שימוש בחילוק של השדה מודולוp-נחסר את השארית תוך שימוש בxor .במקום בחיסור רגיל
.נצרף את התוצאה שקיבלנו מימין להודעה המקורית ונשלחכמו בכל קידוד, Checksum יבצע את שלבים ו-1הצד המקבל ויוודא ש-2 r
הביטים האחרונים שנשלחו זהים לתוצאה שהתקבלה. ©
תקשורת מחשבים ואלגוריתמים מבוזרים 43(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 +x4
+x2 +x+1 CRC-32 ( 32 סיביות בדיקה ) 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 44(2011-2012)חורף
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. Add r zeros to the end of the message.2. Divide by the polynomial.3. Subtract the residue using XOR.
Add the result to the original message
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 45
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:
CRC Algorithm
©
תקשורת מחשבים 46ואלגוריתמים מבוזרים
(2011-2012)חורף
©
CRC ExampleD=101110, d=6, G=1001, r=3
>=< D,R> = 101110000
Want:
D.2r XOR R = nGequivalently:
D.2r = nG XOR R
equivalently:
if we divide D.2r by G, want reminder R
R = remainder[ ]D.2r
G
47
בחילוק עושים XORבין הביטים
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
©
3 types: Channel Partitioning
The channel is divided to timeslots. Allocating timeslots to an edge for an exclusive use.
Random Access Allow collision. Recovery after collision.
Taking turns Monitoring the channel tightly to avoid collisions.
Advantages: Efficiency, equality, simplicity, Distribution.
MAC (Multiple Access Control)
תקשורת מחשבים ואלגוריתמים מבוזרים 49(2011-2012)חורף
©
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.
TDMA MAC Protocol
תקשורת מחשבים ואלגוריתמים מבוזרים 50(2011-2012)חורף
©
FDMA: frequency division multiple access 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. Example: LAN with 6 stations. Stations 1,3,4 broadcast while the frequencies of stations
2,5,6 are unused.
frequ
ency
bands
time
FDMA MAC Protocol
תקשורת מחשבים ואלגוריתמים מבוזרים 51(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 52(2011-2012)חורף
©
Random Access protocols
When an edge has a packet to be sent The station will send the package over the entire bandwidth of
the channel. Rate R. No priority for one station over the other.
Two or more stations broadcast together => Collision.
MAC random access protocols detail: 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
תקשורת מחשבים ואלגוריתמים מבוזרים 55(2011-2012)חורף
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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 56(2011-2012)חורף
©
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]
תקשורת מחשבים ואלגוריתמים מבוזרים 57(2011-2012)חורף
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, 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 Efficiencyt – 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
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:
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:
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
!K
eGKP
GK
GeP 0
GeP 2]0[ GeGPGS 2]0[
%4.18184.02
1
eS
Slotted AlohaIn 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
תקשורת מחשבים ואלגוריתמים מבוזרים 63(2011-2012)חורף
©
Slotted Aloha Efficiency בשיטה זו, התחנה אינה רשאית לשלוח מידע כל הזמן. התחנה נאלצת לחכות לתחילת
בלבד.t והוא כעת 2מקטע הזמן הבא. אינטרוול השקט קטן פי . - ההסתברות לחוסר התנגשות כעת היא ולכן ,כפי שניתן לראותSlotted Aloha מגיע לשיא כאשר , בתפוקה מקסימאלית
.pure Aloha של , פעמיים מהתפוקה המקסימאלית של למקטעים ריקים 37%במקרה האופטימאלי נוכל להגיע בפרוטוקול זה להסתברות של
הצלחות.37%)אי-שידור(, הסתברות של -עבודה בG גבוה יותר תקטין את מספר המקטעים הריקים, אך תגדיל את מספר
ההתנגשויות. הסתברות לכך ששידור ידרוש ניסיונות )כלומר, התנגשויות, הצלחה אחת(:
:)מספר ניסיונות ממוצע לשידור )תוחלת -מספר השידורים הממוצע תלוי בצורה מעריכית בG ולכן עלייה קטנה בעומס,תגרום ,
עלייה אקספוננציאלית במספר ניסיונות השידור ובכך תוריד את הביצועים בצורה חדה. ©
GeP ]0[GeS G
1G368.0
1
e
K1K1)1( KGG
K eeP
חוסר התנגשות פעם אחת
1kהתנגשות פעמים
1
1)1(k
GkGGk eeekkPE
תקשורת מחשבים ואלגוריתמים מבוזרים 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.
The probability of no collision is now:Resulting:
As shown slotted aloha has its maximum efficiency when G=1 and is equal:
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:
The mean transmission attempts (Average): Average transmission attempts depends
exponentially on G
©
65
GeP ]0[
GeS G
368.01
e
1)1( KGGK eeP
1
1)1(k
GkGGk eeekkPE
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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 66(2011-2012)חורף
Carrier Sense multiple Access – CSMAPersistent 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 69(2011-2012)חורף
©
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 70(2011-2012)חורף
“Taking Turns” MAC protocols
©
Polling: The master is inviting the
slaves to transmit according to a queue.
Typically silent devices are used.
Issues: Overhead- wasted time Reaction time- the time
between the invitation and the beginning of the transmission.
One failure vulnerability- The master may have problems.
master
slaves
poll
data
data
תקשורת מחשבים ואלגוריתמים מבוזרים 71(2011-2012)חורף
“Taking Turns” MAC
©
Token passing: 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
(nothingto send)
T
תקשורת מחשבים ואלגוריתמים מבוזרים 72(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 73(2011-2012)חורף
©
MAC protocols overviewChannel 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 74(2011-2012)חורף
©
LAN technologiesUntil 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 76(2011-2012)חורף
© 5-79
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-80
LAN Addresses and ARPEach adapter on LAN has unique LAN address
Broadcast address= FF-FF-FF-FF-FF-FF
=adapter
1A-2F-BB-76-09-AD
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
71-65-F7-2B-08-53
LAN(wired or
wireless)
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-81
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-82
ARP: Address Resolution Protocol
Each IP node (host, router) on LAN has
ARP tableARP table: IP/MAC
address mappings for some LAN nodes
<IP address; MAC address; TTL>
TTL (Time To Live): time after which
address mapping will be forgotten (typically
20 min)
Question: how to determineMAC address of B
knowing B’s IP address?
1A-2F-BB-76-09-AD
58-23-D7-FA-20-B0
0C-C4-11-6F-E3-98
71-65-F7-2B-08-53
LAN
137.196.7.23
137.196.7.78
137.196.7.14
137.196.7.88
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-83
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 addressframe sent to A’s MAC
address (unicast)
A caches (saves) IP-to-MAC 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-and-play:”nodes create their ARP
tables without intervention from net
administrator
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-84
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 networkhost holds address only while connected and “on” (allowing
address reuse)renew address already in use
DHCP overview:1 .host broadcasts “DHCP discover” msg2 .DHCP server responds with “DHCP offer” msg3 .host requests IP address: “DHCP request” msg4 .DHCP server sends address: “DHCP ack” msg
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-85
DHCP client-server scenario
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4 223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2223.1.3.1
223.1.3.27
A
B
E
DHCP server
arriving DHCP client needs
address in this(223.1.2/24 )network
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-86
DHCP client-server scenarioDHCP server: 223.1.2.5 arriving
client
time
DHCP discover
src : 0.0.0.0, 68 dest.: 255.255.255.255,67
yiaddr: 0.0.0.0transaction ID: 654
DHCP offer
src: 223.1.2.5, 67 dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4transaction ID: 654Lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68 dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4transaction ID: 655Lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67 dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4transaction ID: 655Lifetime: 3600 secs
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-87
Addressing: routing to another LAN
R
1A-23-F9-CD-06-9B
222.222.222.220111.111.111.110
E6-E9-00-17-BB-4B
CC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.111
A74-29-9C-E8-FF-55
222.222.222.221
88-B2-2F-54-1A-0F
B222.222.222.222
49-BD-D2-C7-56-2A
walkthrough: send datagram from A to B via R assume A knows B’s IP address
two ARP tables in router R, one for each IP network (LAN)
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
© 5-88
A creates IP datagram with source A, destination B A uses ARP to get R’s MAC address for 111.111.111.110A creates link-layer frame with R's MAC address as dest,
frame contains A-to-B IP datagramA’s NIC sends frame R’s NIC receives frame R removes IP datagram from Ethernet frame, sees its
destined to BR uses ARP to get B’s MAC address R creates frame containing A-to-B IP datagram sends to B
R
1A-23-F9-CD-06-9B
222.222.222.220
111.111.111.110
E6-E9-00-17-BB-4B
CC-49-DE-D0-AB-7D
111.111.111.112
111.111.111.111
A74-29-9C-E8-FF-55
222.222.222.221
88-B2-2F-54-1A-0F
B222.222.222.222
49-BD-D2-C7-56-2A
This is a really importantexample – make sure you
understand!
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
©
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
Ethernet
תקשורת מחשבים ואלגוריתמים מבוזרים 90(2011-2012)חורף
©
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.
Ethernet frames
תקשורת מחשבים ואלגוריתמים מבוזרים 91(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 92(2011-2012)חורף
Ethernet implementation The Ethernet is based on CSMA/CD - Carrier Sense Multiple
Access/Collision Detection. Network access in 4 steps:
1. Sensing – The station checks if there is a carrier, that is if someone is transmitting.
2. The station waits 9.6 microseconds, and if there is no broadcast at the time the station is transmitting but keeps monitoring.
3. 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.
4. 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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 93(2011-2012)חורף
©
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}
תקשורת מחשבים ואלגוריתמים מבוזרים 94(2011-2012)חורף
©
Ethernet’s CSMA/CDJam Signal: Make sure that all others are aware of the collision.
48 bitsExponential 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 96(2011-2012)חורף
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.
Maximum distance between the computer and the hub is 100m. Hub may disconnect noisy adapters. Hub may statistically monitor the throughput for the Admin.
twisted pair
hub
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 98(2011-2012)חורף
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.
© תקשורת מחשבים ואלגוריתמים מבוזרים 99(2011-2012)חורף
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.
Token passing rings: The ring topology defines the logical topology, the order of message passing.
תקשורת מחשבים ואלגוריתמים מבוזרים (2011-2012)חורף
©
LAN extension
Motivation: Distance limitation. Lower performance with more users.
Devices: Hub Repeater Bridge Switch
תקשורת מחשבים ואלגוריתמים מבוזרים 101(2011-2012)חורף
©
Hub - מרכזיה
HUB Hardware Creates one LAN segment
The Hub is a central point to the entire network. A differen cable connect each computer to the Hub.
תקשורת מחשבים ואלגוריתמים מבוזרים 102(2011-2012)חורף
Each Ethernet frame is sent from one port to all the other ports. Logically distributes the signals. Every signal goes to all the ports.
Single collision segment
Repeaters מגבר משחזר -
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.
R
RepeaterDirect connection
Ethernet segmentEthernet segment
תקשורת מחשבים ואלגוריתמים מבוזרים (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.
תקשורת מחשבים ואלגוריתמים מבוזרים 104(2011-2012)חורף
©
©
Bridges Link layer hardware. Connects two LAN segments. Frame delivery
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. Do not extend noise or collisions. Learns the addresses and filters. Transparent
Computers are not aware of the bridge existance. Plug-and-play, Self-learning.
Bridge does not need to be configured.
תקשורת מחשבים ואלגוריתמים מבוזרים 105(2011-2012)חורף
©
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.
bridge collision domain
collision domain
= hub
= host
LAN segment LAN segment תקשורת מחשבים ואלגוריתמים מבוזרים 106(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 107(2011-2012)חורף
©
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.תקשורת מחשבים ואלגוריתמים מבוזרים 108
(2011-2012)חורף
©
Bridge exampleAssume 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 110(2011-2012)חורף
©
אלגוריתם של עץ פורשSpanning Tree Algorithm A bridges network is a graph.
Usually the graph is hierarchal. 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 tree may find a sub graph that spans
all the edges with no loop. 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.
תקשורת מחשבים ואלגוריתמים מבוזרים 113(2011-2012)חורף
©
Spanning Tree example
B3
B5
B7B2
B1
B6 B4
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.
B8
תקשורת מחשבים ואלגוריתמים מבוזרים 114(2011-2012)חורף
©
Spanning Tree example
B3
B5
B7B2
B1
B6 B4
Root
B8
B2 B4 B5 B7
B8
B1
Spanning Tree:
תקשורת מחשבים ואלגוריתמים מבוזרים 115(2011-2012)חורף
©
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.
תקשורת מחשבים ואלגוריתמים מבוזרים 116(2011-2012)חורף