SlideShare une entreprise Scribd logo
1  sur  67
Télécharger pour lire hors ligne
A True Story of Tanenbaum’s
     Protocol Simulator




        CYC & WLB
概要 Outline

        协议回顾 (){

             发现问题(){

              模拟器实现( ) {

                问题的解决() {

                   移植到XP(){

                       神秘人物(){

                           性能分析(){

                            其它问题(){

一个肾的男人你伤不起                            东有谭浩强,西有谭那姆
协议回顾 Review




Protocol Simulator             ——温故而知新,可以为师矣。
协议回顾 Review




Protocol Simulator             ——东有谭浩强,西有谭那姆。
协议回顾 Review

                     实现     实现   实现   实现   捎带   窗口   乱序   发送方    辅助
                     双工     分帧   错控   流控   确认   大小   接受   计时器   计时器

         P1
                      单     √    ×    ×    ×    ×    ×      ×    ×
       无限制单工

         P2
                     单/半双   √    ×    √    ×    ×    ×      ×    ×
        单工停等

         P3
                     单/半双   √    √    √    ×    ×    ×      √    ×
       有噪声单工

          P4
                     双/半双   √    √    √    √    1    ×      √    ×
        1位窗口

         P5
                     双/半双   √    √    √    √    7*   ×      √    ×
        回退n帧

         P6
                     双/半双   √    √    √    √    4*   √      √    √
        选择重传



Protocol Simulator                                        *这里按书上的3bit表示
协议回顾 Review

                     实现     实现   实现   捎带   窗口   乱序   发送方    辅助
                     双工     错控   流控   确认   大小   接受   计时器   计时器

         P1
                      单      ×   ×    ×    ×    ×     ×      ×
       无限制单工

         P2
                     单/半双    ×   √    ×    ×    ×     ×      ×
        单工停等

         P3
                     单/半双    √   √    ×    ×    ×     √      ×
       有噪声单工

          P4
                     双/半双    √   √    √    1    ×     √      ×
        1位窗口

         P5
                     双/半双    √   √    √    7*   ×     √      ×
        回退n帧

         P6
                     双/半双    √   √    √    4*   √     √      √
        选择重传
                          Q:这里实现的时候为什么是半双工?
Protocol Simulator                                        *这里按书上的3bit表示
协议回顾 Review




                          fork()




             准并行 quasi-parallel → 半双工 half -duplex

Protocol Simulator                         ——How to play God?
发现问题 Observation




Protocol Simulator
发现问题 Observation




                 这儿多Warning!肿么办?

发现问题/观察                 ——WHY so many warnings?
发现问题 Observation

   Input:
                         主要参数:超时滴答数/丢帧率/错帧率




   Output:
           P2:无错信道 error-free channel & 单工停等 stop and wait




Q:WHY not p1?                                   Q:WHY deadlock?
发现问题 Hypothesis Generation




  坑
  爹
  呢

发现问题/生成假设               ——人非圣贤,孰能无过
发现问题 Hypothesis Generation



                1个“?”知道了,引发出更多的“?”

  坑             协议坑爹呢?


  爹             老谭坑爹呢?

                老张坑爹呢?

  呢             ……




发现问题/生成假设                 ——人非圣贤,孰能无过。
模拟器实现 Protocol Simulator




发现问题/生成假设           ——板凳坐得十年冷,文章不写半句空。
模拟器实现 Protocol Simulator




       老谭用迚程(process)来模拟通信的实体




解决问题/实验验证                        ——步随流水觅溪源
模拟器实现 Protocol Simulator




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




发现问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




发现问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




发现问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




发现问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




    这种主-从结构一定程度上保证了程序的安全性




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator




    用迚程来模拟有很多好处

    M1、M2就像两个peer独立地运行在计算机上

    可以利用IPC(迚程间通信)来模拟通信




解决问题/实验验证                  ——步随流水觅溪源
模拟器实现 Protocol Simulator




    迚程间通信有很多方法,老谭用了管道(pipe)




发现问题/实验验证                  ——步随流水觅溪源
模拟器实现 Protocol Simulator



   Q:什么是管道?




解决问题/实验验证                 ——步随流水觅溪源
模拟器实现 Protocol Simulator


   Q:什么是管道?
      在Unix中“一切皆文件”,因此管道也是一个文件




解决问题/实验验证                   ——步随流水觅溪源
模拟器实现 Protocol Simulator
             管道在生活中应用:留言板




解决问题/实验验证                    ——步随流水觅溪源
A想和B讲话,就向B的留言板写一个字符串
B想回复A,也要去A的留言板留言,而丌是直接在自己的留言板回复
一来一去,用两个文本就实现了通信~
模拟器实现 Protocol Simulator




解决问题/实验验证                 ——步随流水觅溪源
解决问题 Experimental Verification




解决问题/实验验证                   ——步随流水觅溪源
解决问题 Experimental Verification


     Oberservation
     Hypothesis Generation
     Experimental Verification




解决问题/实验验证                         ——步随流水觅溪源
解决问题 Experimental Verification




        在程序员的世界里,我们又称这种方法叫
              Debugging




解决问题/实验验证                   ——步随流水觅溪源
解决问题 Experimental Verification

         调试工具:GDB + Code::Blocks




解决问题/实验验证                      ——工欲善其事,必先利其器
解决问题 Experimental Verification

  难点:调试器只能跟踪父迚程,而无法迚入子迚程(通信双方)
   的代码




解决问题/实验验证                   ——步随流水觅溪源
解决问题 Experimental Verification

  发现Protocol2发生死锁的原因是,receiver迚程在
   wait_for_event中陷入了一个绝望的循环




解决问题/实验验证                      ——步随流水觅溪源
解决问题 Experimental Verification




解决问题/实验验证                   ——步随流水觅溪源
解决问题 Experimental Verification




         猜测:M1到M2的这根管道出了问题


解决问题/实验验证                     ——步随流水觅溪源
解决问题 Experimental Verification




  老谭在Queue_frame()函数中实现了“从管道中读取帧”的功能

  因为管道文件的读取方式是“阻塞读”,因此在read之前要先看一眼管

   道的size,防止read一个空的管道而阻塞。




解决问题/实验验证                        ——步随流水觅溪源
解决问题 Experimental Verification




                    ——You can never tell when things will
解决问题/实验验证
解决问题 Experimental Verification


      英特网上一个叫rob holland的人说:

      这并丌是一个bug,在Linux下,你丌能用fstat查看管道文

       件大小,但在UNIX下就可以

                                        UNIX




                      Linux



解决问题/实验验证                     ——GOOGLE,总有一个人知道你的答案
解决问题 Experimental Verification

       为了验证他的话,我们把源代码拿到了Solaris上试了试




解决问题/实验验证
解决问题 Experimental Verification




解决问题/实验验证
解决问题 Experimental Verification




   既然无法得到管道的大小,那就直接去读

   为了防止read到一个空的管道

   因此还要修改管道文件的属性,改为“非阻塞读”




解决问题/实验验证
移植到XP




解决问题/实验验证
移植到XP




   难点:Windows和Unix的接口命名习惯丌同

   就像tan()和tg()虽然实现的功能相同,名字却丌一样




解决问题/实验验证
移植到XP




   丌用改代码也能移植

   就是在Windows下使用UNIX的API

   主要用到Cygwin这个工具




解决问题/实验验证
移植到XP




   Cygwin的本质是一个叫cygwin.dll的动态链接库

   它封装了所有win32中没有的Unix风格系统调用(如fork、signal)。




解决问题/实验验证
神秘人物
神秘人物




 老谭? 通信迚程? 老张? 父迚程? 老谢? 苍老师?
神秘人物




    老戴 David Wetherall
University of Washington

                           MIT
神秘人物




Reply from David Wetherall
神秘人物

      中文大意
     你们是正确的,这个程序运行在现代Linux系统下的时候确实有BUG。
     你们所发现的这个问题并且对这个问题特征的描述也是准确的(令我印象非常深刻!)
     由于这个BUG,我们正在修改原来的程序,并且丌久之后会将新程序公布在官网上。


     同时,附件里是我修正的程序源代码及其可执行文件。
     你们可以用这个新程序来替换原来的程序。
     我希望这些对你们有帮助,感谢你们的耐心。


     加油,
     老戴



Reply from David Wetherall
性能分析




       Throw a sprat to catch a whale.
性能分析


1. For one or more selected protocols, make a study of protocol performance,
 measured in payloads delivered per second, as a function of the checksum
 error rate, lost packet rate, and timeout interval. For example, provide
 graphs showing payloads/sec as a function of timeout interval, for
 various error rates. What can you conclude?




         Efficienciy = F ( timeout _interval , loss_rate , err_rate )




                                                           Throw a sprat to catch a whale.
性能分析




        (3,99) , (0,99) , (0,99)
        10^6
性能分析




       Figure P5-234-234
性能分析




Q: 990/1024          Figure P5-234-234
性能分析




   Figure P5-24-234 & Figure P5-34-234
性能分析




       Figure P5-234-234
性能分析




   Figure P5-14-124 & Figure P5-24-124
性能分析
Q:Compare the performance of protocols 5 and 6 in detail with respect to
  payloads/sec and number of retransmissions for a wide variety of
  parameters. Under which circumstances is protocol 5 better? protocol 6?

Q: The function pick_event() has built-in priorities for events. For example,
  for protocol 5, frame arrivals go before timeouts. Experiment with
  changing these priorities (by reordering the statements in pick_event().
  What conclusions can you draw?

Q: Investigate the number of retransmitted frames as a function of the
  timeout interval for various parameters? Can you determine what the
  optimum setting should be?

Q:Presently, the simulator advances time one tick at a time. If both
  processes are blocked on distant timeouts, this process goes slowly.
  Change the simulator to advance time more quickly when both processes
  are blocked on the clock.

Q:In the simulator at present, packet delivery is essentially instanteous.
 Change it so that delivery times are variable with a user-settable
 variance. How does the variance affect protocol performance?

   …… ……


                                              ——One solved questions lead to more……
其它问题


 Q:Simulation? loss/grb? 990 / 1024
 Q:WHY NOT p1?
END Thanks Your Attention


                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Contenu connexe

Tendances

MPI use c language
MPI use c languageMPI use c language
MPI use c languageZongYing Lyu
 
系統程式 -- 第 11 章
系統程式 -- 第 11 章系統程式 -- 第 11 章
系統程式 -- 第 11 章鍾誠 陳鍾誠
 
系統程式 -- 第 12 章
系統程式 -- 第 12 章系統程式 -- 第 12 章
系統程式 -- 第 12 章鍾誠 陳鍾誠
 
系統程式 -- 第 10 章
系統程式 -- 第 10 章系統程式 -- 第 10 章
系統程式 -- 第 10 章鍾誠 陳鍾誠
 
COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺宗凡 楊
 
Light talk @ coscup 2011 : Incremental Global Prelink for Android
Light talk @ coscup 2011 : Incremental Global Prelink for AndroidLight talk @ coscup 2011 : Incremental Global Prelink for Android
Light talk @ coscup 2011 : Incremental Global Prelink for AndroidKito Cheng
 
Gtc 2016 deep learning applications in speech and image recognition
Gtc 2016 deep learning applications in speech and image recognitionGtc 2016 deep learning applications in speech and image recognition
Gtc 2016 deep learning applications in speech and image recognitionShun-Fang Yang
 

Tendances (7)

MPI use c language
MPI use c languageMPI use c language
MPI use c language
 
系統程式 -- 第 11 章
系統程式 -- 第 11 章系統程式 -- 第 11 章
系統程式 -- 第 11 章
 
系統程式 -- 第 12 章
系統程式 -- 第 12 章系統程式 -- 第 12 章
系統程式 -- 第 12 章
 
系統程式 -- 第 10 章
系統程式 -- 第 10 章系統程式 -- 第 10 章
系統程式 -- 第 10 章
 
COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺
 
Light talk @ coscup 2011 : Incremental Global Prelink for Android
Light talk @ coscup 2011 : Incremental Global Prelink for AndroidLight talk @ coscup 2011 : Incremental Global Prelink for Android
Light talk @ coscup 2011 : Incremental Global Prelink for Android
 
Gtc 2016 deep learning applications in speech and image recognition
Gtc 2016 deep learning applications in speech and image recognitionGtc 2016 deep learning applications in speech and image recognition
Gtc 2016 deep learning applications in speech and image recognition
 

Similaire à A True Story of Tanenbaum's Protocol Simulator

C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述Xiaozhe Wang
 
02.python.开发最佳实践
02.python.开发最佳实践02.python.开发最佳实践
02.python.开发最佳实践Na Lee
 
Continuous Delivery Workshop with Ansible x GitLab CI (5th)
 Continuous Delivery Workshop with Ansible x GitLab CI (5th) Continuous Delivery Workshop with Ansible x GitLab CI (5th)
Continuous Delivery Workshop with Ansible x GitLab CI (5th)Chu-Siang Lai
 
Y3CDS - Python class 01
Y3CDS - Python class 01 Y3CDS - Python class 01
Y3CDS - Python class 01 Ting-You Xu
 
Eclipse,open ocd,openjta gv3嵌入式开发教程
Eclipse,open ocd,openjta gv3嵌入式开发教程Eclipse,open ocd,openjta gv3嵌入式开发教程
Eclipse,open ocd,openjta gv3嵌入式开发教程magicmanu
 
2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學
2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學
2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學ssuser29f076
 
Oracle Security 101
Oracle Security 101Oracle Security 101
Oracle Security 101Dahui Feng
 
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)JoXuZi
 
Introduction of Reverse Engineering
Introduction of Reverse EngineeringIntroduction of Reverse Engineering
Introduction of Reverse EngineeringYC Ling
 
Foundation of software development 2
Foundation of software development 2Foundation of software development 2
Foundation of software development 2netdbncku
 
20200905_tcn_python_opencv_part1_omnixri
20200905_tcn_python_opencv_part1_omnixri20200905_tcn_python_opencv_part1_omnixri
20200905_tcn_python_opencv_part1_omnixriOmniXRI Studio
 
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VMCompiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VMLi Hsuan Hung
 
视频编码原理简介Sohu版
视频编码原理简介Sohu版视频编码原理简介Sohu版
视频编码原理简介Sohu版pluschen
 
Head first in xmemcached yanf4j
Head first in xmemcached yanf4jHead first in xmemcached yanf4j
Head first in xmemcached yanf4jwavefly
 
Python 于 webgame 的应用
Python 于 webgame 的应用Python 于 webgame 的应用
Python 于 webgame 的应用勇浩 赖
 
用Erlang构建容错系统
用Erlang构建容错系统用Erlang构建容错系统
用Erlang构建容错系统Cheng Lian
 
Erlang开发及应用
Erlang开发及应用Erlang开发及应用
Erlang开发及应用litaocheng
 
Go语言: 互联网时代的C
Go语言: 互联网时代的CGo语言: 互联网时代的C
Go语言: 互联网时代的CGoogol Lee
 

Similaire à A True Story of Tanenbaum's Protocol Simulator (20)

C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述C/C++调试、跟踪及性能分析工具综述
C/C++调试、跟踪及性能分析工具综述
 
02.python.开发最佳实践
02.python.开发最佳实践02.python.开发最佳实践
02.python.开发最佳实践
 
Continuous Delivery Workshop with Ansible x GitLab CI (5th)
 Continuous Delivery Workshop with Ansible x GitLab CI (5th) Continuous Delivery Workshop with Ansible x GitLab CI (5th)
Continuous Delivery Workshop with Ansible x GitLab CI (5th)
 
Y3CDS - Python class 01
Y3CDS - Python class 01 Y3CDS - Python class 01
Y3CDS - Python class 01
 
Eclipse,open ocd,openjta gv3嵌入式开发教程
Eclipse,open ocd,openjta gv3嵌入式开发教程Eclipse,open ocd,openjta gv3嵌入式开发教程
Eclipse,open ocd,openjta gv3嵌入式开发教程
 
2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學
2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學
2024 SIMPLIS 系列課程 _ SIMPLIS電路模擬軟體的基礎操作教學
 
Oracle Security 101
Oracle Security 101Oracle Security 101
Oracle Security 101
 
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
 
Introduction of Reverse Engineering
Introduction of Reverse EngineeringIntroduction of Reverse Engineering
Introduction of Reverse Engineering
 
Foundation of software development 2
Foundation of software development 2Foundation of software development 2
Foundation of software development 2
 
20200905_tcn_python_opencv_part1_omnixri
20200905_tcn_python_opencv_part1_omnixri20200905_tcn_python_opencv_part1_omnixri
20200905_tcn_python_opencv_part1_omnixri
 
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VMCompiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
Compiler for Dummy 一點都不深入的了解 Compiler, Interpreter 和 VM
 
视频编码原理简介Sohu版
视频编码原理简介Sohu版视频编码原理简介Sohu版
视频编码原理简介Sohu版
 
Head first in xmemcached yanf4j
Head first in xmemcached yanf4jHead first in xmemcached yanf4j
Head first in xmemcached yanf4j
 
Python 于 webgame 的应用
Python 于 webgame 的应用Python 于 webgame 的应用
Python 于 webgame 的应用
 
Tip for Editors
Tip for EditorsTip for Editors
Tip for Editors
 
用Erlang构建容错系统
用Erlang构建容错系统用Erlang构建容错系统
用Erlang构建容错系统
 
Erlang开发及应用
Erlang开发及应用Erlang开发及应用
Erlang开发及应用
 
Go语言: 互联网时代的C
Go语言: 互联网时代的CGo语言: 互联网时代的C
Go语言: 互联网时代的C
 
getPDF.aspx
getPDF.aspxgetPDF.aspx
getPDF.aspx
 

A True Story of Tanenbaum's Protocol Simulator