2012-06-27 53 views
5

我想知道如何獲取數據包正在處理的節點ID。如何在NS2中查找節點ID?

我試過name(),但它沒有給出節點的id,就像跟蹤文件中顯示的一樣,其中顯示了分組跳的源和目的地。在來自格式()的跟蹤文件中,源和目標可用,但如何訪問它們,這可能也有助於瞭解當前處理正在進行的節點。

這是關於NS2。有人可以提供一些幫助。

回答

4
MobileNode *thisnode = (MobileNode *) ((Node::get_node_by_address(id))); 
printf("%d\n",thisnode->address()); 

你可以得到這個節點的ID!嘗試一下。

1

試試這個:

Node *thisnode = Node::get_node_by_address(id); 
printf("%d\n",thisnode->nodeid()); 

其中id僅僅是一個數字的節點: 前節點(1):

Node *thisnode = Node::get_node_by_address(1) 
printf("%d\n",thisnode->nodeid());