gpt4 book ai didi

java - 创建 IPv6 header

转载 作者:行者123 更新时间:2023-12-01 14:19:45 24 4
gpt4 key购买 nike

有人有用 java 创建的 IPv6 IP header (40 字节)吗?我已创建 IPv4 header 。

/**
* Creates IP header for given SIP packet
* Length of IP header is 20 octets. Below information shall be stored in each octet:
* Octet-0 - 0x45 (Version and length)
* Octet-1 - 0x00 (Type of service)
* Octet-2 - Upper byte of length of IP header and data
* Octet-3 - Lower byte of length of IP header and data
* Octet-4 - 0x00 (Upper byte of identification)
* Octet-5 - 0x00 (Lower byte of identification)
* Octet-6 - 0x00 (Flag)
* Octet-7 - 0x00 (Fragment Offset)
* Octet-8 - 0x80 (Time to live)
* Octet-9 - 0x11 (Protocol UDP)
* Octet-10 - Upper byte of checksum
* Octet-11 - Lower byte of checksum
* Octet-12 - Source IP address
* Octet-13 - Source IP address
* Octet-14 - Source IP address
* Octet-15 - Source IP address
* Octet-16 - Destination IP address
* Octet-17 - Destination IP address
* Octet-18 - Destination IP address
* Octet-19 - Destination IP address
*/

最佳答案

也许wikipedia文章会有帮助吗?

我不知道java语法,但是用C结构表示法,它会是这样的:

struct ipv6_header
{
unsigned int
version : 4,
traffic_class : 8,
flow_label : 20;
uint16_t length;
uint8_t next_header;
uint8_t hop_limit;
struct in6_addr src;
struct in6_addr dst;
};

我认为,将其翻译成您的语言可能非常简单。

关于java - 创建 IPv6 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17716213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com