Skip to main content

· 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

說到網路模擬,大家在試過各種模擬網路工具之後,都會覺得模擬網路比起實際架設其實並不是容易的事情,

網路模擬 Scenario 主要都是由 4 個部分構成:點,線,面,時間

因為網路通訊本身就由 Physical/MAC, IP, Network, Application 等層構成, 就 Physical/MAC 來簡分就有無線,有線之別,IP, Network 層裡又有多樣的協定, 總合起來先天網路通訊本模擬上就有極高的複雜度.

先由網路模擬 Scenario 來說. 在 ns2 上是在 tcl 檔中定義,在 omnet++ 上是在 ned 檔與 omnetpp.ini 檔中定義

· 2 min read

Digest from here :

In a mixed simulation involving wired and wireless nodes its necessary : 1. to turn on hierarchical routing 2. to create separate domains for wired and wireless nodes. There may be multiple wired and wireless domains to simulate multiple networks. 3. to have one base-station node in every wireless domain, thru which the wireless nodes may communicate with nodes outside their domain.

we need to use hierarchical routing in order to route packets between wireless and wired domains

  • the routing information for wired nodes are based on connectivity of the topology
  • use base-stations which act as gateways between wired and wireless domains

#Number of domains in this topology is 2 (one for the wired nodes and one for the wireless) AddrParams set domainnum 2

#Number of clusters in each of these domains #which indicates the first domain (wired) to have 1 clusters and #the second (wireless) to have 5 cluster. AddrParams set clusternum {1 5}

#the number of nodes in each of these clusters AddrParams set nodesnum {1 1 3 1 1 1}

心得: 在 mobiwan 中,bs 可以當 rt 用, 因此 bs 也有路由功能

每個 bs 都可以當 HA, 因此 mobiwan 裡不必指定 HA, mobile attach 上的那個點就自動做 HA.

所以 set mobile_ [create-mobile 1.4.1 1.4.0 1000 200 0 0 0.01] 表示 mobile 會把 1.4.0 這節點當作 HA

create-mobile 來自 proc-mipv6-config.tcl 啟動 def_mobile_config 來處理

base-station: create-base-station 啟動 def_bs_config 來處理 讓 bs 可以處理 wired&wireless 的重點是 #have wired routing mechanism turned on -wiredRouting ON 開啟 MIPv6 功能 -mipv6 ON

router: def_transit_config -mipv6 ON -mipagent CN

NS2 上的 RO 即是把 CN 當作 HA, 接收 BU, 然後作 tunnel 欲啟動 RO , 則在檔案最前頭宣告: Agent/MIPv6/MN set rtopti 1 ; # 0 if routing optimization OFF

· One min read

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

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