ndnsim下转发策略的研究以及架构

来源:互联网 发布:淘宝开店认证不通过 编辑:程序博客网 时间:2024/05/21 13:56

// node self mobilityPtr<MobilityModel> mobility = this->m_node->GetObject<MobilityModel>();Vector v_NodePosition = mobility->GetPosition();Vector v_NodeVelocity = mobility->GetVelocity();Vector _n;_n.x=v_NodePosition.x+v_NodeVelocity.x;_n.y=v_NodePosition.y+v_NodeVelocity.y;// last hop mobilityPtr<Packet> p_copy = p->Copy();FwGeoTag geotag;p_copy->RemovePacketTag(geotag);uint32_t n_LastHopNodeId = geotag.GetNodeId();Vector v_LastHopPosition = geotag.GetPosition();Vector v_LastHopVelocity = geotag.GetVelocity();Vector _d2;_d2.x=v_LastHopPosition.x+v_LastHopVelocity.x;_d2.x=v_LastHopPosition.y+v_LastHopVelocity.y;Ptr<Packet> packet = p->Copy();try{// get last hop's node iduint32_t n_From = -1;string str_From;stringstream ss2;ss2 << from;ss2 >> str_From;char szValue[] = "00";szValue[0] = str_From.at(str_From.length() - 2);szValue[1] = str_From.at(str_From.length() - 1);uint32_t nValude = 0;sscanf(szValue, "%x", &nValude);n_From = nValude - 1;uint32_t type = Convert::getPacketType(p);// ============== Interest ================if (type == ::ndn::tlv::Interest){bool b_Sent = false;  // a flag indicating if this interest has been sent out successfully (has data)shared_ptr<const Interest> i = Convert::FromPacket<Interest>(packet);//NS_LOG_FUNCTION(Simulator::Now().GetSeconds() << this->m_node->GetId() << "Interest" << i->getName()<< n_From);NS_LOG_DEBUG(setprecision(8) << setw(9) << Simulator::Now().GetSeconds() << "\tInterest arrive at " << this->m_node->GetId() << "\t from " <<n_From << "\t name: " << i->getName());// BEACON Int: not forwardstring str_Name;stringstream s;s << i->getName().get(0);s >> str_Name;if (str_Name.compare("BEACON") == 0){// 1. check neighbor list, delete duplicated and outdatedNeighborQueue::iterator item = m_NeighborList.begin();while (item != m_NeighborList.end()){if (item->m_NodeId == n_LastHopNodeId || (Simulator::Now().GetSeconds() - item->m_Time.GetSeconds()) > 1){NeighborQueue::iterator tmp = item;tmp++;m_NeighborList.erase(item);item = tmp;}elseitem++;}// 2. add new entry to the listint degree=get_popularitity();//每秒更新beacon包,所以也是每秒更新受欢迎度,这里不能被注释,因为下面的语句需要插入degree,如果想注释,把degree随便赋值即可m_NeighborList.push_front(Neighbor_Item(Simulator::Now(), n_LastHopNodeId, v_LastHopPosition, v_LastHopVelocity,degree));// 3. look at Interest Retx List, schedule available retxItemQueue::iterator item_retx = m_RetxQueue_Interest.begin();int P=0;

终于在ndnsim下,完成了转发策略的研究。不是基于L3层,而是在L2层和L3层之间,处理包的发送和选择。并且完成了BEACON包所携带的位置,距离,速度互相交流。通过设置不同的转发时间,避免了洪泛广播,减少了网络拥塞,并且可以在容延网络下,重新转发兴趣包。研三,可以顺利结束了。

 

注:如果有同学想找我讨论转发策略等内容,请联系QQ:798309267

0 0
原创粉丝点击