Exemple #1
0
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);
}
Exemple #2
0
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);
    }
}
Exemple #3
0
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;
}
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;
}