2013-07-18 85 views
0

有沒有人在java中創建IPv6 IP標頭(40字節)?我創建了IPv4標頭。創建IPv6標頭

/** 
    * 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 
    */ 
+2

歡迎來到Stack Overflow。你能告訴我們[你試過的是什麼](http://mattgemmell.com/2008/12/08/what-have-you-tried/)? –

+0

歡迎來到Stack Overflow!看起來你希望我們爲你寫一些代碼。儘管許多用戶願意爲遇險的編碼人員編寫代碼,但他們通常只在海報已嘗試自行解決問題時才提供幫助。證明這一努力的一個好方法是包含迄今爲止編寫的代碼,示例輸入(如果有的話),期望的輸出和實際獲得的輸出(控制檯輸出,堆棧跟蹤,編譯器錯誤 - 無論是適用)。您提供的細節越多,您可能會收到的答案就越多。 – thegrinner

回答

1

也許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; 
}; 

我認爲,它可以是很簡單的翻譯本在你的語言。