2/22号完成:
(1)更新resetNprachMapping,计算nprachGapSlots和nprachSlots,分别为NPRACH Gap及NPRACH占用hsfn-sfn-slot列表;
(2)增加incSlot,用于递增n个ul slot;(修正一处incSubf bug)
(3)实现了sendNpuschFormat2。
其中incSlot定义如下:
def incSlot(hsfn, sfn, slot, n, slotPerRf):
if n <= 0:
return (hsfn, sfn, slot)
slot = slot + n
if slot >= slotPerRf:
hsfn, sfn = incSfn(hsfn, sfn, slot // slotPerRf)
slot = slot % slotPerRf
return (hsfn, sfn, slot)
sendNpuschFormat2实现了NPUSCH Format 2发送逻辑(npusch与nprach slot重叠及npusch gap)
def sendNpuschFormat2(self, hsfn, sfn, subf):
self.ngwin.logEdit.append('<font color=purple>sendNpuschFormat2 with N=%d, sc=%d, k0=%d @ [HSFN=%d,SFN=%d,SUBF=%d]</font>' % (self.args['npuschFormat2NumRep']*4, self.args['npuschFormat2Sc'], self.args['npuschFormat2K0'], hsfn, sfn, subf))
oldHsfn, oldSfn = hsfn, sfn
oldKey = str(hsfn)+'_'+str(sfn)
#36.213 16.4.2 UE procedure for reporting ACK/NACK
#The UE shall upon detection of a NPDSCH transmission ending in NB-IoT subframe n intended for the UE and for which an ACK/NACK shall be provided, start, at the end of n+k0-1 DL subframe transmission of the NPUSCH carrying ACK/NACK response using NPUSCH format 2 in N consecutive NB-IoT UL slots.
N = self.args['npuschFormat2NumRep'] * 4 #36.211 Table 10.1.2.3-1
k0 = self.args['npuschFormat2K0']
hsfn, sfn, subf = incSubf(hsfn, sfn, subf, k0-1)
newKey = str(hsfn)+'_'+str(sfn)
while oldKey != newKey:
oldHsfn, oldSfn = incSfn(oldHsfn, oldSfn, 1)
oldKey = str(oldHsfn) + '_' + str(oldSfn)
self.normalOps(oldHsfn, oldSfn)
if self.args['nbUlScSpacing'] == NbiotPhy.NBIOT_UL_3DOT75K.value:
if subf / self.slotDurNbUl > self.slotPerRfNbUl - 1:
hsfn, sfn = incSfn(hsfn, sfn)
slot = 0
else:
slot = math.floor(subf / self.slotDurNbUl)
else:
slot = math.floor(subf / self.slotDurNbUl)
self.npuschFmt2Map.clear()
self.npuschGap.clear()
npuschGapTh = math.floor(256 / self.slotDurNbUl) #slot number for 256ms
npuschGapDur = math.floor(40 / self.slotDurNbUl) #slot number for 40ms
slotMapped = 0
slotTotal = 0
slotRaPostponed = 0
self.npuschPostponed = False
while slotMapped < N:
if slotTotal > 0 and slotTotal % npuschGapTh == 0: #after 256ms, a 40ms npusch gap is inserted
self.ngwin.logEdit.append('<font color=red>NPUSCH gap [N=%d,slotMapped=%d,slotRaPostponed=%d,slotTotal=%d] @ [HSFN=%d,SFN=%d,SLOT=%d]</font>' % (N, slotMapped, slotRaPostponed, slotTotal, hsfn, sfn, slot))
#36.211 10.1.3.6 Mapping to physical resources
#The portion of a postponement due to NPRACH which coincides with a (NPUSCH) gap is counted as part of the gap.
slotActGap = npuschGapDur - slotRaPostponed
for i in range(slotActGap):
hsfn, sfn, slot = incSlot(hsfn, sfn, slot, 1, self.slotPerRfNbUl)
newKey = str(hsfn)+'_'+str(sfn)
if newKey != oldKey:
self.normalOps(hsfn, sfn)
oldKey = newKey
if newKey in self.npuschGap:
self.npuschGap[newKey].append(slot)
else:
self.npuschGap[newKey] = [slot]
#reset slotRaPostponed
slotRaPostponed = 0
hsfn, sfn, slot = incSlot(hsfn, sfn, slot, 1, self.slotPerRfNbUl)
newKey = str(hsfn)+'_'+str(sfn)
if newKey != oldKey:
self.normalOps(hsfn, sfn)
oldKey = newKey
if self.validateNpuschSlot(hsfn, sfn, slot):
for i in range(self.nSlots):
hsfn, sfn, slot = incSlot(hsfn, sfn, slot, i, self.slotPerRfNbUl)
newKey = str(hsfn)+'_'+str(sfn)
if newKey != oldKey:
self.normalOps(hsfn, sfn)
oldKey = newKey
self.fillNpuschFormat2(hsfn, sfn, slot)
#keep track of npuschFmt2Map
key = str(hsfn) + '_' + str(sfn)
if key in self.npuschFmt2Map:
self.npuschFmt2Map[key].append(slot)
else:
self.npuschFmt2Map[key] = [slot]
slotMapped = slotMapped + self.nSlots
slotTotal = slotTotal + self.nSlots
self.npuschPostponed = False
#reset slotRaPostponed
slotRaPostponed = 0
else:
slotRaPostponed = slotRaPostponed + 1
slotTotal = slotTotal + 1
self.npuschPostponed = True
self.ngwin.logEdit.append('contents of self.npuschFmt2Map:')
for key, val in self.npuschFmt2Map.items():
self.ngwin.logEdit.append('-->[NPUSCH FORMAT 2]key=%s,val=%s' % (key, val))
if len(self.npuschGap) > 0:
self.ngwin.logEdit.append('<font color=red>contents of self.npuschGap:</font>')
for key, val in self.npuschGap.items():
self.ngwin.logEdit.append('<font color=red>-->[NPUSCH GAP]key=%s,val=%s</font>' % (key, val))
#make return tuple
allKeys = list(self.npuschFmt2Map.keys())
retHsfn, retSfn = list(map(int, allKeys[-1].split('_')))
retSubf = math.floor((self.npuschFmt2Map[allKeys[-1]][-1] + 1) * self.slotDurNbUl)
if retSubf == self.subfPerRfNbDl:
retSubf = 0
retHsfn, retSfn = incSfn(retHsfn, retSfn, 1)
return (retHsfn, retSfn, retSubf)
validateNpuschSlot用于校验UL slot是否与NPRACH重叠。
采用缺省参数时,输出如下:
[2018-02-22 21:13:23] ***nb-iot grid generation started!***
CCE statistics:
-->CCE number in subframe 0 = 21
-->CCE number in subframe 1 = 21
-->CCE number in subframe 2 = 21
-->CCE number in subframe 3 = 21
-->CCE number in subframe 4 = 21
-->CCE number in subframe 5 = 21
-->CCE number in subframe 6 = 21
-->CCE number in subframe 7 = 21
-->CCE number in subframe 8 = 21
-->CCE number in subframe 9 = 21
Max PUCCH allocation info:
-->max PUCCH region in subframe 0: 4
-->max PUCCH region in subframe 1: 4
-->max PUCCH region in subframe 2: 4
-->max PUCCH region in subframe 3: 4
-->max PUCCH region in subframe 4: 4
-->max PUCCH region in subframe 5: 4
-->max PUCCH region in subframe 6: 4
-->max PUCCH region in subframe 7: 4
-->max PUCCH region in subframe 8: 4
-->max PUCCH region in subframe 9: 4
###以上为调用NgLteGrid的输出
NPRACH frequency locations (nInit=2):
-->NPRACH repetition #0: [2,3,9,8]
monitorNpdcch @ [HSFN=0,SFN=0]
call resetNpdcchUssMap with T=4, R=1, k0=0, b=0 @ [HSFN=0,SFN=0]
key=0_0,val=[1]
normalOps @ [HSFN=0,SFN=0]
nprach start slot=[0_0_16], end slot=[0_1_7]
contents of self.nprachSlots:
-->[NPRACH]key=0_0,val=[16, 17, 18, 19]
-->[NPRACH]key=0_1,val=[0, 1, 2, 3, 4, 5, 6, 7]
sendingNprach=True @ [HSFN=0,SFN=0]
###上行NPRACH资源
recving NPDCCH @ [HSFN=0,SFN=0]
###下行接收NPDCCH DCI N1
recvNpdschWoBcch with N=1, k0=0 @ [HSFN=0,SFN=0,SUBF=1]
key=0_0,val=[7]
recving NPDSCH w/o BCCH @ [HSFN=0,SFN=0]
###下行接收NPDSCH without BCCH
sendNpuschFormat2 with N=4, sc=0, k0=13 @ [HSFN=0,SFN=0,SUBF=7]
normalOps @ [HSFN=0,SFN=1]
sendingNprach=False @ [HSFN=0,SFN=1]
normalOps @ [HSFN=0,SFN=2]
contents of self.npuschFmt2Map:
-->[NPUSCH FORMAT 2]key=0_1,val=[19]
-->[NPUSCH FORMAT 2]key=0_2,val=[0, 1, 2]
###上行发送NPUSCH format 2(HARQ-ACK feedback)
monitorNpdcch @ [HSFN=0,SFN=3]
call resetNpdcchUssMap with T=4, R=1, k0=2, b=0 @ [HSFN=0,SFN=3]
key=0_3,val=[3]
normalOps @ [HSFN=0,SFN=3]
recving NPDCCH @ [HSFN=0,SFN=3]
[2018-02-22 21:13:25] ***nb-iot grid generation finished!***
如果UI配置参数为(nbiot ul tab,npusch format 2/ACK-NACK-numRepetitions-NB-r13=r128,nprach/numRepetitionsPerPreambleAttempt-r13=r8),NPUSCH format 2部分输出为:
contents of self.npuschFmt2Map:
-->[NPUSCH FORMAT 2]key=0_5,val=[12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_6,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_7,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_8,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
-->[NPUSCH FORMAT 2]key=0_13,val=[12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_14,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_15,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_16,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
-->[NPUSCH FORMAT 2]key=0_21,val=[12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_22,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_23,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_24,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
-->[NPUSCH FORMAT 2]key=0_29,val=[12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_30,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_31,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_32,val=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
-->[NPUSCH FORMAT 2]key=0_37,val=[12, 13, 14, 15, 16, 17, 18, 19]
-->[NPUSCH FORMAT 2]key=0_38,val&#