Ejemplo n.º 1
0
void
Application::Start ()
{
#ifdef TEST_START_APPLICATION
  std::cout << "Start Application: src: " << GetSource ()->GetIDNetworkNode ()
		  << " dst: " << GetDestination ()->GetIDNetworkNode () << std::endl;
#endif

  // 1 - create radio bearer
  m_radioBearer = new RadioBearer ();
  //std::cout<<"RB"<<std::endl;//memorytest
  m_radioBearer->GetRlcEntity ()->SetRlcEntityIndex (GetApplicationID ());


  if (GetSource ()->GetNodeType() == NetworkNode::TYPE_UE)
    {
	  //create an UL radio bearer between UE and targetENB
	  UserEquipment* ue = (UserEquipment*) GetSource ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);

#ifdef TEST_START_APPLICATION
      std::cout << "Create UL radio bearer bewtween: " << GetSource ()->GetIDNetworkNode ()
		  << " and " << ue->GetTargetNode ()->GetIDNetworkNode () << std::endl;
#endif

	  m_radioBearer->SetSource (ue);
	  m_radioBearer->SetDestination (ue->GetTargetNode ());
	  m_radioBearer->SetClassifierParameters (GetClassifierParameters ());
	  m_radioBearer->SetApplication (this);
	  m_radioBearer->SetQoSParameters (GetQoSParameters ());
    }
  else if (GetSource ()->GetNodeType() == NetworkNode::TYPE_GW
		  ||
		  GetSource ()->GetNodeType() == NetworkNode::TYPE_ENODEB
		  ||
		  GetSource ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION)
    {
	  //create an DL radio bearer between targetENB and UE
	  UserEquipment* ue = (UserEquipment*) GetDestination ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);

#ifdef TEST_START_APPLICATION
      std::cout << "Create DL radio bearer bewtween: " << ue->GetTargetNode ()->GetIDNetworkNode ()
    		  << " and " << ue->GetIDNetworkNode ()  << std::endl;
#endif

	  m_radioBearer->SetSource (ue->GetTargetNode ());
	  m_radioBearer->SetDestination (ue);
	  m_radioBearer->SetClassifierParameters (GetClassifierParameters ());
	  m_radioBearer->SetApplication (this);
	  m_radioBearer->SetQoSParameters (GetQoSParameters ());
    }

  m_radioBearer->GetSource ()->GetProtocolStack ()->GetRrcEntity ()->AddRadioBearer (m_radioBearer);


  // 2 - create application sink
  m_applicationSink = new ApplicationSink ();
  //std::cout<<"AS"<<std::endl;//memorytest
  m_applicationSink->SetClassifierParameters (GetClassifierParameters ());
  m_applicationSink->SetSourceApplication (this);


  // 3 - create radio bearer sink
  m_bearerSink = new RadioBearerSink ();
  //std::cout<<"RBS"<<std::endl;//memorytest
  m_bearerSink->GetRlcEntity ()->SetRlcEntityIndex (GetApplicationID ());
  m_bearerSink->SetApplication (m_applicationSink);
  m_bearerSink->SetClassifierParameters (GetClassifierParameters ());
  m_bearerSink->SetQoSParameters (GetQoSParameters ());
  if (GetSource ()->GetNodeType() == NetworkNode::TYPE_UE)
    {
	  UserEquipment* ue = (UserEquipment*) GetSource ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);
	  m_bearerSink->SetSource (ue);
	  m_bearerSink->SetDestination (ue->GetTargetNode ());
    }
  else if (GetSource ()->GetNodeType() == NetworkNode::TYPE_GW || GetSource ()->GetNodeType() == NetworkNode::TYPE_ENODEB
		  || GetSource ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION)
    {
	  UserEquipment* ue = (UserEquipment*) GetDestination ();
	  ue->SetNodeState (NetworkNode::STATE_ACTIVE);
	  m_bearerSink->SetSource (ue->GetTargetNode ());
	  m_bearerSink->SetDestination (ue);
    }


  // 4 - add in radio bearer a pointer to the radio bearer sink
  m_radioBearer->GetDestination() ->GetProtocolStack ()->GetRrcEntity ()->AddRadioBearerSink(m_bearerSink);
  m_applicationSink->SetRadioBearerSink (m_bearerSink);


  // 4 attach UE on the UL or DL channel
  if (GetSource ()->GetNodeType() == NetworkNode::TYPE_UE)
    {
	  UserEquipment* ue = (UserEquipment*) GetSource ();
/*mouan
	  LteChannel *ch = ue->GetTargetNode ()->GetPhy ()->GetUlChannel ();

	  if (!ch->IsAttached (ue))
	    {
		  ch->AddDevice (ue);
	    }
mouan end*/

	  ue->MakeActive ();
    }
  else if (GetSource ()->GetNodeType() == NetworkNode::TYPE_GW || GetSource ()->GetNodeType() == NetworkNode::TYPE_ENODEB
		  || GetSource ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION)
    {
	  UserEquipment* ue = (UserEquipment*) GetDestination ();
	  LteChannel *ch = ue->GetTargetNode ()->GetPhy ()->GetDlChannel ();

	  if (!ch->IsAttached (ue))
	    {
		  ch->AddDevice (ue);
	    }

	  ue->MakeActive ();
    }

#ifdef TEST_START_APPLICATION
  std::cout << "CREATED RADIO BEARER " << m_radioBearer->GetApplication ()->GetApplicationID ()
		  << " BETWEEN "
		  << m_radioBearer->GetSource ()->GetIDNetworkNode () << " and "
		  << m_radioBearer->GetDestination () ->GetIDNetworkNode ()<< std::endl;
#endif

  DoStart ();
}
Ejemplo n.º 2
0
void
NetworkManager::TransferBearerInfo (UserEquipment* ue, NetworkNode* target)
{
#ifdef HANDOVER_DEBUG
              std::cout << "** HO ** \t TransferBearerInfo for user "
            		  <<  ue->GetIDNetworkNode () << std::endl;
#endif

  if ( (target->GetNodeType() == NetworkNode::TYPE_ENODEB && ue->GetTargetNode ()->GetNodeType() == NetworkNode::TYPE_ENODEB) ||
		 (target->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION && ue->GetTargetNode ()->GetNodeType() == NetworkNode::TYPE_ENODEB) ||
		 (target->GetNodeType() == NetworkNode::TYPE_ENODEB && ue->GetTargetNode ()->GetNodeType() == NetworkNode::TYPE_HOME_BASE_STATION))
    {
	   ENodeB *oldTargetNode = (ENodeB*) ue->GetTargetNode ();
	   ENodeB *newTargetNode = (ENodeB*) target;

	   // 1 - update spectrum, channels and propagation loss model
#ifdef HANDOVER_DEBUG
	   std::cout << "update spectrum, channels and propagation loss model"<< std::endl;
#endif
	   ue->GetPhy ()->SetBandwidthManager (newTargetNode->GetPhy ()->GetBandwidthManager ());

	   LteChannel *oldDl = oldTargetNode->GetPhy ()->GetDlChannel ();
	   LteChannel *oldUl = oldTargetNode->GetPhy ()->GetUlChannel ();
	   LteChannel *newDl = newTargetNode->GetPhy ()->GetDlChannel ();
	   LteChannel *newUl = newTargetNode->GetPhy ()->GetUlChannel ();

	   ue->GetPhy ()->SetDlChannel (newDl);
	   if (oldDl->IsAttached (ue))
	     {
		   newDl->AddDevice (ue);
           oldDl->DelDevice (ue);
	     }
	   if (newDl->GetPropagationLossModel () != NULL)
	     {
		   newDl->GetPropagationLossModel ()->
				   AddChannelRealization (CreateChannelRealization (newTargetNode, ue));

		   oldDl->GetPropagationLossModel ()->DelChannelRealization (oldTargetNode,ue);

	     }

	   ue->GetPhy ()->SetUlChannel (newUl);
	   if (oldUl->IsAttached (ue))
	     {
		   newUl->AddDevice (ue);
           oldUl->DelDevice (ue);
	     }
	   if (newUl->GetPropagationLossModel () != NULL)
	     {
		   newUl->GetPropagationLossModel ()->AddChannelRealization (
				   CreateChannelRealization (ue, newTargetNode));

		   oldUl->GetPropagationLossModel ()->DelChannelRealization (ue,oldTargetNode);;
	     }


	   // 2 - add ue record to the new Enb
#ifdef HANDOVER_DEBUG
	   std::cout << "add ue record to the new Enb"<< std::endl;
#endif
       newTargetNode->RegisterUserEquipment (ue);

	   // 3 - delete ue record form the old enb
#ifdef HANDOVER_DEBUG
       std::cout << "delete ue record form the old enb"<< std::endl;
#endif
       oldTargetNode->DeleteUserEquipment (ue);

	   // 4 - update cell and new target enb for the ue
#ifdef HANDOVER_DEBUG
       std::cout << "update cell and new target enb for the ue"<< std::endl;
#endif
	   ue->SetTargetNode (newTargetNode);

	   // MOVE RRC CONTEXT FOR THE OLD TARGET NODE TO THE NEWER ONE
#ifdef HANDOVER_DEBUG
	   std::cout << "MOVE RRC CONTEXT"<< std::endl;
#endif
	   RrcEntity * oldEnbRrc = oldTargetNode->GetProtocolStack ()->GetRrcEntity ();
	   RrcEntity * newEnbRrc = newTargetNode->GetProtocolStack ()->GetRrcEntity ();
	   RrcEntity * ueRrc = ue->GetProtocolStack  ()->GetRrcEntity ();


	   // --> move dl bearers
#ifdef HANDOVER_DEBUG
	   std::cout << "\t DL radio bearers " << oldEnbRrc->GetRadioBearerContainer ()->size () << std::endl;
#endif
	   std::vector<RadioBearer* > *dlBearerToDelete = new std::vector<RadioBearer* > ();
	   for (std::vector<RadioBearer* >::iterator it = oldEnbRrc->GetRadioBearerContainer ()->begin();
			   it != oldEnbRrc->GetRadioBearerContainer ()->end (); it++)
	     {
		   RadioBearer *bearer = (*it);
		   if (bearer->GetDestination ()->GetIDNetworkNode () == ue->GetIDNetworkNode ())
		     {
			   bearer->SetSource (newTargetNode);
			   bearer->GetRlcEntity ()->SetDevice (newTargetNode);
			   newEnbRrc->AddRadioBearer (bearer);
			   dlBearerToDelete->push_back (bearer);
		     }
	     }
	   for (std::vector<RadioBearer* >::iterator it = dlBearerToDelete->begin();
			   it != dlBearerToDelete->end (); it++)
	     {
		   RadioBearer *bearer = (*it);
		   oldEnbRrc->DelRadioBearer (bearer);
	     }
	   dlBearerToDelete->clear ();
	   delete dlBearerToDelete;



	   // --> move ul bearers
#ifdef HANDOVER_DEBUG
	   std::cout << "\t UL radio bearers"<< std::endl;
#endif
	   std::vector<RadioBearerSink* > *ulBearerToDelete = new std::vector<RadioBearerSink* > ();
	   for (std::vector<RadioBearerSink* >::iterator it = oldEnbRrc->GetRadioBearerSinkContainer ()->begin();
			   it != oldEnbRrc->GetRadioBearerSinkContainer ()->end (); it++)
	     {
		   RadioBearerSink *bearer = (*it);
		   if (bearer->GetSource ()->GetIDNetworkNode () == ue->GetIDNetworkNode ())
		     {
			   bearer->SetDestination (newTargetNode);
			   newEnbRrc->AddRadioBearerSink (bearer);
			   ulBearerToDelete->push_back (bearer);
		     }
	     }
	   for (std::vector<RadioBearerSink* >::iterator it = ulBearerToDelete->begin();
			   it != ulBearerToDelete->end (); it++)
	     {
		   RadioBearerSink *bearer = (*it);
		   oldEnbRrc->DelRadioBearerSink (bearer);
	     }
	   ulBearerToDelete->clear ();
	   delete ulBearerToDelete;


	   // UPDATE THE RRC CONTEXT FOR THE UE
#ifdef HANDOVER_DEBUG
	   std::cout << "\t UE updates DL radio bearers "<< std::endl;
#endif
	   for (std::vector<RadioBearerSink* >::iterator it = ueRrc->GetRadioBearerSinkContainer ()->begin();
			   it != ueRrc->GetRadioBearerSinkContainer ()->end (); it++)
	     {
		   RadioBearerSink *bearer = (*it);
		   bearer->SetSource (newTargetNode);
	     }
#ifdef HANDOVER_DEBUG
	   std::cout << "\t UE updates UL radio bearers "<< std::endl;
#endif
	   for (std::vector<RadioBearer* >::iterator it = ueRrc->GetRadioBearerContainer ()->begin();
			   it != ueRrc->GetRadioBearerContainer ()->end (); it++)
	     {
		   RadioBearer *bearer = (*it);
		   bearer->SetDestination (newTargetNode);
	     }
    }

}