Skip to main content

· 4 min read

9th. Part: 編輯 IP6Datagram.msg 參考 IANAPROTOCOL NUMBERS 來改寫 IP6Datagram.msg

Protocol field -> Next Header field 因此 enum 名稱 IP6ProtocolFieldId 改成 IP6NextHeaderFieldId

IPv4 上叫 Protocol field, IPv6 上稱 Next Header field 為了相容性,將原本定義的 Protocol field 全保留之外,另外新增

  • IP6_PROT_IPv6_Route = 43; //Routing Header for IPv6 [Deering]
  • IP6_PROT_IPv6_Frag = 44; //Fragment Header for IPv6 [Deering]
  • IP6_PROT_ESP = 50; //Encap Security Payload [RFC2406]
  • IP6_PROT_AH = 51; //Authentication Header [RFC2402]
  • IP6_PROT_IPv6_ICMP = 58; //ICMP for IPv6 [RFC1883] IP6_PROT_NONE = 59; --> IP6_PROT_NoNxt = 59; //No Next Header for IPv6 [RFC1883]
  • IP6_PROT_Opts = 60; //Destination Options for IPv6 [RFC1883]
  • IP6_PROT_ENCAP = 98; //Encapsulation Header [RFC1241,RXB3]

除了這些之外,順便把一些 Routing protocol 的號也加了上去.

IP6_PROT_IPv6_MOBILITY 原本給 62, 改成 IP6_PROT_IPv6_MOBILITY = 135; //Mobility Header for IPv6 [RFC3775]

從一串配給號碼中發現比較特別的是

61                 any host internal protocol           [IANA]
63 any local network [IANA]
68 any distributed file system [IANA]
99 any private encryption scheme [IANA]
114 any 0-hop protocol [IANA]

剛開始看不知有何特別作用,後來想想這幾個保留位看起來對模擬工具好像不賴 --> 有新協定要試作? 不必改到標頭定義,暫時先用這幾個吧! 不過沒有標頭名稱怎麼辦? Orz ..... 還是暫時不要加進去好了

本檔案編完的下一步應是編輯 IP6Address.h 或 IP6ControInfo.msg 吧

Ref: IP VERSION 6 PARAMETERS , ICMPv6 TYPE NUMBERS

10th. Part:

編輯 IP6Datagram.msg 中的 message IP6Datagram : 參考 IPv6Suite IP6Datagram.cc 來改寫 IP6Datagram.msg

ToDo: 1. 將相關各標頭定義在檔案裡. 2. 定義 flow_label 結構 (struct, 20 bit = double + short OR int + int + short OR?) 3. 訂 Options Types

IP6Datagram.cc 中標頭是如此定義出來的:

static const ipv6_hdr IPV6_INITIAL_HDR = { 0x60000000, //version 6, traffic class of 0, flow label of 0 0, //payload of 0 59, //No next header yet 0, //Hop Limit set to uninitialised IPv6_ADDR_UNSPECIFIED, IPv6_ADDR_UNSPECIFIED };

完整的標頭:

message IP6Datagram
{
properties:
//g Still unknown its func
omitGetVerb = true;
fields:
short version = 6; // version 6
int traffic_class = 0; // traffic class of 0
IP6FlowLabel flow_label; // flow label of 0
double payload_length = 0; // payload of 0
int next_header enum(IP6NextHeaderFieldId) = IP_PROT_NONxt; // No next header yet
int hop_limit = 0; //Hop Limit set to uninitialised
IP6Address srcAddress;
IP6Address destAddress;
}

即將碰到 day 3 提到的 延伸標頭處理 問題. RFC2460 上的敘述是這樣的

4.1 Extension Header Order [Page 6] When more than one extension header is used in the same packet, it is recommended that those headers appear in the following order:

IPv6 header Hop-by-Hop Options header Destination Options header (note 1) Routing header Authentication header (note 2) Encapsulating Security Payload header (note 2) Destination Options header (note 3) upper-layer header Fragment header

填 class IP6Options, 碰到 Option_Data: Variable-length field. Option-Type-specific data 的問題

經 majorlee 學長指點 RFC 3493 Basic Socket Interface Extensions for IPv6. RFC 3542 Advanced Sockets Application Program Interface (API) for IPv6 裡可能會有答案.

· 2 min read

7th Part: 為了對將來開發好的程式進行測試,新增目錄 INET/Tests/IPv6 同時也發現原本 INET 程式的測試數量明顯不足,但還好結果不差.

發現 Firebird 的 scratchbook extension 可以編輯已截取的網頁文件,可以在原文件上畫重點並加上註解, 我想應該充分將這個特點利用在 INET 與 IPv6Suite 線上文件注釋上.

8th. Part: 分析 Mobiwan2 架構,並與學長留下的舊版程式碼作比對. 為此使用 WinMerge 程式來協助版本比對的工作.

OMNET++ INET 與 NS2 的比較: 目錄名: INET mobiwan 架構:按照 TCP/IP 作分層目錄 / 平行資料夾目錄 相依性:放到 OMNET++ 3.0 以上版本目錄下,依照 Readme 即可安裝 / 需 Patch 特定版本的 NS2

Mobiwan 新舊檔案比較 檔案:新 / 舊 ipv6.cc, ipv6.h: Network --> NetworkAgent

ipv6.cc - line 416 r line 497: hdripinip ppinhdr = (hdr_ipinip )p->access(off_ipinip); 改成: hdr_ipinip ppinhdr = (hdr_ipinip )hdr_ipinip::access(p);

mipv6.cc 大修改 mipv6.h: Binding 訊息,Mobile IPv6 Base Agent, Mobile IPv6 Node

ipv6routing.h, classifer-src.h 完全相同

tcl/lib 2.27 版多了很多檔案,包含 2.1b1 版所有檔案。尚不知是否會造成什麼影響

· 2 min read

5th Part: 閱讀論文: KAME IPv6 Impliment issue 文中指出 IPv6 遵照 IPv4 基礎來修改,所以基本觀念不變. 文中也提出一些 porting 中遇上的問題: 1. Scope 位址處理 2. 多重位址應綁介面 (Interface) 而非綁節點 (Node) 3. 延伸標頭處理 4. IPSec

目前可能會遇到的問題還不只這些: 1. 位址分析 2. 明確的參考資料 ...., etc

6th. Part 閱讀書籍: C++ 風格與藝術 第二版 (Practical C++ Programming, 2e) 整本書說明都很清晰,應該買一本手邊隨時參考

程式碼要像文章一樣分段落章節,每段並加入主題說明, 變數避免用縮寫,以降低程式複雜度

原型:先寫規格中可以運作的部分, 當這一小部份運作正常之後, 再以它為基礎, 建立其他的功能.

程式檔中應包含: Header 標題 Author 作者 Purpose 目的 Usage 用法 References 參考資料 File Formats 列出讀取 / 寫入的檔案與格式 Restrictions 限制 (Q by myself: 是否可延伸成代辦事項?Revice: ToDo 集中管理會比較有效率) Revision History Error Handling Copyright and License Notes 補充說明

  • 編輯提供 .ned 架構檔在 NodePad++ 編輯關鍵字加亮的定義, 但還沒找到獨立提供這個設定檔的方法

3/11 update: 定義在 NodePad++ 資料夾下 userDefineLang.xml 檔中

· 2 min read

16.3.1. 確認是否支援

嘗試載入模組,確認是否編譯成功

# modprobe ip6_tables

確認相容性

� 'ip6tables' firewalling (IPv6)!"

16.3.2. 學習如何使用 ip6tables

16.3.2.1. 列出所有 IPv6 netfilter 輸入條件

  • 短指令

# ip6tables -L

  • 延伸指令 ip6tables -n -v --line-numbers -L

16.3.2.2. 列出特定過濾器

# ip6tables -n -v --line-numbers -L INPUT

16.3.2.3. 使用選項在輸入過濾器中插入紀錄規則

� --log-level 7

16.3.2.4. 在輸入過濾器中插入拋棄條件

# ip6tables --table filter --append INPUT -j DROP

16.3.2.5. 依號碼刪除一筆條件

# ip6tables --table filter --delete INPUT 1

16.3.2.6. 允許 ICMPv6 訊息

使用較舊的 Linux 核心 (未修正的核心 2.4.5 與 iptables-1.2.2) 將無法指定類型 (type)

  • 接受透過隧道 (Tunnel) 進來的 ICMPv6 通訊

# ip6tables -A INPUT -i sit+ -p icmpv6 -j ACCEPT

  • 接受透過隧道 (Tunnel) 出去的 ICMPv6 通訊

# ip6tables -A OUTPUT -o sit+ -p icmpv6 -j ACCEPT

新的 Linux 核心可以指定 ICMPv6 類型:

# ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT

16.3.2.7. 速率限制

· 3 min read

16.2.1. 取得原始檔

取得最新的 Linux 核心原始檔: http://www.kernel.org/

取得最新的 iptables 套件:

16.2.2. 將原始檔解壓縮

切換到原始檔所在目錄:

# cd /path/to/src

將原始檔解開並更名 # tar z|jxf kernel-version.tar.gz|bz2

# mv linux linux-version-iptables-version+IPv6

解壓縮 iptables 原始檔

# tar z|jxf iptables-version.tar.gz|bz2

16.2.3. 將最新 iptables/IPv6 - 相關 修正檔修正到 Linux 核心原始檔上

切換到 iptables 所在目錄:

# cd iptables-version

使用修正檔 # make pending-patches KERNEL_DIR=/path/to/src/linux-version-iptables-version/

使用其他 IPv6 相關修正檔 (核心尚未包含的)

# make patch-o-matic KERNEL_DIR=/path/to/src/linux-version-iptables-version/

在以下選項中選擇 yes (iptables-1.2.2)

  • ah-esp.patch
  • masq-dynaddr.patch (only needed for systems with dynamic IP assigned WAN connections like PPP or PPPoE)
  • ipv6-agr.patch.ipv6
  • ipv6-ports.patch.ipv6
  • LOG.patch.ipv6
  • REJECT.patch.ipv6

確認 IPv6 extensions

Extensions found: IPv6:owner IPv6:limit IPv6:mac IPv6:multipor
``

## 16.2.4\. 配置, 建立與安裝新 Linux 核心
切換到Linux核心所在目錄:

`# cd /path/to/src/linux-version-iptables-version/`

編輯 Makefile
- EXTRAVERSION =
+ EXTRAVERSION = -iptables-version+IPv6-try

執行 configure, 啟動 IPv6 相關支援

Code maturity level options Prompt for development and/or incomplete code/drivers : yes Networking options Network packet filtering: yes The IPv6 protocol: module IPv6: Netfilter Configuration IP6 tables support: module All new options like following: limit match support: module MAC address match support: module Multiple port match support: module Owner match support: module netfilter MARK match support: module Aggregated address check: module Packet filtering: module REJECT target support: module LOG target support: module Packet mangling: module MARK target support: module


同時亦配置其他與系統相關的參數. 完整的核心編譯與安裝請參照其他 HOWTOs

## 16.2.5\. 重新建立與安裝iptables binaries

確認核心原始碼已存在於 /usr/src/linux/

將舊目錄更名
`# mv /usr/src/linux /usr/src/linux.old`

建立一個新的軟連結(softlink)

`# ln -s /path/to/src/linux-version-iptables-version /usr/src/linux`

重新建立 SRPMS
`# rpm --rebuild /path/to/SRPMS/iptables-version-release.src.rpm`

安裝新的 iptables 套件 (iptables + iptables-ipv6)

* 在 RH 7.1 系統上, 正常狀況下已安裝好舊版的 iptables , 因此我們"更新"它

`# rpm -Fhv /path/to/RPMS/cpu/iptables*-version-release.cpu.rpm`

* 若尚未安裝, 就先"安裝"它

`# rpm -ihv /path/to/RPMS/cpu/iptables*-version-release.cpu.rpm`

* On RH 6.2 systems, normally, no kernel 2.4.x is installed, therefore the requirements don't fit. Use "--nodeps" to install it

`# rpm -ihv --nodeps /path/to/RPMS/cpu/iptables*-version-release.cpu.rpm`

也許須先新建一個軟連結給 iptables 參照檔

`# ln -s /lib/iptables/ /usr/lib/iptables`