Exemplo n.º 1
0
void
AmRlcEntity::SendArqRlcIdealControlMessage (ArqRlcIdealControlMessage msg)
{
#ifdef RLC_DEBUG
  std::cout << "AM RLC -- SendArqRlcIdealControlMessage, node " << GetRadioBearerInstance ()->GetDestination ()->GetIDNetworkNode () << " bearer "<<  GetRlcEntityIndex () << std::endl;
  std::cout << "\t ack " << msg.GetAck() << ", startB " << msg.GetStartByte () << ", endB " << msg.GetEndByte () << std::endl;
#endif

  //send AM RLC ACK to the receiver RLC under ideal control channel
  RadioBearerSink* thisBearer = (RadioBearerSink*) GetRadioBearerInstance ();
  ApplicationSink *thisApplication = (ApplicationSink*) thisBearer->GetApplication ();
  RadioBearer* remoteBearer = thisApplication->GetSourceApplication ()->GetRadioBearer ();

  AmRlcEntity* remoteRlc = (AmRlcEntity*) remoteBearer->GetRlcEntity();
  remoteRlc->ReceiveArqRlcIdealControlMessage (msg);
}
Exemplo 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);
	     }
    }

}