本文整理汇总了C++中Packet::AddIPHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::AddIPHeader方法的具体用法?C++ Packet::AddIPHeader怎么用?C++ Packet::AddIPHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet::AddIPHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Packet
void
WEB::SendPkt (Packet* pRed)
{
if (!m_stateON)
{
m_stateON = true;
//start state ON
int n_packet = Ran.Geometric(300);
arrival = Ran.Geometric(0.4);
// double random = rand() %10000;
m_stateDuration = n_packet * arrival;
m_endState = Simulator::Init()->Now () + m_stateDuration;
#ifdef APPLICATION_DEBUG
std::cout << " WEB_DEBUG - Start ON Period, "
"\n\t Time = " << Simulator::Init()->Now ()
<< "\n\t state ON Duration = " << m_stateDuration
<< "\n\t end ON state = " << m_endState << std::endl;
#endif
}
//CREATE A NEW PACKET (ADDING UDP, IP and PDCP HEADERS)
Packet *packet = pRed->Copy();//new Packet ();
int uid = Simulator::Init()->GetUID ();
packet->SetID(uid);
packet->SetTimeStamp (Simulator::Init()->Now ());
packet->SetSize (GetSize ());
Trace (packet);
PacketTAGs *tags = new PacketTAGs ();
tags->SetApplicationType(PacketTAGs::APPLICATION_TYPE_WEB);
tags->SetApplicationSize (packet->GetSize ());
packet->SetPacketTags(tags);
UDPHeader *udp = new UDPHeader (GetClassifierParameters ()->GetSourcePort (),
GetClassifierParameters ()->GetDestinationPort ());
packet->AddUDPHeader (udp);
IPHeader *ip = new IPHeader (GetClassifierParameters ()->GetSourceID (),
GetClassifierParameters ()->GetDestinationID ());
packet->AddIPHeader (ip);
PDCPHeader *pdcp = new PDCPHeader ();
packet->AddPDCPHeader (pdcp);
GetRadioBearer()->Enqueue (packet);
}
示例2: rand
void
VoIP::Send (void)
{
if (!m_stateON)
{
m_stateON = true;
//start state ON
double random = rand() %10000;
m_stateDuration = -3*log(1-((double)random/10000));
m_endState = Simulator::Init()->Now () + m_stateDuration;
#ifdef APPLICATION_DEBUG
std::cout << " VoIP_DEBUG - Start ON Period, "
"\n\t Time = " << Simulator::Init()->Now ()
<< "\n\t state ON Duration = " << m_stateDuration
<< "\n\t end ON state = " << m_endState << std::endl;
#endif
}
//CREATE A NEW PACKET (ADDING UDP, IP and PDCP HEADERS)
Packet *packet = new Packet ();
int uid = Simulator::Init()->GetUID ();
packet->SetID(uid);
packet->SetTimeStamp (Simulator::Init()->Now ());
packet->SetSize (GetSize ());
Trace (packet);
PacketTAGs *tags = new PacketTAGs ();
tags->SetApplicationType(PacketTAGs::APPLICATION_TYPE_VOIP);
tags->SetApplicationSize (packet->GetSize ());
packet->SetPacketTags(tags);
UDPHeader *udp = new UDPHeader (GetClassifierParameters ()->GetSourcePort (),
GetClassifierParameters ()->GetDestinationPort ());
packet->AddUDPHeader (udp);
IPHeader *ip = new IPHeader (GetClassifierParameters ()->GetSourceID (),
GetClassifierParameters ()->GetDestinationID ());
packet->AddIPHeader (ip);
PDCPHeader *pdcp = new PDCPHeader ();
packet->AddPDCPHeader (pdcp);
GetRadioBearer()->Enqueue (packet);
if (Simulator::Init()->Now () <= m_endState)
{
ScheduleTransmit (0.02);
}
else
{
//schedule OFF Period
m_stateON = false;
double random = rand() %10000;
m_stateDuration = -2.23*log(1-((double)random/10000));
if (m_stateDuration > 6.9)
{
m_stateDuration = 6.9;
}
#ifdef APPLICATION_DEBUG
std::cout << " VoIP_DEBUG - Start OFF Period, "
"\n\t Time = " << Simulator::Init()->Now ()
<< "\n\t state OFF Duration = " << m_stateDuration << std::endl;
#endif
ScheduleTransmit (m_stateDuration);
}
}
示例3: Packet
Packet*
Packet::Copy (void)
{
Packet *p = new Packet ();
p->m_id = m_id;
p->m_timeStamp = m_timeStamp;
if (m_UDPHeader != NULL)
{
UDPHeader *udp = new UDPHeader (GetSourcePort(), GetDestinationPort());
p->AddUDPHeader(udp);
}
if (m_IPHeader != NULL)
{
IPHeader *ip = new IPHeader (GetSourceID(), GetDestinationID());
p->AddIPHeader(ip);
}
if (m_PDCPHeader != NULL)
{
PDCPHeader *pdcp = new PDCPHeader ();
p->AddPDCPHeader (pdcp);
}
if (m_RLCHeader != NULL)
{
RLCHeader *rlc = new RLCHeader ();
if (GetRLCHeader ()->IsAFragment ())
rlc->SetAFragment (true);
if (!GetRLCHeader ()->IsTheLatestFragment ())
rlc->SetTheLatestFragment (false);
rlc->SetFragmentNumber (GetRLCHeader ()->GetFragmentNumber());
rlc->SetRlcEntityIndex (GetRLCHeader ()->GetRlcEntityIndex ());
rlc->SetRlcPduSequenceNumber (GetRLCHeader ()->GetRlcPduSequenceNumber());
rlc->SetStartByte (GetRLCHeader ()->GetStartByte ());
rlc->SetEndByte (GetRLCHeader ()->GetEndByte ());
p->AddRLCHeader (rlc);
}
if (m_MACHeader != NULL)
{
MACHeader *mac = new MACHeader (GetSourceMAC (), GetDestinationMAC ());
p->AddMACHeader(mac);
}
if (m_tags != NULL)
{
PacketTAGs *tags = new PacketTAGs ();
tags->SetApplicationType(GetPacketTags()->GetApplicationType());
tags->SetFrameNumber (GetPacketTags ()->GetFrameNuber ());
tags->SetStartByte (GetPacketTags ()->GetStartByte ());
tags->SetEndByte (GetPacketTags ()->GetEndByte ());
tags->SetApplicationSize (GetPacketTags ()->GetApplicationSize ());
p->SetPacketTags(tags);
}
p->m_size = m_size;
return p;
}
示例4: Packet
Packet*
RadioBearer::CreatePacket (int bytes)
{
Packet *p = new Packet ();
p->SetID(Simulator::Init()->GetUID ());
p->SetTimeStamp(Simulator::Init()->Now ());
UDPHeader *udp = new UDPHeader (GetClassifierParameters ()->GetSourcePort(),
GetClassifierParameters ()->GetDestinationPort ());
p->AddUDPHeader(udp);
IPHeader *ip = new IPHeader (GetClassifierParameters ()->GetSourceID (),
GetClassifierParameters ()->GetDestinationID());
p->AddIPHeader(ip);
PDCPHeader *pdcp = new PDCPHeader ();
p->AddPDCPHeader (pdcp);
RLCHeader *rlc = new RLCHeader ();
p->AddRLCHeader(rlc);
PacketTAGs *tags = new PacketTAGs ();
tags->SetApplicationType(PacketTAGs::APPLICATION_TYPE_INFINITE_BUFFER);
p->SetPacketTags(tags);
if (_APP_TRACING_)
{
/*
* Trace format:
*
* TX APPLICATION_TYPE BEARER_ID SIZE SRC_ID DST_ID TIME
*/
UserEquipment* ue = (UserEquipment*) GetApplication ()->GetDestination ();
std::cout << "TX";
switch (p->GetPacketTags ()->GetApplicationType ())
{
case Application::APPLICATION_TYPE_VOIP:
{
std::cout << " VOIP";
break;
}
case Application::APPLICATION_TYPE_TRACE_BASED:
{
std::cout << " VIDEO";
break;
}
case Application::APPLICATION_TYPE_CBR:
{
std::cout << " CBR";
break;
}
case Application::APPLICATION_TYPE_INFINITE_BUFFER:
{
std::cout << " INF_BUF";
break;
}
default:
{
std::cout << " UNDEFINED";
break;
}
}
if (bytes > 1490) bytes = 1490;
else bytes = bytes - 13;
std::cout << " ID " << p->GetID ()
<< " B " << GetRlcEntity ()->GetRlcEntityIndex ()
<< " SIZE " << bytes
<< " SRC " << GetSource ()->GetIDNetworkNode ()
<< " DST " << GetDestination ()->GetIDNetworkNode ()
<< " T " << Simulator::Init()->Now()
<< " " << ue->IsIndoor () << std::endl;
}
return p;
}