diff --git a/openair2/RRC/LTE/L2_interface.c b/openair2/RRC/LTE/L2_interface.c
index d201732177733f67cc61cfc0ff877d06b21f7c6f..74e735bc85a42e9596e1dbba0488fc8b73b482db 100644
--- a/openair2/RRC/LTE/L2_interface.c
+++ b/openair2/RRC/LTE/L2_interface.c
@@ -279,6 +279,9 @@ mac_rrc_data_ind(
 }
 
 //------------------------------------------------------------------------------
+/*
+* Get RRC status (Connected, Idle...) of UE from RNTI
+*/
 int
 mac_eNB_get_rrc_status(
   const module_id_t Mod_idP,
@@ -287,9 +290,7 @@ mac_eNB_get_rrc_status(
 //------------------------------------------------------------------------------
 {
   struct rrc_eNB_ue_context_s* ue_context_p = NULL;
-  ue_context_p = rrc_eNB_get_ue_context(
-                   RC.rrc[Mod_idP],
-                   rntiP);
+  ue_context_p = rrc_eNB_get_ue_context(RC.rrc[Mod_idP], rntiP);
 
   if (ue_context_p != NULL) {
     return(ue_context_p->ue_context.Status);
diff --git a/openair2/RRC/LTE/rrc_defs.h b/openair2/RRC/LTE/rrc_defs.h
index ae87075489f970602c2e34f0e04492368ef7a97d..3756acc457dba53b718445960e42757acf2a5570 100644
--- a/openair2/RRC/LTE/rrc_defs.h
+++ b/openair2/RRC/LTE/rrc_defs.h
@@ -387,10 +387,10 @@ typedef enum SL_TRIGGER_e {
 #define RRC_TRANSACTION_IDENTIFIER_NUMBER  3
 
 typedef struct {
-  unsigned short transport_block_size;                  /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */
-  unsigned short max_transport_blocks;                  /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */
-  unsigned long  Guaranteed_bit_rate;           /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/
-  unsigned long  Max_bit_rate;                  /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/
+  unsigned short transport_block_size;   /*!< \brief Minimum PDU size in bytes provided by RLC to MAC layer interface */
+  unsigned short max_transport_blocks;   /*!< \brief Maximum PDU size in bytes provided by RLC to MAC layer interface */
+  unsigned long  Guaranteed_bit_rate;    /*!< \brief Guaranteed Bit Rate (average) to be offered by MAC layer scheduling*/
+  unsigned long  Max_bit_rate;           /*!< \brief Maximum Bit Rate that can be offered by MAC layer scheduling*/
   uint8_t  Delay_class;                  /*!< \brief Delay class offered by MAC layer scheduling*/
   uint8_t  Target_bler;                  /*!< \brief Target Average Transport Block Error rate*/
   uint8_t  Lchan_t;                      /*!< \brief Logical Channel Type (BCCH,CCCH,DCCH,DTCH_B,DTCH,MRBCH)*/
@@ -552,7 +552,7 @@ typedef struct eNB_RRC_UE_s {
   CipheringAlgorithm_r12_t                          ciphering_algorithm;
   e_SecurityAlgorithmConfig__integrityProtAlgorithm integrity_algorithm;
 
-  uint8_t                            Status;
+  uint8_t                            Status; // RRC status, type enum UE_STATE_t
   rnti_t                             rnti;
   uint64_t                           random_ue_identity;
 
@@ -599,6 +599,9 @@ typedef struct eNB_RRC_UE_s {
   uint32_t                           ue_release_timer_thres_rrc;
   uint32_t                           ue_reestablishment_timer;
   uint32_t                           ue_reestablishment_timer_thres;
+  /* RRC inactivity timer: on timeout, should release RRC connection for inactivity on all E-RABs */
+  uint32_t                           ue_rrc_inactivity_timer;
+  uint32_t                           ue_rrc_inactivity_timer_thres;     
   uint8_t                            e_rab_release_command_flag;
   int8_t                             reestablishment_xid;
 } eNB_RRC_UE_t;
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index 56d68117c4c8dc22003b2496d66352d3d5fe7a91..54b94f8c35eb488d9fedddef4af7c4df63b6c6d8 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -862,13 +862,13 @@ rrc_eNB_free_UE(
       rnti);
 
     if (EPC_MODE_ENABLED) {
-      if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP,rnti) >= RRC_CONNECTED)) {
-        LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x\n", 
+      if((ue_context_pP->ue_context.ul_failure_timer >= 20000) && (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) {
+        LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 21, radio connection with ue lost\n", 
           enb_mod_idP, 
           rnti);
         
         rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 21); 
-        // send cause 21: connection with ue lost
+        // send cause 21: radio connection with ue lost
         /* From 3GPP 36300v10 p129 : 19.2.2.2.2 S1 UE Context Release Request (eNB triggered)
          * If the E-UTRAN internal reason is a radio link failure detected in the eNB, the eNB shall wait a sufficient time before
          *  triggering the S1 UE Context Release Request procedure in order to allow the UE to perform the NAS recovery
@@ -877,7 +877,18 @@ rrc_eNB_free_UE(
          
         return;
       }
-      // TODO : add here cause ul inactivity
+      
+      if((ue_context_pP->ue_context.ue_rrc_inactivity_timer >= ue_context_pP->ue_context.ue_rrc_inactivity_timer_thres) &&
+        (mac_eNB_get_rrc_status(enb_mod_idP, rnti) >= RRC_CONNECTED)) {
+        LOG_I(RRC, "[eNB %d] S1AP_UE_CONTEXT_RELEASE_REQ sent for RNTI %x, cause 20, user inactivity\n", 
+          enb_mod_idP, 
+          rnti);
+        
+        rrc_eNB_send_S1AP_UE_CONTEXT_RELEASE_REQ(enb_mod_idP, ue_context_pP, S1AP_CAUSE_RADIO_NETWORK, 20); 
+        // send cause 20: user inactivity
+
+        return;
+      }
     }
 
     // add UE info to freeList
@@ -1012,11 +1023,14 @@ void release_UE_in_freeList(module_id_t mod_id)
 }
 
 //-----------------------------------------------------------------------------
+/*
+* Process the rrc connection setup complete message from UE (SRB1 Active)
+*/
 void
 rrc_eNB_process_RRCConnectionSetupComplete(
-  const protocol_ctxt_t* const ctxt_pP,
-  rrc_eNB_ue_context_t*         ue_context_pP,
-  RRCConnectionSetupComplete_r8_IEs_t * rrcConnectionSetupComplete
+  const protocol_ctxt_t *const ctxt_pP,
+  rrc_eNB_ue_context_t *ue_context_pP,
+  RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete
 )
 //-----------------------------------------------------------------------------
 {
@@ -1024,22 +1038,19 @@ rrc_eNB_process_RRCConnectionSetupComplete(
         PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing RRCConnectionSetupComplete from UE (SRB1 Active)\n",
         PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
 
-  ue_context_pP->ue_context.Srb1.Active=1;  
+  ue_context_pP->ue_context.Srb1.Active = 1;
+  ue_context_pP->ue_context.Status = RRC_CONNECTED;
+  ue_context_pP->ue_context.ue_rrc_inactivity_timer = 1; // set rrc inactivity when UE goes into RRC_CONNECTED
+
   T(T_ENB_RRC_CONNECTION_SETUP_COMPLETE, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->frame),
     T_INT(ctxt_pP->subframe), T_INT(ctxt_pP->rnti));
 
   if (EPC_MODE_ENABLED == 1) {
     // Forward message to S1AP layer
-    rrc_eNB_send_S1AP_NAS_FIRST_REQ(
-      ctxt_pP,
-      ue_context_pP,
-      rrcConnectionSetupComplete);
+    rrc_eNB_send_S1AP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcConnectionSetupComplete);
   } else {
     // RRC loop back (no S1AP), send SecurityModeCommand to UE
-    rrc_eNB_generate_SecurityModeCommand(
-      ctxt_pP,
-      ue_context_pP);
-    // rrc_eNB_generate_UECapabilityEnquiry(enb_mod_idP,frameP,ue_mod_idP);
+    rrc_eNB_generate_SecurityModeCommand(ctxt_pP, ue_context_pP);
   }
 }
 
@@ -5364,6 +5375,11 @@ rrc_eNB_generate_RRCConnectionReconfiguration_handover(
 */
 
 //-----------------------------------------------------------------------------
+/*
+* TODO: * add function description
+*       * add ue_rrc_inactivity_timer set
+*       * format the function correctly
+*/
 void
 rrc_eNB_process_RRCConnectionReconfigurationComplete(
   const protocol_ctxt_t* const ctxt_pP,
@@ -6868,7 +6884,6 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
             ctxt_pP,
             ue_context_p,
             &ul_dcch_msg->message.choice.c1.choice.rrcConnectionSetupComplete.criticalExtensions.choice.c1.choice.rrcConnectionSetupComplete_r8);
-          ue_context_p->ue_context.Status = RRC_CONNECTED;
           LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" UE State = RRC_CONNECTED \n",
                 PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
 	  
@@ -7901,6 +7916,18 @@ rrc_rx_tx(
       } // end if (rrc_release_info.num_UEs > 0)
       pthread_mutex_unlock(&rrc_release_freelist);
 
+      if (ue_context_p->ue_context.ue_rrc_inactivity_timer > 0) {
+        ue_context_p->ue_context.ue_rrc_inactivity_timer++;
+
+        if (ue_context_p->ue_context.ue_rrc_inactivity_timer >= ue_context_p->ue_context.ue_rrc_inactivity_timer_thres) {
+          LOG_I(RRC, "Removing UE %x instance because of rrc_inactivity_timer timeout\n", 
+            ue_context_p->ue_context.rnti);
+          
+          ue_to_be_removed = ue_context_p;
+          break; // break RB_FOREACH
+        }
+      }
+
       if (ue_context_p->ue_context.ue_reestablishment_timer > 0) {
         ue_context_p->ue_context.ue_reestablishment_timer++;
 
@@ -7935,7 +7962,8 @@ rrc_rx_tx(
     } // end RB_FOREACH
 
     if (ue_to_be_removed) {
-      if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) {
+      if ((ue_to_be_removed->ue_context.ul_failure_timer >= 20000) || 
+        (ue_to_be_removed->ue_context.ue_rrc_inactivity_timer >= ue_to_be_removed->ue_context.ue_rrc_inactivity_timer_thres)) {
         ue_to_be_removed->ue_context.ue_release_timer_s1 = 1;
         ue_to_be_removed->ue_context.ue_release_timer_thres_s1 = 100;
         ue_to_be_removed->ue_context.ue_release_timer = 0;
@@ -7947,6 +7975,10 @@ rrc_rx_tx(
       if (ue_to_be_removed->ue_context.ul_failure_timer >= 20000) {
         ue_to_be_removed->ue_context.ul_failure_timer = 0;
       }
+
+      if (ue_to_be_removed->ue_context.ue_rrc_inactivity_timer >= ue_to_be_removed->ue_context.ue_rrc_inactivity_timer_thres) {
+        ue_to_be_removed->ue_context.ue_rrc_inactivity_timer = 0; //reset timer after S1 command UE context release request is sent
+      }
     }
 
 #ifdef RRC_LOCALIZATION