Presentation is loading. Please wait.

Presentation is loading. Please wait.

Formal Methods Project Design Yuanhui Luo yl3026, Ziwei Zhang zz2282, Yih-Nin Lai yl3030, Zhen Qiu zq2130.

Similar presentations


Presentation on theme: "Formal Methods Project Design Yuanhui Luo yl3026, Ziwei Zhang zz2282, Yih-Nin Lai yl3030, Zhen Qiu zq2130."— Presentation transcript:

1 Formal Methods Project Design Yuanhui Luo yl3026, Ziwei Zhang zz2282, Yih-Nin Lai yl3030, Zhen Qiu zq2130

2 1. Protocol description  Considering the requirements of this design, we implement our Go-back-N protocol as follow: For Sender:  Transmitting the messages in the 4-size window one by one, not caring about whether it receives ACK of previous messages.  As soon as the sender receives an ACK, the window base will move to the next message numbered by this ACK.  It is impossible for sender to receive an ACK with the number smaller than expected.  If it receives a larger ACK, sender believes that all the messages before are successfully transmitted.

3 For Receiver:  If receiver accepts the expected message, it will put a corresponding ACK in the reverse channel.  Receiver will not put ACK in the channel if this message is not the expected one. It will discard this message. Timing Sets:  The propagation time, of both messages and ACKs, is not specified. Timeout Case:  A timeout will result in retransmitting all the four messages in the window.

4 2. Assumptions  The protocol only allows to lose up to 3 packets  We define that a timeout happens when both the forward channel and reverse channel are empty.  We only consider the first elements of sequence in both channels.  If there are messages and ACKs in both channels, we assume the first message and first ACK have equal probability to be received earlier.  We take these as stopping point when the first 4 messages are successfully transmitted and 4 packets are lost.

5 In our algorithm, it is hard to consider timeout factor if we want to make probabilistic verification. In fact, the timeout trigger will happened in every states. If we take this strategy, the analysis will be much more complex. And what’s more, our protocol will fail if timeout out always happened. So we took such assumption. Why we assume the propagation delay much longer than transmission delay?

6 3. Design implementation

7

8

9

10

11 Figure 1 Examples of Next States from Current State From the figure above, the states and are of high probability to occur, while the other two are of 10 -4 to occur. 4. Example

12 5. Pseudo Code  Stack ; //define a stack structure  T.Push(initial);  For{  t2=T.pop(); //pop out the data saved in the top of stack  Generate_state(t2);  }  Table T  {  int s, r; //sender, receiver  int sizef, sizeb; //size of forward and reverse channel  int[4]=chf,chb; //define forward channel and reverse channel  int p=0; //initiate error rate  }

13  //sender receives ack  Generate_state{  If(t2.sizeb>0)  {  new T.t; //create new table to save new state  x=chb[0]; //first element in backward channel queue  t.sizef=t2.sizef;  t.sizeb=t2.sizeb-1;  t.chf=t2.chf;  for(i=0, i<t.sizeb,i=++)  {t.chb[i]=t2.chb[i+1];}  t.p=t2.p;  t.r=t2.r  if(t.s<=x) //if expected ack no larger than recieved ack  t.s=x+1;  for(j=0,j<x-t.s+1,j++)  t.chf[t2.sizef+j] = t.s + j + 4; //moving window base forward  t.sizef ++;  }

14  //sender loses ack  Generate_state{  if(t2.sizeb>0)  {  new T.t; //create new table to save new state  x=chb[0]; //first element in backward channel queue  t.sizef=t2.sizef  t.sizeb=t2.sizeb-1;  t.chf=t2.chf  for(i=0, i<t.sizeb,i=++) //reorder the acks in the backward channel  {t.chb[i]=t2.chb[i+1];}  t.p=t2.p;  t.r=t2.r; //The status of receiver and sender will not  t.s=t2.s; //change  t.p++; //error rate will increase  }

15  //receiver receive message  Generate_state{  if(t2.sizef>0)  {  new T.t; //create new table to save new state  x=chf[0]; //first element in forward channel queue  t.sizef=t2.sizef-1;  t.sizeb=t2.sizeb;  t.chb=t2.chb;  for(i=0, i<t.sizef,i=++)  {t.chf[i]=t2.chf[i+1];}  t.p=t2.p;  t.s=t2.s;  t.r=t2.r;  if(t.r=x) // expect message equal to message channel  t.r++; //receiver expected number +1  t.chb[t.sizeb+1] = x;  t.sizeb ++;  }

16  //receiver lose message  Generate_state{  if(t2.sizef>0)  {  new T.t //create new table to save new state  x=chf[0] // first element in forward channel queue  t.sizef=t2.sizef-1  t.sizeb=t2.sizeb  t.chb=t2.chb  for(i=0, i<t.sizef,i=++)  {t.chf[i]=t2.chf[i+1]}  t.p=t2.p  t.s=t2.s  t.r=r2.r  }

17  Table 1 First 3 Steps of the Table  State Service Seq  initial  0 0 [E] [E]  ----------------------------------------------------------------------  step: 1 pop: 0 0 [] []  ----------------------------------------------------------------------  0 0 [0,1,2,3] [] 0 Get 0 1 2 3  ----------------------------------------------------------------------  step: 2 pop: 0 0 [0,1,2,3] []  ----------------------------------------------------------------------  0 1 [1,2,3] [0] 0 Get 0 1 2 3 Acpt 0  0 0 [1,2,3] [] 1 Get 0 1 2 3  ----------------------------------------------------------------------  step: 3 pop: 0 1 [1,2,3] [0]  ----------------------------------------------------------------------  0 2 [2,3] [0,1] 0 Get 0 1 2 3 Acpt 0 Acpt 1  1 1 [1,2,3,4] [] 0 Get 0 1 2 3 Acpt 0 Get 4  0 0 [1,2,3] [] 1 Get 0 1 2 3  0 1 [2,3] [0] 1 Get 0 1 2 3 Acpt 0  0 1 [1,2,3] [] 1 Get 0 1 2 3 Acpt 0  ---------------------------------------------------------------------- We use four separate stacks to store states with different probabilities, p=0, p=1, p=2, p=3. Firstly, we push the initial state to stack0 and pop it, then push the next states into the corresponding stacks. After the sender transmits all the 4 messages in the window [0,1,2,3], it’s the state with p=0. We push it into stack0 and pop it. The next states of are two states, with p=0 (receiver accepts M1 and puts A1 in the reverse channel)and with p=1 (M1 is lost). So we push them into stack0 and stack1 separately, then pop the one in stack0 (the one with higher probability), so on and so forth. In terms of the four stacks, we will always pop states in the order of stack0, stack1, stack2, stack3. That is to say, the state with higher probability should be pop earlier.

18 6. Discussion  For the last problem of this GBN design requirement, there would have no protocol failure in our design. In our program, if there’s no stop-points, the program will continue to implement the whole sequence in GBN protocol. Since there’s no deadlock in this design, protocol failure would not happen.

19 7. Weakness As we have made the assumption that the channel is long enough to consider the timeout to be very large. So timeout will occur only when all massage in channel have lost or received, in other word, both forward and reverse channel are empty. However, such assumption may not fit in all possible cases. For example, when timeout, we will resend msg n, n+1, n+2, n+3 to channel, maybe n arrives to receiver before n+1 is sent out. But not put 4 msg on channel together. We can modify our algorithm to make up. To set a variable m x to represent the msg index we will send. When timeout happen, we set m x to base of senders window. If m x is less than base+4, sender can send to msg to forward channel anyway. So we will not send all msg to channel together, but discuss sending them one by one to the channel.


Download ppt "Formal Methods Project Design Yuanhui Luo yl3026, Ziwei Zhang zz2282, Yih-Nin Lai yl3030, Zhen Qiu zq2130."

Similar presentations


Ads by Google