Skip to main content

34 posts tagged with "OMNET++"

View All Tags

· 2 min read

----in IPv6SuiteWithINET: work---- Applications/UDPApp 下新增 "NDSBasicApp.cc", "NDSBasicApp.h", "NDSBasicApp.ned".

makemake nmake -f makefile.vc depend (option) m.bat

----in INET: not work---- Our goal is to build a UDP based Application named NDSApp.

1. Add "NDSApp" folder in "INET/Applications" folder

2. Modifiy "INET/makemake.cmd" to generate makefile for the new App(If you add/remove/rename directories). set ALL_INET_INCLUDES: append -I%root%/Applications/NDSApp

We copied the line "cd %root%\Applications\UDPApp && ....." and change "UDPApp" to "NDSApp"

cd %root%\Nodes\INET: append -I....\Applications\NDSApp

3. Copy files "UDPApp.cc", "UDPApp.h", "UDPApp.ned" from "UDPApp" folder, Rename "UDPApp.cc", "UDPApp.h", "UDPApp.ned" to "NDSApp.cc", "NDSApp.h", "NDSApp.ned".

4. In file "NDSApp.cc" "#include "UDPApp.h"" to "#include "NDSApp.h"" Replace the class inherits and function names from "UDP"xx to "NDS"xx, ex: "UDPSink::initialize();" to "NDSSink::initialize();"

5. Add NDSApp to StandardHost Modifiy INET/Nodes/StandardHost.ned At import section: append "NDSApp,"

At module StandardHost parameters section: Append "numNdsApps : numeric const, "ndsAppType : string,"

At module StandardHost submodules section: Append ndsApp: ndsAppType[numNdsApps] like NDSApp; display: "i=block/app;p=392,67";

At module StandardHost connections section: Append "for i=0..numNdsApps-1 do ndsApp[i].to_udp --> udp.from_application++; ndsApp[i].from_udp <-- udp.to_application++; endfor;"

makemake nmake -f makefile.vc depend m.bat

Then test it in Example/INET/Multicast

modify its omnetpp.ini

set UDPApp off

udp app (off)

.numUdpApps=0 .udpAppType="UDPApp"

modified udp app configuration to nds app configuration, note the captions.

· 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

· One min read

20th. Part: IPv6suite 的 IPProccessing 用的是 IPv4d 資料夾中的架構.

21th. Part: Mac 層要加入 0x86DD 代表 IPv6 訊息

· 2 min read

18th. Part: NetworkLayer6.ned: disable OSPF, RSVP 原 protocolMapping = "6:0,17:1,1:2,2:3,46:4,89:5"; 表示 TCP (6):0, UDP (17):1, ICMP (1):2, IGMP (2):3, RSVP (46):4, OSPF (89):5 考慮到保證將來 DualStack 相容性,因此不更改原對應數字,而從後面再繼續補加.

暫時補加 ICMPv6 (58):2, ROUTING (43), MOBILITY (135) protocolMapping 後添上 58:6,43:7,135:8

  • 應再找資料確認 Neighbor Discovery -- ND 模組是否應包含在 ICMPv6 模組裡

19th. Part: 照著 Winodws 步驟,以 TicToc10 為基礎編譯. OMNET++/Sample/INET6Test: 修改 IP6Datagram.msg 以通過 compiler.

這次是針對 "模擬" 來做修正:

  • 因為 20 bits 不好宣告 (RFC 中是連 version, Traffic Class 一同宣告在一起), 因此 flow label 欄位訂的較 RFC 小 (20->16) (反正沒在用,應該沒什麼關係)
  • 在訂 IPv6 options message struct 時,Padding 不加似乎也沒關係
  • IP6FRAGMENT identification 欄位訂的較 RFC 小 (32->16)

目前採用方式 -> 全改用 int , short, long 來宣告,皆遠大於所需位元數