コード例 #1
0
ファイル: Packet.cpp プロジェクト: Linyes/lte_sim
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;
}
コード例 #2
0
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;
}