Ruby 从人类可读的位置创建二进制数据
我正在创建一个作为 IPv6 数据包有效负载的变量,我需要将多种数据格式连接到它,但遇到了一些麻烦。
具体来说,我有:
64 - unsigned int 1 byte (prefix length)
1100 0000 - binary 1 byte (flags)
86400 - unsigned int, left padded/4 bytes (lifetime)
14400 - unsigned int, left padded/4 bytes (preferred lifetime)
0x00 0x00 0x00 0x00 - reserved/unused 4 bytes
红宝石新手 - 任何事情都会有帮助。
I am creating a variable that is the payload of an IPv6 packet, and I need to have multiple data formats concatenated to it, and am having some trouble.
Specifically, I have:
64 - unsigned int 1 byte (prefix length)
1100 0000 - binary 1 byte (flags)
86400 - unsigned int, left padded/4 bytes (lifetime)
14400 - unsigned int, left padded/4 bytes (preferred lifetime)
0x00 0x00 0x00 0x00 - reserved/unused 4 bytes
New to ruby - anything will help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您熟悉pack吗?这可能就是您构建数据包所需的。
Are you familiar with pack? That's probably what you'll need to build your packets.