西电协议详情分析报告与设计上机报告材料.docxVIP

  • 5
  • 0
  • 约4.56千字
  • 约 15页
  • 2018-12-30 发布于安徽
  • 举报

西电协议详情分析报告与设计上机报告材料.docx

协议分析与设计上机报告 实验目的 学习和掌握PROMELA语言,并能在SPIN上对协议进行模拟和分析。 实验题目 6-5 将6.3节描述的协议条件改为报文和应答均会出错,且都丢失,接收方没有无线接收能力,这就是我们通常所说的实用停等协议。请用PROMELA进行描述,并用SPIN模拟运行、一般性验证、无进展循环验证和人为加入错误进行验证。 6-6 请根据图6-16写出著名的AB协议的PROMELA描述,并验证“A”获取的每一个报文至少有一个是正确的,而“B”接收的每一个报文之多有一次是正确的。 S1 ?b0?b1 S4 S3 ?b1 !a1 !a0 ?err !b1 ?a0 S2 ?err S5 S2 ?err S5 !a1 ?b0 ?a1 !b1 !b0 ?err S3 S1 ?a0 ?a1 S4 Terminal A Terminal B 实验分析 6-5 停止等待协议 因为协议条件为报文应答均会出错,且都丢失,接收方没有无限接收能力,所以此时信道应该有5种信号,分别为:信息,ACK,NAK,出错信号和丢失信号,即mtype={Msg,Ack,Nak,Err,Miss}。 然后定义两个信道,用于在发送方实体和接收方实体进行数据传输。 chan SenderToReceiver=[1]of{mtype,byte,byte}; chan ReceiverToSender=[1]of{mtype,byte,byte}; 主要过程为:发送方发送报文,等待应答,如果是肯定应答则发送下一帧,如果是否定应答或者应答帧出错则重发,发送端通过OutCh!Miss(0,0) 来模拟发送报文丢失;接收方接收报文,如果是期望的报文则发送肯定应答,否则发送否定应答,接收端通过InCh?Mis(0,0)模拟应答报文丢失,如果报文丢失,则需要重发报文。 代码如下: 1 #define MAXSEQ 5 2 3 mtype = {Msg,Ack,Nak,Err,Miss}; 4 chan SenderToReceiver = [1] of {mtype,byte,byte} ; 5 chan ReceiverToSender = [1] of {mtype,byte,byte} ; 6 7 proctype SENDER(chan InCh,OutCh) 8 { 9 byte SendData; 10 byte SendSeq; 11 byte ReceivedSeq; 12 SendData = MAXSEQ-1; 13 do 14 ::SendData = (SendData+1)%MAXSEQ; 15 again: if 16 ::OutCh!Msg(SendData,SendSeq) 17 ::OutCh!Err(0,0) 18 ::OutCh!Miss(0,0) 19 fi; 20 21 if 22 ::timeout - goto again 23 ::InCh?Miss(0,0) -goto again 24 ::InCh?Err(0,0) -goto again 25 ::InCh?Nak(ReceivedSeq,0) - 26 end1: goto again 27 ::InCh?Ack(ReceivedSeq,0) - 28 if 29 ::(ReceivedSeq == SendSeq) -goto progress 30 ::(ReceivedSeq != SendSeq) - 31 end2: goto again 32 fi 33 fi; 34 progress : SendSeq = 1 - SendSeq; 35 od; 36 } 37 38 proctype RECEIVER(chan InCh,OutCh) 39 { 40 byte ReceivedData; 41 byte ReceivedSeq; 42 byte ExpectedData; 43 byte ExpectedSeq; 44 45 do 46 :: InCh?Msg(ReceivedData,ReceivedSeq) - 47

文档评论(0)

1亿VIP精品文档

相关文档