本文整理汇总了C++中Packet::AddHeaderSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::AddHeaderSize方法的具体用法?C++ Packet::AddHeaderSize怎么用?C++ Packet::AddHeaderSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet::AddHeaderSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
PacketBurst*
AmRlcEntity::TransmissionProcedure (int availableBytes)
{
#ifdef RLC_DEBUG
std::cout << "AM RLC tx procedure for node " << GetRadioBearerInstance ()->GetSource ()->GetIDNetworkNode ()<< " bearer "<< GetRlcEntityIndex () << std::endl;
#endif
PacketBurst* pb = new PacketBurst ();
AmStateVariables* amRlcState = GetAmStateVariables ();
//STEP 1 CHECK FOR RE-TRANSMISSION
#ifdef RLC_DEBUG
std::cout << "--> STEP 1: CHECK FOR RE-TRANSMISSION" << std::endl;
PrintSentAMDs ();
#endif
int nbSentAMDs = GetSentAMDs()->size();
if (nbSentAMDs != 0)
{
int amdId = 0;
while (availableBytes > 0 && amdId < nbSentAMDs)
{
AmdRecord* amdRecord = GetSentAMDs()->at (amdId);
if (amdRecord->m_packet->GetSize () + 6 <= availableBytes) //6 = MAC + CRC overhead
{
amdRecord->m_retx_count++;
#ifdef RLC_DEBUG
std::cout << "send the whole unacknowledged AMD PDU" << std::endl;
#endif
Packet* p = amdRecord->m_packet->Copy ();
MACHeader *mac = new MACHeader (GetRadioBearerInstance ()->GetSource ()->GetIDNetworkNode (),
GetRadioBearerInstance ()->GetDestination ()->GetIDNetworkNode ());
p->AddMACHeader(mac);
p->AddHeaderSize (3);
if (_RLC_TRACING_)
{
std::cout << "TX AM_RLC SIZE" << p->GetSize () <<
" B " << GetRlcEntityIndex () <<
" PDU_SN " << p->GetRLCHeader ()->GetRlcPduSequenceNumber() << std::endl;
}
pb->AddPacket (p);
availableBytes -= p->GetSize ();
amdId++;
}
else if (availableBytes > 8) // 8 = RLC + MAC + CRC
{
amdRecord->m_retx_count++;
#ifdef RLC_DEBUG
std::cout << "there is not enough bandwidth for this AMD PDU. Do another fragmentation"
<< "--> bytes: " << availableBytes << std::endl;
#endif
Packet* p1 = amdRecord->m_packet->Copy ();
Packet* p2 = amdRecord->m_packet;
int sentBytes = availableBytes - 7;
p1->GetRLCHeader ()->SetEndByte (p1->GetRLCHeader ()->GetStartByte () + sentBytes - 1);
p1->SetSize (2 + sentBytes); //consider both RLC and sent bytes
p2->GetRLCHeader ()->SetStartByte (p1->GetRLCHeader ()->GetStartByte () + sentBytes);
p2->SetSize (p2->GetSize () - sentBytes); //decrease the packet size by the quota of sent bytes
p1->GetRLCHeader ()->SetTheLatestFragment (false);
p1->GetRLCHeader ()->SetAFragment (true);
p2->GetRLCHeader ()->SetAFragment (true);
MACHeader *mac = new MACHeader (GetRadioBearerInstance ()->GetSource ()->GetIDNetworkNode (),
GetRadioBearerInstance ()->GetDestination ()->GetIDNetworkNode ());
p1->AddMACHeader(mac);
p1->AddHeaderSize (3); //CRC
if (_RLC_TRACING_)
{
std::cout << "TX AM_RLC SIZE" << p1->GetSize () <<
" B " << GetRlcEntityIndex () <<
" PDU_SN " << p1->GetRLCHeader ()->GetRlcPduSequenceNumber() << std::endl;
}
pb->AddPacket (p1->Copy ());
AmdRecord* newAmdRecord = new AmdRecord (p1, p1->GetRLCHeader ()->GetRlcPduSequenceNumber ());
newAmdRecord->m_retx_count = amdRecord->m_retx_count;
GetSentAMDs ()->insert(GetSentAMDs ()->begin() + amdId, newAmdRecord);
#ifdef RLC_DEBUG
PrintSentAMDs ();
#endif
availableBytes = 0;
}
else
{
availableBytes = 0;
}
}
}
//.........这里部分代码省略.........
示例2: if
PacketBurst*
UmRlcEntity::TransmissionProcedure (int availableBytes)
{
#ifdef RLC_DEBUG
std::cout << "UM RLC tx procedure for node " << GetRadioBearerInstance ()->GetSource ()->GetIDNetworkNode ()<< std::endl;
#endif
PacketBurst* pb = new PacketBurst ();
RadioBearer *bearer = (RadioBearer*) GetRadioBearerInstance ();
MacQueue *queue = bearer->GetMacQueue ();
if (bearer->GetApplication ()->GetApplicationType () == Application::APPLICATION_TYPE_INFINITE_BUFFER)
{
//CREATE PACKET FOR THE INFINITE BUFFER SOURCE
while (true)
{
Packet *packet = bearer->CreatePacket (availableBytes);
//Set the id of the receiver RLC entity
packet->GetRLCHeader ()->SetRlcEntityIndex (GetRlcEntityIndex ());
packet->GetRLCHeader ()->SetRlcPduSequenceNumber (GetRlcPduSequenceNumber ());
int newSequenceNumber = GetRlcPduSequenceNumber () + 1;
SetRlcPduSequenceNumber (newSequenceNumber);
//Add MAC header
MACHeader *mac = new MACHeader (GetRadioBearerInstance ()->GetSource ()->GetIDNetworkNode (),
GetRadioBearerInstance ()->GetDestination ()->GetIDNetworkNode ());
packet->AddMACHeader(mac);
packet->AddHeaderSize (3); //CRC
if (availableBytes > 1503)
{
packet->SetSize (1503);
packet->GetPacketTags ()->SetApplicationSize (1490);
//Set the id of the receiver RLC entity
packet->GetRLCHeader ()->SetRlcEntityIndex (GetRlcEntityIndex ());
packet->GetRLCHeader ()->SetRlcPduSequenceNumber (GetRlcPduSequenceNumber ());
int newSequenceNumber = GetRlcPduSequenceNumber () + 1;
SetRlcPduSequenceNumber (newSequenceNumber);
availableBytes -= 1503;
pb->AddPacket (packet);
if (_RLC_TRACING_)
{
std::cout << "TX UM_RLC SIZE" << packet->GetSize () <<
" B " << GetRlcEntityIndex () <<
" PDU_SN " << packet->GetRLCHeader ()->GetRlcPduSequenceNumber() << std::endl;
}
}
else if (availableBytes > 13)
{
packet->SetSize (availableBytes);
packet->GetPacketTags ()->SetApplicationSize (availableBytes - 13);
//Set the id of the receiver RLC entity
packet->GetRLCHeader ()->SetRlcEntityIndex (GetRlcEntityIndex ());
packet->GetRLCHeader ()->SetRlcPduSequenceNumber (GetRlcPduSequenceNumber ());
int newSequenceNumber = GetRlcPduSequenceNumber () + 1;
SetRlcPduSequenceNumber (newSequenceNumber);
availableBytes = 0;
pb->AddPacket (packet);
if (_RLC_TRACING_)
{
std::cout << "TX UM_RLC SIZE" << packet->GetSize () <<
" B " << GetRlcEntityIndex () <<
" PDU_SN " << packet->GetRLCHeader ()->GetRlcPduSequenceNumber() << std::endl;
}
break;
}
else
{
availableBytes = 0;
break;
}
}
}
else
{
while (availableBytes > 0 && !queue->IsEmpty ())
{
Packet* packet = queue->GetPacketToTramsit (availableBytes);
if (packet != NULL)
{
//Set the id of the receiver RLC entity
packet->GetRLCHeader ()->SetRlcEntityIndex (GetRlcEntityIndex ());
packet->GetRLCHeader ()->SetRlcPduSequenceNumber (GetRlcPduSequenceNumber ());
int newSequenceNumber = GetRlcPduSequenceNumber () + 1;
SetRlcPduSequenceNumber (newSequenceNumber);
if (_RLC_TRACING_)
{
std::cout << "TX UM_RLC SIZE" << packet->GetSize () <<
" B " << GetRlcEntityIndex () <<
" PDU_SN " << packet->GetRLCHeader ()->GetRlcPduSequenceNumber() << std::endl;
//.........这里部分代码省略.........