npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reudp

v1.3.0

Published

Reliable UDP implementation for Node

Downloads

5

Readme

Reliable UDP implementation for Node

协议定义

术语定义

逻辑包:从上层应用中接收到的 buffer 物理包:对逻辑包按固定大小(500Byte)进行分割 发送端: 发送数据包的端点 接收端: 接收数据包的端点

数据包定义

所有的 UDP 包都有以下头部:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        CHECKSUM(16)           |    TYPE(8)    |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            ID(32)                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

其中,

  • CHECKSUM 为简单的校验和,主要用来过滤掉无效的 UDP 包
  • TYPE 为下面表格里列出的包类型值
  • ID 为逻辑包的 id

TYPE

| Type | Value | Description | |---------|-------|-----------------------------------------------------------| | UDP_PSH | 0x01 | 数据包,用于发送端发送数据(物理包) | | UDP_REQ | 0x02 | 控制包,用于接收端请求未接收到的物理包 | | UDP_FIN | 0x03 | 控制包,用于通知发送端所有物理包已接收完毕 | | UDP_ACK | 0x04 | 控制包,用于通知发送端已成功接收到控制包 | | UDP_ERR | 0x05 | 控制包,用于发生错误时 |

UDP_PSH 类型包的其他部分:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           SEQ(16)             |      SEQ_SINGLE_TOTAL(16)     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         SEQ_TOTAL(16)         |         DATA(* lte 500)     ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

其中,

  • SEQ 为物理包的序号 id
  • SEQ_SINGLE_TOTAL 为一次并行发送的物理包的数量
  • SEQ_TOTAL 为一个逻辑包里包含的物理包的数量
  • DATA 为物理包的内容(这里固定为 500Byte,当小于 500B 时为实际大小)

UDP_REQ 类型包的其他部分:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      REQ_SEQ_ARRAY(*)                       ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

其中,

  • REQ_SEQ_ARRAY 为接收端请求其他未收到的物理包的序号(SEQ)的数组

UDP_FIN 类型包只有头部

UDP_ACK 类型包的其他部分:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  ACK_TYPE(8)  |
+---------------+

其中,

  • ACK_TYPE 为 UDP_REQ | UDP_FIN | UDP_ERR 等值

UDP_ERR 类型包的其他部分:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         ERR_TYPE(16)          |
+-------------------------------+

其中,

  • ERR_TYPE 为错误的类型