Sei sulla pagina 1di 9

AnalysisofSimple CommunicationProtocol(1) ( )

ExercisesonSpecification&Verification

CafeOBJ TeamofJAIST

Roadmap
SimpleCommunicationProtocol(SCP) ModelingSCP SpecificationofDateUsed ExercisesonSpecification&Verification

SinaiaSchool,Mar0311,2008

SimpleCommunicationProtocol ( (SCP) )

SimpleCommunicationu Protocol
bit1 cell1 ll1 <bit1,pac> bit2 cell2 bit2 Receiver Sender

AlthoughABPusesunreliablequeues,SCPusesunreliable cells.Datainthecellscanbelost. Initially,bothcellsareempty&bothbitsarethesame. Sender&Receiverdothefollowing:


Senderputs<bit1,pac> intocell1 repeatedly. Receiverputsbit2 intocell2 repeatedly. WhenSendergetsabitb fromcell2,ifb doesnotequalbit1, Senderselectsthenextpacketandalternatesbit1. WhenReceivergets<b,p> fromcell1,ifb equalsbit2, Receiverreceivesp andalternatesbit2.
SinaiaSchool,Mar0311,2008

Animation
bit1: f t cell1 <t,p1> <f,p0> <t,p1> <f,p0> bit2: f t

Sender next: p1 p0 f t

f t cell2

Receiver list: (p1 (p0)p0) nil

SinaiaSchool,Mar0311,2008

OneDesirableProperty
When h Receiverreceivesthe h nth hpacket, k
Receiverhasreceivedthen+1 packetsp0, , pn inthisorder, eachpi fori = 0,,n hasbeenreceivedonly once,and nootherpacketshavebeenreceived.

Thepropertyiscalled thereliablecommunicationproperty inthistalk.


SinaiaSchool,Mar0311,2008 6

ModelingSCP

Observations
S Sender d to t Receiver R i channel h l bop cell1 : Sys -> PCell ReceivertoSenderchannel bop cell2 : Sys -> BCell Sender'sbit bop bit1 : Sys -> > Bool Receiver'sbit bop bit2 : Sys -> Bool TheordinalofthepacketsentnextbySender bop next : Sys -> Nat ThepacketsreceivedbyReceiver bop list : Sys -> List

SinaiaSchool,Mar0311,2008

Transitions
S Sender's d ' sending di pairs i of fbit bits&packets k t bop send1 : Sys -> Sys Sender'sreceivingbits bop rec1 : Sys -> Sys Receiver'ssendingbits bop send2 : Sys -> > Sys Receiver'sreceivingpairsofbits&packets bop rec2 : Sys -> Sys Droppingthecontentofcell1 bop drop1 : Sys -> Sys Droppingthecontentofcell2 bop drop2 : Sys -> Sys

SinaiaSchool,Mar0311,2008

TransitionDiagramofSender
<*, true> t > <rec1, ow> bit1: f next: 0 <*, true> t > <rec1, ow> bit1: t next: 1 bit1: f next: 2

<rec1, cell2 =/= empty and get(cell2) =/= f>

<rec1, cell2 =/= empty and get(cell2) =/= t>

<trans, cond>

Iftheconditioncond holdsinthestateS,thenthe
transitiontranscanchangeS toS. ow> meansthatifanyotherconditionsfor <trans,ow> trans donothold,trans canchangeS toS. * representsanytransitionexceptthoseexplicitly stated stated.
SinaiaSchool,Mar0311,2008 10

TransitionDiagramofReceiver
<*, true> t > <rec2, ow> bit2: f bit2 list: nil <*, true> t > <rec2, ow> bit2: t bit2 list: p0 bit2: f bit2 list: p1 p0 <rec2, cell1 =/= empty and fst(get(cell1)) =/= t> wheresnd(get(cell1)) = p1

<rec2, cell1 =/= empty and fst(get(cell1)) =/= f> wheresnd(get(cell1)) = p0

fst(< e1,e2>) = e1 snd(<e1,e2>) = e2

SinaiaSchool,Mar0311,2008

11

TransitionDiagramofChannels
<*, true> <*, true> <reci, true> < t > <dropi, true> <sendi, true> celli: z

celli: empty

celli: x celli: y

<sendi, true>

SinaiaSchool,Mar0311,2008

12

SpecificationofDataUsed

DataUsed
Booleanvaluesforbits Naturalnumbersforordinalsofpackets Packets PairsofBooleanvalues&packets Cells(forchannels)ofpairsofBVs&pacs Cells(forchannels)ofBooleanvalues Listofpackets
SinaiaSchool,Mar0311,2008 14

DataModules
M Modules d l EQBOOL,PNAT,PACKET,PAIR,CELL,LIST, PACKET LIST,BOOL-PACKET-PAIR PACKET-LIST BOOL PACKET PAIR, BOOL-CELL,BOOL-PACKET-PAIR-CELL, EQTRIV Views EQTRIV2PACKET,EQTRIV2EQBOOL, EQTRIV2BOOL-PACKET-PAIR Letustakealookatthefilescp.mod.
SinaiaSchool,Mar0311,2008 15

ExercisesonSpecification& Verification

Exercises
1. WritethemoduleSCP inwhichthemodelof SCPisspecified. p 2. Makesomeexperimentsbasedonthe specification. specification 3. VerifythatSCPsatisfiesthereliable communicationpropertybywritingproof scores.

SinaiaSchool,Mar0311,2008

17

Potrebbero piacerti anche