当前位置: 首页>>代码示例>>C++>>正文


C++ Packet::Copy方法代码示例

本文整理汇总了C++中Packet::Copy方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::Copy方法的具体用法?C++ Packet::Copy怎么用?C++ Packet::Copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet的用法示例。


在下文中一共展示了Packet::Copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

void
AmRlcEntity::ReceptionProcedureEnd ()
{
#ifdef RLC_DEBUG
  std::cout << "AM RLC ReceptionProcedureEnd " << std::endl;
  PrintReceivedAMDs ();
#endif

  if (m_receivedAMDs->size () == 0) return;

  int currentPacket = -1;
  int expectedNextByte = 0;

  std::list<int> packetIdToDelete;

  std::vector <AmdRecord*>::iterator it;
  for (it = m_receivedAMDs->begin (); it != m_receivedAMDs->end (); it++)
	{
	  Packet* packet = (*it)->m_packet;

	  if (packet->GetID () != currentPacket && packet->GetRLCHeader ()->GetStartByte () == 0)
		{
		  //std::cout << "\t\t !! first fragment of the packet" << std::endl;
          currentPacket = packet->GetID ();
          expectedNextByte = packet->GetRLCHeader ()->GetEndByte () + 1;
		}
	  else if (packet->GetID () != currentPacket && packet->GetRLCHeader ()->GetStartByte () != 0)
	    {
		  //std::cout << "\t\t !! fragment of a new packet, but not he first" << std::endl;
		  expectedNextByte = 0;
	    }
	  else if (packet->GetID () == currentPacket && packet->GetRLCHeader ()->GetStartByte () ==  expectedNextByte)
	    {
		  if (packet->GetRLCHeader ()->IsTheLatestFragment ())
		    {
			  //std::cout << "\t\t !! consecutive fragment --> the packet can be reassembled" << std::endl;
			  RadioBearerSink *bearer = (RadioBearerSink*) GetRadioBearerInstance ();
              Packet* p = packet->Copy ();
              p->SetSize (packet->GetRLCHeader ()->GetEndByte () + 8);
			  bearer->Receive (p);

	          packetIdToDelete.push_front(packet->GetID ());

	    	  expectedNextByte = 0;
		    }
		  else
		    {
			  //std::cout << "\t\t !! consecutive fragment --> we expect another fragment" << std::endl;
			  expectedNextByte = packet->GetRLCHeader ()->GetEndByte () + 1;
		    }
	    }
	}


  //DELETE REASSEBLED PACKETS!
#ifdef RLC_DEBUG
  std::cout << "\t\t !! DELETE REASSEBLED PACKETS" << std::endl;
#endif

  for (std::list<int>::iterator iter = packetIdToDelete.begin (); iter != packetIdToDelete.end (); iter++)
    {
	  std::vector <AmdRecord*> *newAmdList = new std::vector <AmdRecord*>;
	  int id = (*iter);
	  for (std::vector <AmdRecord*>::iterator  itt = m_receivedAMDs->begin (); itt != m_receivedAMDs->end (); itt++)
		{
		  AmdRecord *amdRecord = (*itt);
		  double delay = amdRecord->m_packet->GetTimeStamp () + GetRadioBearerInstance ()->GetQoSParameters ()->GetMaxDelay ();
  		  if (amdRecord->m_packet->GetID () == id)
			{
				delete amdRecord;
			}
  		  else
  		    {
  			  newAmdList->push_back (amdRecord);
  		    }
		}
   	  m_receivedAMDs->clear();
   	  delete m_receivedAMDs;
   	  m_receivedAMDs = newAmdList;
    }


  //DELETE PACKETS or AMDs WHOSE DEADLINE is EXPIRED !
#ifdef RLC_DEBUG
  std::cout << "\t\t !! DELETE PACKETS or AMDs WHOSE DEADLINE is EXPIRED !" << std::endl;
#endif

  int currentpacketId = -1;
  std::vector <AmdRecord*> *newAmdList = new std::vector <AmdRecord*>;
  for (std::vector <AmdRecord*>::iterator  itt = m_receivedAMDs->begin (); itt != m_receivedAMDs->end (); itt++)
	{
	  AmdRecord *amdRecord = (*itt);
	  double delay = amdRecord->m_packet->GetTimeStamp () + GetRadioBearerInstance ()->GetQoSParameters ()->GetMaxDelay ();
	  if ((delay + 0.01) < Simulator::Init()->Now())
		{
		  //trace for statistical purposes
		  Packet *pp = amdRecord->m_packet;
		  if (pp->GetID () !=  currentpacketId)
		    {
			  currentpacketId = amdRecord->m_packet->GetID ();
//.........这里部分代码省略.........
开发者ID:AbubakarAuwal,项目名称:lte-sim,代码行数:101,代码来源:am-rlc-entity.cpp

示例2: PacketBurst

void
DL_my_algo_PacketScheduler2::DoStopSchedule (void)
{
#ifdef SCHEDULER_DEBUG
  std::cout << "\t Creating Packet Burst" << std::endl;
#endif

  PacketBurst* pb = new PacketBurst ();

  //Create Packet Burst
  FlowsToSchedule *flowsToSchedule = GetFlowsToSchedule ();

  for (FlowsToSchedule::iterator it = flowsToSchedule->begin (); it != flowsToSchedule->end (); it++)
    {
	  FlowToSchedule *flow = (*it);

	  int availableBytes = flow->GetAllocatedBits ()/8;

	  if (availableBytes > 0)
	    {

		  flow->GetBearer ()->UpdateTransmittedBytes (availableBytes);

#ifdef SCHEDULER_DEBUG
	      std::cout << "\t  --> add packets for flow "
	    		  << flow->GetBearer ()->GetApplication ()->GetApplicationID () << std::endl;
#endif

	      RlcEntity *rlc = flow->GetBearer ()->GetRlcEntity ();
	      PacketBurst* pb2 = rlc->TransmissionProcedure (availableBytes);

#ifdef SCHEDULER_DEBUG
	      std::cout << "\t\t  nb of packets: " << pb2->GetNPackets () << std::endl;
#endif

	      if (pb2->GetNPackets () > 0)
	        {
	    	  std::list<Packet*> packets = pb2->GetPackets ();
	    	  std::list<Packet* >::iterator it;
	    	  for (it = packets.begin (); it != packets.end (); it++)
	    	    {
#ifdef SCHEDULER_DEBUG
	    		  std::cout << "\t\t  added packet of bytes " << (*it)->GetSize () << std::endl;
	    		  //(*it)->Print ();
#endif

	    		  Packet *p = (*it);
	    		  pb->AddPacket (p->Copy ());
	    	    }
	        }
	      delete pb2;
	    }
	  else
	    {}
    }

  //UpdateAverageTransmissionRate ();

  //SEND PACKET BURST

#ifdef SCHEDULER_DEBUG
  if (pb->GetNPackets () == 0)
    std::cout << "\t Send only reference symbols" << std::endl;
#endif

  GetMacEntity ()->GetDevice ()->SendPacketBurst (pb);
}
开发者ID:alongxxx,项目名称:QFS-algorithm,代码行数:67,代码来源:dl-my-algo-packet-scheduler2.cpp


注:本文中的Packet::Copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。