From c2e65b06392922537d42be49be16b747ea476bdc Mon Sep 17 00:00:00 2001
From: matzakos <panagiotis.matzakos@eurecom.fr>
Date: Tue, 19 May 2020 15:08:02 +0200
Subject: [PATCH] Correct pseudo-subheader byte of random ULSCH PDU (phytest)
 to an appropriate value

---
 openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c |  6 +++---
 openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c    | 11 +++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
index c74bc16754d..f7e5737a9f7 100644
--- a/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
+++ b/openair1/PHY/NR_TRANSPORT/nr_ulsch_decoding.c
@@ -714,11 +714,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
   }
 
 #ifdef DEBUG_ULSCH_DECODING
-  LOG_I(PHY, "Decoder output (payload): \n");
-  for (i = 0; i < harq_process->TBS / 8; i++) {
+  LOG_I(PHY, "Decoder output (payload, TBS: %d): \n", harq_process->TBS);
+  for (i = 0; i < harq_process->TBS; i++) {
 	  //harq_process_ul_ue->a[i] = (unsigned char) rand();
 	  //printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
-	  printf("0x%02x",harq_process->b[i]);
+	  printf("%02x",harq_process->b[i]);
   }
 #endif
 
diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
index 769cea37a1d..fc02cb989e9 100644
--- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
+++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c
@@ -193,15 +193,14 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
       if (!IS_SOFTMODEM_NOS1 || !data_existing) {
         //Use zeros for the header bytes in noS1 mode, in order to make sure that the LCID is not valid
         //and block this traffic from being forwarded to the upper layers at the gNB
-        uint16_t payload_offset = 5;
         LOG_D(PHY, "Random data to be tranmsitted: \n");
 
-        //Give the header bytes a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2)
-        //in order to block the random packet at the MAC layer of the receiver
-        for (i = 0; i<payload_offset; i++)
-          harq_process_ul_ue->a[i] = 64;
+        //Give the first byte a dummy value (a value not corresponding to any valid LCID based on 38.321, Table 6.2.1-2)
+        //in order to distinguish the PHY random packets at the MAC layer of the gNB receiver from the normal packets that should
+        //have a valid LCID (nr_process_mac_pdu function)
+          harq_process_ul_ue->a[0] = 0x31;
 
-        for (i = payload_offset; i < harq_process_ul_ue->TBS / 8; i++) {
+        for (i = 1; i < harq_process_ul_ue->TBS / 8; i++) {
           harq_process_ul_ue->a[i] = (unsigned char) rand();
           //printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
         }
-- 
GitLab