PHYenb.cc 18.0 KB
Newer Older
C
x  
calincerchez 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#include "PHYenb.h"
C
calin cerchez 已提交
17
#include "RRC.h"
C
calincerchez 已提交
18
#include "LTEChannelControl.h"
C
x  
calincerchez 已提交
19 20 21

Define_Module(PHYenb);

C
calin cerchez 已提交
22
PHYenb::PHYenb() : PHY() {
C
x  
calincerchez 已提交
23 24
    dlBandwith = 6;
    ulBandwith = 6;
C
calincerchez 已提交
25

C
calin cerchez 已提交
26
    hasBCHPdu = false;
C
calin cerchez 已提交
27 28 29 30 31 32 33 34 35 36

    sfn = 0;
    sf = 0;
    symb = 0;
    slot = 0;

    nRBsc = 12;
    nDLsymb = 7;

    symbPeriod = 1e-3 / nDLsymb;
C
x  
calincerchez 已提交
37 38 39
}

PHYenb::~PHYenb() {
C
calincerchez 已提交
40 41 42 43
    for (unsigned char i = 0; i < nDLsymb * 2; i++) {
        if (dlSubframe[i])
            delete dlSubframe[i];
    }
C
calin cerchez 已提交
44 45

	for (unsigned char l = 0; l < nDLsymb * 2; l++)
C
calin cerchez 已提交
46
		for (unsigned short k = 0; k < nRBsc * nDLrb; k++)
C
calin cerchez 已提交
47 48
			if (dlBuffer[l][k])
				delete dlBuffer[l][k];
C
x  
calincerchez 已提交
49 50 51 52
}

void PHYenb::initialize(int stage) {
    // TODO - Generated method body
C
calin cerchez 已提交
53
	PHY::initialize(stage);
C
x  
calincerchez 已提交
54 55 56 57 58 59 60 61 62 63

    if (stage == 2) {
        cc->setRadioChannel(myRadioRef, PRACH);
        cc->setRadioChannel(myRadioRef, PUSCH);
    }

    if (stage == 4) {
        fsm = cFSM("fsm-PHYenb");
        fsm.setState(IDLE);

C
calincerchez 已提交
64 65 66 67 68 69
        nb = NotificationBoardAccess().get();

        nb->subscribe(this, PARAMRequest);
        nb->subscribe(this, CONFIGRequest);
        nb->subscribe(this, STARTRequest);
        nb->subscribe(this, TXRequest);
C
calin cerchez 已提交
70
        nb->subscribe(this, DLCONFIGRequest);
C
x  
calincerchez 已提交
71 72 73
    }
}

74 75
void PHYenb::handleMessage(cMessage *msg) {
	if (msg->isSelfMessage()) {
C
calincerchez 已提交
76
		if (msg == symbolTimer) {
C
calincerchez 已提交
77 78 79 80 81 82 83 84
            if (symb == 0 && slot % 2 == 0) {
                cleanup();

                SubframeIndication *sfInd = new SubframeIndication();
                sfInd->setSf(sf);
                sfInd->setSfn(sfn);
                nb->fireChangeNotification(SUBFRAMEIndication, sfInd);
                delete sfInd;
C
calincerchez 已提交
85

C
calincerchez 已提交
86 87 88 89 90
                buildSubframe();
            }

            sendSymbol();

C
calin cerchez 已提交
91
            this->cancelEvent(symbolTimer);
C
calincerchez 已提交
92 93
            this->scheduleAt(simTime() + symbPeriod, symbolTimer);

C
calincerchez 已提交
94 95 96 97 98
            symb = (symb + 1) % nDLsymb;
            if (symb == 0) {
                slot = (slot + 1) % 20;
                sf = slot / 2;

C
calin cerchez 已提交
99
                if (sf == 0 && slot == 0)
C
calincerchez 已提交
100
                    sfn++;
C
calincerchez 已提交
101
            }
102 103 104 105
		}
	}
}

C
x  
calincerchez 已提交
106
void PHYenb::handleUpperMessage(cMessage *msg) {
C
calin cerchez 已提交
107
    EV << "LTE-PHYenb: Receiving message with id = " << msg->getKind() << " from upper layer. Buffering the received message.\n";
C
calincerchez 已提交
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
//    LTEControlInfo *ctrl = check_and_cast<LTEControlInfo*>(msg->removeControlInfo());
//    TransportBlock *tb = new TransportBlock();
//    tb->setName(msg->getName());
//    tb->encapsulate(PK(msg));
//    switch(ctrl->getChannel()) {
//        case BCH:
//        	// TODO repetition of MIB + get the tti rest at PHYue
//            tb->setChannelNumber(PBCH);
//            break;
//        case DLSCH0:
//            tb->setChannelNumber(PDSCH0);
//            break;
//        case DLSCH1:
//            tb->setChannelNumber(PDSCH1);
//            break;
//        default:
//            break;
//    }
//    buffer[msg->getKind()] = tb;
C
x  
calincerchez 已提交
127 128
}

C
calin cerchez 已提交
129 130 131 132
void PHYenb::handleRadioMessage(cMessage *msg) {
    PhysicalResourceBlock *prb = check_and_cast<PhysicalResourceBlock*>(msg);
    EV << "LTE-PHYenb: Receiving message from ";

C
calincerchez 已提交
133 134 135 136 137 138 139 140 141 142 143 144
//    if (prb->getChannelNumber() == PRACH) {
//    	EV << "PRACH.\n";
//    	RAPreamble *raPreamble = check_and_cast<RAPreamble*>(prb);
//    	RachIndication *rachInd = new RachIndication();
//    	rachInd->setTti(tti);
//    	rachInd->setPreamblesArraySize(1);
//    	RachPreamble rachPrbl = RachPreamble();
//    	rachPrbl.setPreamble(raPreamble->getRapid());
//    	rachPrbl.setRnti(raPreamble->getRnti());
//    	rachInd->setPreambles(0, rachPrbl);
//    	nb->fireChangeNotification(RACHIndication, rachInd);
//    }
C
x  
calincerchez 已提交
145 146
}

C
calincerchez 已提交
147 148 149 150 151 152 153
void PHYenb::buildSubframe() {
    EV << "LTE-PHYenb: Building downlink subframe for sfn = " << sfn << " and sf = " << (unsigned)sf << ".\n";
	for (unsigned char i = 0; i < nDLsymb * 2; i++) {
		dlSubframe[i] = new PHYSymbol();
		dlSubframe[i]->setResArraySize(nDLrb * nRBsc);
		dlSubframe[i]->setChannelNumber(Downlink);
	}
C
calincerchez 已提交
154

C
calin cerchez 已提交
155
    unsigned short ssOffset = (nDLrb * nRBsc) / 2 - 31;
C
calincerchez 已提交
156
    unsigned char vShift = nCellId % 6;
C
calincerchez 已提交
157 158

    // PSS
C
calincerchez 已提交
159 160
    if ((slot == 0 || slot == 10)) {
    	PHYSymbol *symbol = dlSubframe[nDLsymb - 1];
C
calin cerchez 已提交
161
    	unsigned short k = ssOffset;
C
calincerchez 已提交
162 163
        for (; k < ssOffset + 62; k++) {
            symbol->setRes(k, PSS);
C
calincerchez 已提交
164
        }
C
calincerchez 已提交
165 166
        PSSSignal *pss = new PSSSignal();
        pss->setCellIdInGroup(n2id);
C
calin cerchez 已提交
167
        dlBuffer[nDLsymb - 1][k - 1] = pss;
C
calincerchez 已提交
168 169 170
    }

    // SSS
C
calincerchez 已提交
171 172
    if ((slot == 0 || slot == 10)) {
    	PHYSymbol *symbol = dlSubframe[nDLsymb - 2];
C
calin cerchez 已提交
173
    	unsigned short k = ssOffset;
C
calincerchez 已提交
174 175
        for (; k < ssOffset + 62; k++) {
            symbol->setRes(k, SSS);
C
calincerchez 已提交
176
        }
C
calincerchez 已提交
177 178 179
        SSSSignal *sss = new SSSSignal();
        sss->setCellGroupId(n1id);
        sss->setSf(sf);
C
calin cerchez 已提交
180
        dlBuffer[nDLsymb - 2][k - 1] = sss;
C
calincerchez 已提交
181 182
    }

C
calin cerchez 已提交
183
    // TODO repair RS
C
calincerchez 已提交
184 185 186 187 188 189
    PHYSymbol *symbol1 = dlSubframe[0];
    PHYSymbol *symbol2 = dlSubframe[nDLsymb - 3];
    unsigned char v1 = 0;
    unsigned char v2 = 3;
    unsigned char rsOffset1 = (v1 + vShift) % 6;
    unsigned char rsOffset2 = (v2 + vShift) % 6;
C
calincerchez 已提交
190 191
    unsigned char i = 0;
    for (; i < 2 * nDLrb; i++) {
C
calincerchez 已提交
192 193
    	symbol1->setRes(rsOffset1 + 6 * i, RS);
    	symbol2->setRes(rsOffset2 + 6 * i, RS);
C
calincerchez 已提交
194
    }
C
calincerchez 已提交
195 196 197
    ReferenceSignal *refSig = new ReferenceSignal();
    refSig->setCellId(nCellId);
    refSig->setNcp(ncp);
C
calincerchez 已提交
198 199
    dlBuffer[0][rsOffset1 + 6 * (i - 1)] = refSig->dup();
    dlBuffer[nDLsymb - 3][rsOffset2 + 6 * (i - 1)] = refSig;
C
calincerchez 已提交
200 201

    // PBCH
C
calin cerchez 已提交
202
    if (hasBCHPdu && slot == 1) {
C
calincerchez 已提交
203
        unsigned char pbchOffset = nDLrb * nRBsc / 2 - 36;
C
calin cerchez 已提交
204 205
        for (unsigned char l = 0; l < 4; l++) {
            PHYSymbol *symbol = dlSubframe[nDLsymb + l];
C
calin cerchez 已提交
206
            for (unsigned short k = pbchOffset; k < pbchOffset + 72; k++) {
C
calincerchez 已提交
207 208 209 210
                symbol->setRes(k, PBCH);
            }
        }
    }
C
calin cerchez 已提交
211 212

    // PCFICH
C
calin cerchez 已提交
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
    if (dciBuffer.size() != 0 && cfi != 0) {
		PHYSymbol *symbol = dlSubframe[0];
		unsigned char pcfichOffset = (nRBsc / 2) * (nCellId % (2 * nDLrb));
		unsigned short kLast = 0;
		for (unsigned i = 0; i < 4; i++) {
			unsigned short k = (pcfichOffset + (unsigned)(i * nDLrb / 2) * nRBsc / 2) % (nDLrb * nRBsc);
			REG reg = findExactReg(0, k);
			if (reg) {
				unsigned char kRel = 0;
				for (; kRel < getReNrInReg(0); kRel++) {
					if (!symbol->getRes(reg[kRel].k))	// avoid resource elements assigned for RS
						symbol->setRes(reg[kRel].k, PCFICH);
				}
				kLast = reg[kRel - 1].k;
			} else {
				EV << "LTE-PHYenb: !!! Error in PCFICH, resource element (k,l) does not represent a resource element group !!!\n";
			}
		}
		PCFICHMessage *pcfichMsg = new PCFICHMessage();
		pcfichMsg->setCfi(cfi);
		dlBuffer[0][kLast] = pcfichMsg;
    }

    // PDCCH
    if (dciBuffer.size() != 0 && cfi != 0) {
//    	unsigned char m = 0;
    	unsigned short k = 0;
    	DlConfigRequestDciDlPdu *dciDlPdu = NULL;
    	unsigned char dciSize = 0;

    	while (k < nDLrb * nRBsc && dciBuffer.size() != 0) {
    		unsigned char l = 0;
    		while (l < cfi && dciBuffer.size() != 0) {
				PHYSymbol *symbol = dlSubframe[l];
				REG reg = findExactReg(l, k);

				if (reg && symbol->getRes(k) != PCFICH) {	// TODO PHICH
					// symbol preparation
					unsigned short kLast = 0;
					unsigned char kRel = 0;
					for (; kRel < getReNrInReg(l); kRel++) {
						if (!symbol->getRes(reg[kRel].k))	// avoid resource elements assigned for RS
							symbol->setRes(reg[kRel].k, PDCCH);
					}
					kLast = reg[kRel - 1].k;

					// data transmission
					dciDlPdu = dciBuffer.back();
					if (dciSize == 0) {
						if (dciDlPdu->getType() == DCI_FORMAT_1 || dciDlPdu->getType() == DCI_FORMAT_1A)
							dciSize = 18;
					}
					dciSize--;
					if (dciSize == 0) {
						DCIFormat *dci = new DCIFormat();
					    dci->setRnti(dciDlPdu->getRnti());   // scrambled in CRC
					    dci->setRntiType(dciDlPdu->getRntiType());
					    dci->setFormatFlag(dciDlPdu->getType());
					 	dci->setVrbFlag(dciDlPdu->getVrbFlag());
					 	dci->setRbCoding(dciDlPdu->getRbCoding());
					 	// TODO 2 transport blocks
					 	dci->setMcs(dciDlPdu->getMcs1());
					 	dci->setRv(dciDlPdu->getRv1());
					 	dci->setTpc(dciDlPdu->getTpc());
					 	dlBuffer[l][kLast] = dci;

						dciBuffer.pop_back();
						delete dciDlPdu;
					}
//					m++;
				}
				l++;
    		}
    		k++;
    	}
C
calin cerchez 已提交
288
    }
C
calincerchez 已提交
289 290 291
}

void PHYenb::cleanup() {
C
calin cerchez 已提交
292 293
	cfi = 0;

C
calincerchez 已提交
294
    if (sfn % 4 == 0 && sf == 0) {
C
calin cerchez 已提交
295
    	hasBCHPdu = false;
C
calincerchez 已提交
296
    }
C
calincerchez 已提交
297 298 299 300 301
}

void PHYenb::sendSymbol() {
	PHYSymbol *symbol = dlSubframe[symb + (slot % 2) * nDLsymb];

C
calin cerchez 已提交
302
	for (unsigned short k = 0; k < nRBsc * nDLrb; k++) {
C
calin cerchez 已提交
303 304 305 306
		if (dlBuffer[symb + (slot % 2) * nDLsymb][k]) {
			setData(k, dlBuffer[symb + (slot % 2) * nDLsymb][k]);
			dlBuffer[symb + (slot % 2) * nDLsymb][k] = NULL;
		}
C
calincerchez 已提交
307
	}
C
calincerchez 已提交
308

C
calincerchez 已提交
309 310
	sendToChannel(symbol);
	dlSubframe[symb + (slot % 2) * nDLsymb] = NULL;
C
calincerchez 已提交
311 312
}

C
calin cerchez 已提交
313
void PHYenb::setData(unsigned short k, PHYFrame *frame) {
C
calincerchez 已提交
314
    if (dynamic_cast<LTEChannelControl*>(cc) != NULL) {
C
calin cerchez 已提交
315
        dynamic_cast<LTEChannelControl*>(cc)->setData(k, frame);
C
calincerchez 已提交
316 317 318
    }
}

C
calin cerchez 已提交
319
void PHYenb::stateEntered(int category, const cPolymorphic *details) {
C
calin cerchez 已提交
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
    switch(fsm.getState()) {
        case IDLE: {
            ParamResponse *paramResp = new ParamResponse();
            paramResp->setErrorCode(MsgOk);
            paramResp->setTlvsArraySize(1);
            paramResp->setTlvs(0, createPhyCommandTlv(PhyState, 1, IDLE));
            nb->fireChangeNotification(PARAMResponse, paramResp);
            break;
        }
        case CONFIGURED: {
            if (category == CONFIGRequest) {
            	ConfigRequest *cfgReq = check_and_cast<ConfigRequest*>(details);
            	for (unsigned i = 0; i < cfgReq->getTlvsArraySize(); i++) {
            		if (cfgReq->getTlvs(i).getTag() == SfnSf) {
            			sfn = cfgReq->getTlvs(i).getValue() / 10;
            			sf = cfgReq->getTlvs(i).getValue() % 10;
            		}
                    if (cfgReq->getTlvs(i).getTag() == DlCyclicPrefixType) {
                        ncp = cfgReq->getTlvs(i).getValue() == CTRL_CP_NORMAL ? PHY_CP_NORMAL : PHY_CP_EXTENDED;
                    }
                    if (cfgReq->getTlvs(i).getTag() == TxAntennaPorts) {
                        p = cfgReq->getTlvs(i).getValue();
                    }
                    if (cfgReq->getTlvs(i).getTag() == DlChannelBandwith) {
                        nDLrb = cfgReq->getTlvs(i).getValue();
                    }
                    if (cfgReq->getTlvs(i).getTag() == PhysicalCellId) {
                        nCellId = cfgReq->getTlvs(i).getValue();
                        n1id = nCellId / 3;
                        n2id = nCellId % 3;
                    }
            	}
                ConfigResponse *cfgResp = new ConfigResponse();
                cfgResp->setErrorCode(MsgOk);
                nb->fireChangeNotification(CONFIGResponse, cfgResp);
            }
            break;
        }
        case RUNNING: {
            if (category == STARTRequest) {
            	dlSubframe = new PHYSymbol*[nDLsymb * 2];
            	for (unsigned char i = 0; i < nDLsymb * 2; i++)
            		dlSubframe[i] = NULL;

            	dlBuffer = new PHYFramePtr*[nDLsymb * 2];
            	for (unsigned char l = 0; l < nDLsymb * 2; l++) {
            		dlBuffer[l] = new PHYFramePtr[nRBsc * nDLrb];
            		for (unsigned short k = 0; k < nRBsc * nDLrb; k++)
            			dlBuffer[l][k] = NULL;
            	}

            	configureRegs();

                this->cancelEvent(symbolTimer);
                this->scheduleAt(simTime(), symbolTimer);
            } else if (category == DLCONFIGRequest) {
    			DlConfigRequest *dlCfgReq = check_and_cast<DlConfigRequest*>(details);
    			cfi = dlCfgReq->getNrPdcchSymb();

    		    while (dlCfgReq->getPdusArraySize() != 0) {
    		    	DlConfigRequestPduPtr pdu = dlCfgReq->backPdu();
    		    	EV << "LTE-PHYenb: Received DLCONFIGRequest for PDU with type = " << (unsigned)pdu->getType() << ".\n";

    		    	// DCI request from upper layer
    		    	if (pdu->getType() == DciDlPdu) {
    		    		DlConfigRequestDciDlPdu *dciDlPdu = check_and_cast<DlConfigRequestDciDlPdu*>(pdu);
    		    		dciBuffer.push_back(dciDlPdu);
    		    	} else {
    		    		delete pdu;
    		    	}
    //		    	if (pdu->getType() == BchPdu) {
    //		            hasBCHPdu = true;
    //		            unsigned char pbchOffset = nDLrb * nRBsc / 2 - 36;
    //
    //		            PBCHMessage *frame = new PBCHMessage();
    //		            frame->setCellId(nCellId);
    //		            dlBuffer[nDLsymb + 3][pbchOffset + 71] = frame;
    //		            dlCfgReq[pdu->getPduIndex()] = frame;
    //		        } else if (pdu->getType() == DciDlPdu) {
    ////		    		sendDCIFormat(pdu);
    //		    	} else {
    ////		    		dlCfgReqs[pdu->getPduIndex()] = pdu;
    //		    	}
    		    	dlCfgReq->popPdu();
    		    }
            }
            break;
        }
        default:
            EV << "LTE-PHYenb: Unknown state.\n";
            break;
    }
C
calin cerchez 已提交
412 413 414

	if (fsm.getState() == RUNNING) {
		if (category == DLCONFIGRequest) {
C
calin cerchez 已提交
415

C
calin cerchez 已提交
416
		} else if (category == TXRequest) {
C
calincerchez 已提交
417 418 419
//			TxRequest *txReq = check_and_cast<TxRequest*>(details);
//			for (unsigned i = 0; i < txReq->getPdusArraySize(); i++) {
//				TxRequestPdu pdu = txReq->getPdus(i);
C
calin cerchez 已提交
420 421
//				DlConfigRequests::iterator dlCfgIt = dlCfgReqs.find(pdu.getPduIndex());
//				if (dlCfgIt != dlCfgReqs.end()) {
C
calincerchez 已提交
422
//					for (unsigned j = 0; j < pdu.getMsgKindsArraySize(); j++) {
C
calin cerchez 已提交
423
//						short msgKind = pdu.getMsgKinds(j);
C
calincerchez 已提交
424
//						EV << "LTE-PHYenb: Received TXRequest for PDU with id = " << msgKind << ".\n";
C
calin cerchez 已提交
425
//						txReqs[msgKind] = dlCfgIt->second;
C
calincerchez 已提交
426 427 428
//					}
//				}
//			}
C
calin cerchez 已提交
429 430
		}
	}
C
calin cerchez 已提交
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
//	delete details;

}

void PHYenb::receiveChangeNotification(int category, const cPolymorphic *details) {
    Enter_Method_Silent();

    int oldState = fsm.getState();

    switch(oldState) {
        case IDLE:
            switch(category) {
                case PARAMRequest: {
                    break;
                }
                case CONFIGRequest: {
                    FSM_Goto(fsm, CONFIGURED);
                    break;
                }
                default:
                    EV << "LTE-PHYenb: Received unexpected event.\n";
                    break;
            }
            break;
        case CONFIGURED:
            switch(category) {
                case STARTRequest: {
                    FSM_Goto(fsm, RUNNING);
                    break;
                }
                default:
                    EV << "LTE-PHYenb: Received unexpected event.\n";
                    break;
            }
            break;
        case RUNNING:
            switch(category) {
                case DLCONFIGRequest: {
                    break;
                }
                case TXRequest : {
                    break;
                }
                default:
                    EV << "LTE-PHYenb: Received unexpected event.\n";
                    break;
            }
            break;
        default:
            EV << "LTE-PHYenb: Unknown state.\n";
            break;
    }

//    if (oldState != fsm.getState())
//        EV << "LTE-PHY: PSM-Transition: " << stateName(oldState) << " --> " << stateName(fsm.getState()) << "  (event was: " << eventName(category) << ")\n";
//    else
//        EV << "LTE-PHY: Staying in state: " << stateName(fsm.getState()) << " (event was: " << eventName(category) << ")\n";

    stateEntered(category, details);
C
x  
calincerchez 已提交
490 491
}

C
calin cerchez 已提交
492 493 494
void PHYenb::sendBufferedData() {
	unsigned short rnti = 0;

C
calincerchez 已提交
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
//	DlConfigRequests::iterator dlCfgReqsIt = dlCfgReqs.find(tti);
//	if (dlCfgReqsIt != dlCfgReqs.end()) {	// first check downlink configuration requests
//		EV << "LTE-PHYenb: Found DLConfigRequest for tti = " << tti << ".\n";
//
//		while(!dlCfgReqsIt->second.empty()) {
//			DlConfigRequestPduPtr dlCfgReqPdu = dlCfgReqsIt->second.front();
//
//			// find rnti to add to transport block
//			if (dlCfgReqPdu->getType() == DlschPdu) {
//				DlConfigRequestDlschPdu *dlCfgReqDlschPdu = check_and_cast<DlConfigRequestDlschPdu*>(dlCfgReqPdu);
//				rnti = dlCfgReqDlschPdu->getRnti();
//			}
//
//			dlCfgReqsIt->second.pop_front();
//			TxRequests::iterator txReqsIt = txReqs.find(dlCfgReqPdu->getPduIndex());
//			if (txReqsIt != txReqs.end()) {	// second check transmission requests
//				EV << "LTE-PHYenb: Found TxRequest for pduIndex = " << dlCfgReqPdu->getPduIndex() << ".\n";
//
//				while(!txReqsIt->second.empty()) {
//					short msgKind = txReqsIt->second.front();
//					txReqsIt->second.pop_front();
//
//					TransmissionBuffer::iterator bufferIt = buffer.find(msgKind);
//					if (bufferIt != buffer.end()) {	// send transportblock from the buffer
//
//						EV << "LTE-PHYenb: Sending buffered transport block with id = " << msgKind << " to the air.\n";
//						TransportBlock *tb = bufferIt->second;
//						tb->setRnti(rnti);
//						sendToChannel(tb);
//						buffer.erase(bufferIt);
//					}
//				}
//			}
//			delete dlCfgReqPdu;
//		}
//		dlCfgReqs.erase(dlCfgReqsIt);
//	}
C
x  
calincerchez 已提交
532 533 534
}

void PHYenb::sendDCIFormat(DlConfigRequestPduPtr pdu) {
C
calin cerchez 已提交
535 536 537 538 539 540 541
//    DlConfigRequestDciDlPdu *dciPdu = check_and_cast<DlConfigRequestDciDlPdu*>(pdu);
//    DCIFormat *dci = new DCIFormat();
//    dci->setName("DCIFormat");
//    dci->setRnti(dciPdu->getRnti());
////    dci->setRntiType(dciPdu->getRntiType());
//    dci->setChannelNumber(PDCCH);
//    sendToChannel(dci);
C
x  
calincerchez 已提交
542
}
C
calin cerchez 已提交
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
//
//bool PHYenb::findAndRemoveDlConfigRequestPdu(unsigned short pduIndex) {
//    DlConfigRequestPdus::iterator i = dlCfgReqPdus.find(pduIndex);
//    if (i != dlCfgReqPdus.end()) {
//    	delete i->second;
//        dlCfgReqPdus.erase(i);
//        return true;
//    } else {
//        return false;
//    }
//}
//
//bool PHYenb::findAndRemoveTxRequestPdu(unsigned msgId) {
//    TxRequestPdus::iterator i = txReqPdus.find(msgId);
//    if (i != txReqPdus.end()) {
//    	txReqPdus.erase(i);
//        return true;
//    } else {
//        return false;
//    }
//}