Alternating%20Bit%20Protocol - PowerPoint PPT Presentation

About This Presentation
Title:

Alternating%20Bit%20Protocol

Description:

Alternating Bit Protocol – PowerPoint PPT presentation

Number of Views:285
Avg rating:3.0/5.0
Slides: 12
Provided by: Muf7
Category:

less

Transcript and Presenter's Notes

Title: Alternating%20Bit%20Protocol


1
Alternating Bit Protocol
  • Protocol for simplex data-transfer channel
  • data flows from sender to receiver
  • control flows in both directions
  • the transfer medium may corrupt messages
  • The protocol attaches a status bit, the
    alternation bit to messages.
  • Assume send from A to B
  • B receives message and accepts it only if bits
    differ
  • B sends verification message (an ack) to A
    (receipt of message)
  • A receives ack and deduces
  • message sent was received correctly
  • send next message with flipped bit
  • message sent was corrupted
  • resend message
  • nothing - because ack was corrupted
  • resend message
  • We do not indicate the exact corrpution of a
    message, just turn any corrupted message into
    error message.

2
Alternating Bit Protocol
  • messages
  • mtype data, control, error
  • channels
  • chan fromA N of byte, byte, bit /
    messagetype1, data, statusbit /
  • chan toB N of byte, byte, bit /
    messagetype1, data, statusbit /

B
A
fromA
fromB
toB
toA
lower layer
3
Lower Layer
  • transfer medium (perfect channel)
  • proctype lower (chan fromA, toA, fromB, toB)
  • byte d bit b
  • do
  • fromA?data(d,b) -gt toB!data(d,b)
  • fromB?control(b) -gt toA!control(b)
  • od

transfer medium (imperfect channel) proctype
lower (chan fromA, toA, fromB, toB) byte d bit
b do fromA?data(d,b) -gt if
toB!data(d,b) / correct /
toB!error(d,b) / error /
fi fromB?control(b) -gt if
toA!control(b) / correct /
toA!error(b) / error /
fi od
4
Sender
  • Sender - without initialisation
  • proctype A (chan in, out)
  • byte mt / message type /
  • bit at / status bit /
  • bit vr / verification bit /
  • FETCH / get actual data /
  • out!data(mt,at) / send the data /
  • do / wait for correct response /
  • in?control(vr) -gt / got a control message
    /
  • if
  • (vr 1) -gt / correct ! /
  • FETCH / get next
    actual data /
  • at at -1 / alternate status bit
    /
  • (vr 0) -gt / an error in
    send /

5
Receiver
  • Receiver - without initialisation
  • proctype B (chan in, out)
  • byte mr / message type /
  • byte last_mr / mr of last error-free msg /
  • bit ar / status bit /
  • bit lar / ar of last error-free msg /
  • do
  • in?error(mr,ar) -gt / receive corrupted msg /
  • out!control(0)
  • in?data(mr,ar) -gt / receive correct msg /
  • out!control(1)
  • if
  • (ar lar) -gt /
    retransmission, do not accept /
  • skip
  • (ar ! lar) -gt / new message, accept /

6
Initialisation
  • Send message from A to B (error-free, but not
    necessarily accepted) which forces setting of Bs
    alternation bit.

7
Sender
  • Sender - with initialisation
  • proctype A (chan in, out)
  • byte mt0 / message type /
  • bit at 0 / status bit /
  • bit vr / verification bit /
  • out!data(0,1) / initialise /
  • do in?error(vr) -gt / an error in ack/
  • out!data(0,1) / resend /
  • in?control(0) -gt /an error in send
    /
  • out!data(0,1) / resend /
  • in?control(1) -gt / successful
    initialisation /
  • break
  • od
  • FETCH / get actual data /
  • out!data(mt,at) / send the data /
  • do / wait for correct response /
  • in?control(vr) -gt / got a control message
    /

8
Receiver
  • Receiver - with initialisation
  • proctype B (chan in, out)
  • byte mr / message type /
  • byte last_mr / mr of last error-free msg /
  • bit ar / status bit /
  • bit lar / ar of last error-free msg /
  • bit ini0 / initialised /
  • do
  • in?error(mr,ar) -gt / receive corrupted msg /
  • out!control(0)
  • in?data(mr,ar) -gt / receive correct msg /
  • out!control(1)
  • if
  • (!ini) -gt / not initialised /
  • ini 1 lar ar / initialise /
  • (ini) -gt / initialised /

9
Assertions
  • define ACCEPT assert(mr (last_mr1)MAX)
  • Full program
  • define N 2
  • define MAX 8
  • define FETCH mt (mt1)MAX
  • / sequence of numbers /
  • define ACCEPT assert (mr (last_mr1)MAX)
  • / messages received in sequence /
  • init
  • chan fromA N of byte, byte, bit
  • chan toB N of byte, byte, bit
  • chan fromB N of byte, bit
  • chan toA N of byte, bit
  • atomic run A(toA, fromA)

10
Message Sequence Charts
  • 1. Message and ack is successful, 2 times.
  • 2. Message is corrupted first time, success 2nd
    time.
  • 3. Message is received, but ack is corrupted
    first time success 2nd time.
  • Use global channel names show states of
    variables.

11
Using Spin for Simulation
Run spin on a linux machine by /local/fda/tools/i
nstall/i386-unkown-linux/bin/xspin-linux Run
from your own directory. Set Simulation
Parameters Display Mode
Simulation Style

MSC Panel

Random

Seed1 Timed Sequence

Guided

Steps skipped 0


Interactive Data Values

Full Queue

Blocks New Messages


Loses New Messages
x
x
x
Write a Comment
User Comments (0)
About PowerShow.com