Skip to main content

7th. day of porting INET6 第七天

· 2 min read

13th. Part: 看 RFC3493RFC 2542 一邊處理 IP6Address.h 位址格式設定的問題.

原本 IPAddress 內部結構是 unsigned char addr [4]; 用來儲存 32bits IP 位址 改成 IP6Address 後, 內部結構要儲存 128 bits IPv6 位址,因此改成 uint8_t s6_addr [16];

取消輸入值或回傳值為 int 型態的函數,因為與 IPv6 位址表示方式不符, 這部分需弄更清楚後再作加強.

14th. Part: 聯想:

猜測 OMNET++ 中的 IPControInfo 應該就是 RFC 中的 sockaddr_in , 是用來與上層協定溝通的資料結構.

該詢問 INET Wireless 模組部分的進度 The routing information for wired nodes are based on connectivity of the topology, i.e how are nodes connected to one another through Links. This connectivity information is used to populate the forwarding tables in each wired node., however wireless nodes have no concept of "links".

Inorder to exchange pkts among these wired and wireless nodes, Base-stations(BS) is introduced to act as gateways between the two domains.

porting 學長模組時, 發現 OPNET/NS2 (Mobiwan2) 共同的缺點是模組用太多簡寫, 讓人剛開始沒有辦法一看就很清楚這模組的作用...... 若能減少花在辨認簡寫上的時間, 使用者可以更容易明瞭各模組的作用, 也能更容易去使用它們.

4th day of tracing INET6: Application/TCPApp Echo&Sink

· 3 min read

從 UDPApp 或 TCPApp 一堆檔案中,總是要從 xxSinkApp 最先開始看, 最簡單又能猜測到大致流程的一定是這幾個檔案,透過這樣 tracing code 熟悉了大致架構後,看其他相關檔案時會事半功倍.

因為 xxSinkApp 明顯講的都會是如何收到這種類型的封包,還有收到後如何將封包消滅的過程


TCPSinkApp void TCPSinkApp::initialize()

TCPSocket socket; 宣告 TCPSocket

socket.setOutputGate(gate("tcpOut"));

socket.bind (address [0] ? IPAddress (address) : IPAddress (), port); 繫結 "位址 - 埠號"

socket.listen(true);

.... 參考一般 socket 連線相關文件

void TCPSinkApp::handleMessage (cMessage *msg) if (msg->kind ()==TCP_I_PEER_CLOSED) 如果狀態為 TCP_I_PEER_CLOSED

msg->setKind (TCP_C_CLOSE); 將狀態設成 TCP_C_CLOSE

send (msg, "tcpOut"); 將訊息送到 "tcpOut"

else if (msg->kind ()==TCP_I_DATA || msg->kind ()==TCP_I_URGENT_DATA) 如果狀態為 TCP_I_DATA 或 TCP_I_URGENT_DATA

bytesRcvd += msg->length ()/8; bytesRcvd += 收到的封包 bit 長度 / 8 (變成 byte)

delete msg; 並將訊息刪除

else delete msg; 收到其他狀態訊息的話都直接刪除


TCPEchoApp echoFactor=1 will result in sending back the same message unmodified The lengths of the messages are multiplied by echoFactor before sending them back

void TCPEchoApp::sendOrSchedule(cMessage *msg)

if (delay==0) 若 delay 變數值為 0

bytesSent += msg->length ()/8; 紀錄總共送出的封包 byte 長度

send (msg, "tcpOut"); 並送出訊息

else scheduleAt (simTime ()+delay, msg); 否則繼續等待 delay 這段時間

void TCPEchoApp::handleMessage(cMessage *msg)

if (msg->isSelfMessage ()) 若訊息來自本身 紀錄總共送出的封包 byte 長度 並送出訊息

else if (msg->kind ()==TCP_I_PEER_CLOSED) 如果狀態為 TCP_I_PEER_CLOSED

msg->setKind (TCP_C_CLOSE); 將狀態設成 TCP_C_CLOSE

sendOrSchedule (msg); 將訊息傳到 sendOrSchedule () 處理

else if (msg->kind ()==TCP_I_DATA || msg->kind ()==TCP_I_URGENT_DATA) 如果狀態為 TCP_I_DATA 或 TCP_I_URGENT_DATA 紀錄總共收到的封包 byte 長度

if (echoFactor==0) 若 echoFactor==0 將訊息刪除

else 其他: msg->setKind (TCP_C_SEND); 狀態設成 TCP_C_SEND

//reverse direction, modify length, and send it back

TCPCommand *ind = check_and_cast<TCPCommand *>(msg->removeControlInfo ()); 將 msg 的 ControlInfo 去掉後,強制轉換型別成 TCPCommand

TCPSendCommand *cmd = new TCPSendCommand();

cmd->setConnId(ind->connId()); msg->setControlInfo(cmd);

delete ind; 將不再用到的 ind 刪除

計算回傳訊息大小: long len = long (msg->length ()echoFactor) & ~7U; 將原訊息長度echoFactor

if (len<8) len=8; 若訊息長度小於 1 byte, 補足成 1 byte

msg->setLength (len); 設定回傳訊息長度 sendOrSchedule (msg); 排到 sendOrSchedule () 中

else delete msg; 收到其他狀態訊息的話都直接刪除

5th day of tracing INET6: setStatusString()

· One min read

void TCPGenericCliAppBase::setStatusString(const char *s) { if (ev.isGUI()) displayString().setTagArg("t", 0, s); }

void TCPGenericCliAppBase::socketEstablished(int, void *) { // redefine to perform or schedule first sending ev << "connected\n"; setStatusString("connected"); }

IPv6SuiteWithINET

· One min read

剛看到

上提供了 IPv6SuiteWithINET for OMNeT++ 3.1, windows/linux 版.

趕快來試用,如果沒問題的話那 INET6 計畫的下一步就修正成寫 IPv6SuiteWithINET 文件推廣囉, 當然,要先自己 trace 一遍才知人家怎麼做的

4/21 quick revice: 必須安裝 VC 7.1 編譯程式才能編譯,6.0 的不行。程式可以由下面連結下載 http://www.microsoft.com/downloads/details.aspx?FamilyID=272be09d-40bb-49fd-9cb0-4bfa122fa91b&amp;displaylang=en

FreeBSD TCP/IP-Stack to OMNeT++

· One min read

I found this paper through IEEE Xplore, and intrest in the topic "Eval freeBSD protocol stack in OMNeT++".

Integration of the FreeBSD TCP/IP-Stack into the Discrete Event Simulator OMNet++ Bless, R.; Doll, M.; Simulation Conference, 2004. Proceedings of the 2004 Winter Volume 2, December 5-8, 2004 Page(s):487 - 492

--

  • In asimulation environment one wants to run several hosts in parallel, So every required global and static FreeBSD variable must be made local to each host. -> a structure to store all the kernel variables for one host. -> Consequently,in the FreeBSD source every occurrence of the variables must be replaced by a reference into the corresponding structure.

ex: xyz is replaced to D->xyz

where D points to the current host structure that contains all the global and static kernel variables for this particular host.

  • Encapsulate the complete TCP/IP into one OMNeT++ simple module.

Others are out of my knowledge...... In consequence, I think porting protocol stacks from different architecture is still not an easy way....