简体   繁体   English

处理可靠性的序列ID

[英]sequence ID for handling reliability

I'm trying to figure out a simple way to handle reliability for UDP messages. 我正在尝试找出一种处理UDP消息可靠性的简单方法。 I figured I would just send each one with a sequencing ID and by comparing the ID to the one previously received, a loss can be detected. 我想我只给每个人发送一个测序ID,然后通过将ID与先前收到的ID进行比较,就可以发现丢失。 I would normally just use integers however the idea that it would just keep incrementing indefinitely did not sit right with me. 我通常只使用整数,但是它会无限期递增的想法并不适合我。

I could use base64, but that would only make it a bit more readable but doesn't really solve anything. 我可以使用base64,但这只会使它更具可读性,但并不能真正解决任何问题。

I also considered prefixing a date stamp however that would be kind of sloppy when dealing messages received around midnight. 我还考虑过为日期戳添加前缀,但是在处理午夜左右收到的消息时,这会有点草率。

I feel like there must a better solution that someone could suggest, even if that is to just stick with integers. 我觉得有人必须提出一个更好的解决方案,即使那只是坚持使用整数。

My preference for this particular job is to use an incrementing (at least 64-bit) integer sequence seeded with a high-resolution timestamp. 我偏爱此特定工作,是使用以高分辨率时间戳作为种子的递增(至少64位)整数序列。 In this way, even if there is a loss of state at the sending end, when the sequence is re-seeded from the time, it will in all likelihood simply jump forward. 这样,即使在发送端丢失状态,从该时间起重新播种该序列时,也很可能会简单地向前跳。 Any Year 10K bugs that this might introduce are left as an exercise for Lazarus Long. Lazarus Long可能会练习任何可能引起的10K年错误。 :-) :-)

Keep in mind that sequence-gap detection is essentially an optimization. 请记住,序列间隔检测本质上是一种优化。 The transmitting end needs to retransmit until an ack is received, with a nack (for a gap or corrupted datagram) simply eliciting earlier retransmission. 发送端需要重新发送,直到接收到一个ack为止,而nack(用于间隙或损坏的数据报)仅会引起较早的重新发送。 (ZMODEM is a rare exception to this rule, with its default mode of operation being the use of a single ack at the end of the stream and all other retransmissions governed by nacks; as a file transfer protocol, however, it is essentially one giant multipart datagram.) (ZMODEM是此规则的罕见例外,它的默认操作模式是在流的末尾使用单个ack以及由nacks控制的所有其他重传;但是,作为文件传输协议,它实际上是一个巨大的优势多部分数据报。)

Use TCP? 使用TCP? This is why TCP is different to UDP 这就是为什么TCP与UDP不同的原因

I don't mean to be sarcastic, but this is why TCP is there. 我并不是要讽刺,但这就是为什么存在TCP的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM