Skip to main content

59 posts tagged with "IPv6"

View All Tags

· One min read

IPv6 Programming in 5 minutes in IPv6Style

Use DNS record to check dual stack:

  1. Try accessing the IPv6 address written in the AAAA record.

  2. If an attempt to connect using IPv6 fails, try accessing the IPv4 address written in the A record. Use address family independent function: getaddrinfo()

· 2 min read

If the dest_addresses parameter contains more than one address, one of them is randomly chosen for each packet.

An address may be given in the dotted decimal notation, or with the module name. (The IPAddressResolver class is used to resolve the address.)

To disable the model, set dest_addresses to "".

The peer can be UDPSink or another UDPBasicApp (it handles received packets exactly like UDPSink).


UDPAppBase: *** void UDPAppBase::bindToPort(int port)

cMessage msg = new cMessage ("UDP_C_BIND", UDP_C_BIND); 建立新 message "msg", 使用 UDP_C_BIND 格式

UDPControlInfo ctrl = new UDPControlInfo (); 建立新 record "ctrl"

ctrl->setSrcPort (port); 將 port 參數設定進 ctrl 的 SrcPort 參數中

msg->setControlInfo (ctrl); 將 ctrl 包進 msg 中的 ControlInfo 參數中

send (msg, "to_udp"); 送到傳輸層的 udp 做處理

void UDPAppBase::sendToUDP(cMessage *msg, int srcPort, const IPvXAddress& destAddr, int destPort)

msg->setKind(UDP_C_DATA); Send message to UDP, with the appropriate control info attached

其他類似 bindToPort ()


UDPSink: void UDPSink::initialize()

WATCH (numReceived); TKenv 中顯示 numReceived 變數

if (port!=-1) bindToPort (port); port 數字正常就將 port 參數繫結到埠號

void UDPSink::handleMessage (cMessage *msg) 處理封包並秀 numReceived 狀態在畫面中

void UDPSink::processPacket (cMessage *msg) 收到封包後刪除,numReceived 數 +1


UDPBaseApp

const char destAddrs = par ("dest_addresses"); 讀入目的位址 cStringTokenizer tokenizer (destAddrs); const char token; while ((token = tokenizer.nextToken ())!=NULL) destAddresses.push_back (IPAddressResolver ().resolve (token)); 解析 string 成可辨識的位址格式

void UDPBasicApp::sendPacket () IPvXAddress destAddr = chooseDestAddr (); 超過一個目的位址時從中選擇隨機目的位址

IPvXAddress UDPBasicApp::chooseDestAddr () { int k = intrand (destAddresses.size ()); destAddresses.size () 即目標位址數量,intrand (n) 從 n 中隨機取一數

return destAddresses[k];

}

· 2 min read

22th. Part: 修改 IPControlInfo.msg: 協定對應改成 IP6NextHeaderFieldId

檢討:在修改一陣子模組之後,對整個架構更了解的同時, 也更了解修改整個 IP 協定的難度. 因為了解,而越來越缺少每個部分改好兜起來就能跑的自信.

所以檢討了現在 porting 的方法,歸納出下面幾條新的 porting 步驟:

第一階段:多方嘗試 (完成) 1. 初步對各主要模組了解,trace code 同時並做初步 porting. 2. 儲存當前 porting slices 成果

第二階段:系統化調試 1. 一切修改都應該先以能執行,能隨時觀察模擬流程為目標. (每次修改都能編出可用的快照檔 (snapshot)) 2. 將 IP 相關模組複製一份,編譯,確定可用的新增協定方式 3. 階段修改 2. 修改 Mac 層加入訊息 3. 修改 IPDatagram.msg 新增協定 4. 修改協定訊息 5. 修改各 Class 名稱 6. 實際修改 Class 7. 路由表位址,位址解譯,flatconfigurator

第三階段:新增功能 1. Neighbor Discovery (Major Option). MIPv6 & NEMO (After Wireless Support) 2. DualStack 3. Extension Header Proccessing 4. RSVP, Multicast