Coder Social home page Coder Social logo

gbn's Introduction

事件

我第一次写事件驱动型的结构,所以把事件的定义放在了单独文件中

可以直接看event.js文件,然后跳过本节

定义了以下事件:

  • packet_arrive:分组到达
  • new_packet_sended:生成新的分组
  • packet_loss:分组丢失
  • packet_move:分组移动
  • finish:传输结束

介绍

packet

pakcet中有5个成员:

  • sequence_number:分组的序号
  • key_number:分组的标识符
  • datatrue指数据分组, false指确认分组
  • position:分组所走过的路程
  • speed:分组传输的速度

分组传输

程序固定了发送到到接受方的距离:5000

packet.position >= 5000表示分组到达目的地

超时时间

默认为5000ms,保存在变量timeout

接口

pause() & keep_on()

暂停和继续

set_speed(packet)

设置分组的速度,默认为500

move_packet(packet)

分组的所走过的路程 += 速度

gbn's People

Contributors

xbghc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.