Record of NS_Simulator bug fixed.

来源:互联网 发布:windows汉语意思 编辑:程序博客网 时间:2024/05/22 00:18

   In "RunController.h":

/*
Modify in 2012_04_07:
@1: modify the ~RunController(), in which MNs can be destruct without any obstruct, and guide MNs to destroy their pkts in buffer.
*/


   In "Node.h":

/*
Modify in 2012_04_07:
 @1: modify the Clear_MNs_Pkts(), and add the DestroyPkts() function into it;
 @2: modify the ReceiveAndStorePkt( int nPktType, char* pPkt), every MN should keep its own pkts buffer, not the pointer to the source MN's newed pkt.
*/


   Display the modified ReceiveAndStorePkt function here:

// ---------------- ReceiveAndStorePkt:

// Create a new Packet depend on the pSrcPkt, and store it into its buffer Storage.
void MNode::ReceiveAndStorePkt( _in int nPktType, _in char* pSrcPkt)
{
 assert( NULL != pSrcPkt);
 if ( NULL == pSrcPkt)
 {
  LogFile::instance()->m_ofErrLog << "Error: in MNode::StorePkt, NULL == pSrcPkt.\n";
  return;
 }

 // 1) Copy and Store the received Pkt, !! must create a new pPkt_dataPiece here.
 char* pPktData = new char[PIECESIZE+1];
 memset( pPktData, 0, PIECESIZE+1 );
 memcpy( pPktData, pSrcPkt, PIECESIZE );

  this->m_map_PktID__PktType_pData.insert( make_pair(m_nPktID, make_pair( nPktType, pPktData )) );
  m_nPktID++;  // every time, the PktID++.

// ...

}

// ------------- ReceiveAndStorePkt:~

原创粉丝点击