首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >创建IPv6标头

创建IPv6标头
EN

Stack Overflow用户
提问于 2013-07-18 14:35:19
回答 1查看 819关注 0票数 0

谁有用java创建的IPv6 IP报头(40字节)?我已经创建了IPv4头。

代码语言:javascript
运行
复制
/**
   * 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
   */
EN

回答 1

Stack Overflow用户

发布于 2013-07-18 14:44:38

也许wikipedia的文章会有所帮助?

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

代码语言:javascript
运行
复制
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;
};

我认为,把它翻译成你的语言是非常简单的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17716213

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档