Commit 183b0158 authored by Nitha Sagar Jayanna's avatar Nitha Sagar Jayanna

project final update: semester project

parent d1809c05
...@@ -200,14 +200,17 @@ void start_background_system(void) { ...@@ -200,14 +200,17 @@ void start_background_system(void) {
void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){ void threadCreate(pthread_t* t, void * (*func)(void*), void * param, char* name, int affinity, int priority){
pthread_attr_t attr; pthread_attr_t attr;
pthread_attr_init(&attr); pthread_attr_init(&attr);
/*
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
struct sched_param sparam={0}; struct sched_param sparam={0};
sparam.sched_priority = priority; sparam.sched_priority = priority;
pthread_attr_setschedparam(&attr, &sparam); pthread_attr_setschedparam(&attr, &sparam);
pthread_create(t, &attr, func, param); pthread_create(t, &attr, func, param);
*/
AssertFatal(pthread_create(t, &attr, func, param)==0, "Error creating thread");
pthread_setname_np(*t, name); pthread_setname_np(*t, name);
if (affinity != -1 ) { if (affinity != -1 ) {
......
...@@ -416,15 +416,23 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp ...@@ -416,15 +416,23 @@ static int rfsimulator_write_internal(rfsimulator_state_t *t, openair0_timestamp
int flags_msb = (flags>>8)&0xff; int flags_msb = (flags>>8)&0xff;
int beam_enabled = (flags_msb>>3)&1; int beam_enabled = (flags_msb>>3)&1;
int beam_id = flags_msb&7; int beam_id = flags_msb&7;
LOG_I(HW,"sending %d samples at time: %ld, beam_enabled %d, beam_id %d\n", nsamps, timestamp, beam_enabled, beam_id); if(t->typeStamp == ENB_MAGICDL_FDD){
LOG_I(HW,"sending %d timestamp: %ld, beam_enabled %d, beam_id %d\n", nsamps, timestamp, beam_enabled, beam_id);
}
for (int i=0; i<FD_SETSIZE; i++) { for (int i=0; i<FD_SETSIZE; i++) {
buffer_t *b=&t->buf[i]; buffer_t *b=&t->buf[i];
if (b->conn_sock >= 0 ) { if (b->conn_sock >= 0 ) {
samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp}; samplesBlockHeader_t header= {t->typeStamp, nsamps, nbAnt, timestamp, beam_id};
fullwrite(b->conn_sock,&header, sizeof(header), t); fullwrite(b->conn_sock,&header, sizeof(header), t);
// LOG_I(HW,"Hello,World %d \n",header.beam_id);
sample_t tmpSamples[nsamps][nbAnt]; sample_t tmpSamples[nsamps][nbAnt];
for(int a=0; a<nbAnt; a++) { for(int a=0; a<nbAnt; a++) {
...@@ -466,7 +474,6 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi ...@@ -466,7 +474,6 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
// store the data in lists // store the data in lists
struct epoll_event events[FD_SETSIZE]= {{0}}; struct epoll_event events[FD_SETSIZE]= {{0}};
int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, timeout); int nfds = epoll_wait(t->epollfd, events, FD_SETSIZE, timeout);
if ( nfds==-1 ) { if ( nfds==-1 ) {
if ( errno==EINTR || errno==EAGAIN ) { if ( errno==EINTR || errno==EAGAIN ) {
return false; return false;
...@@ -500,6 +507,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi ...@@ -500,6 +507,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
buffer_t *b=&t->buf[fd]; buffer_t *b=&t->buf[fd];
//LOG_I(HW,"======= beam index ==========\n", b);
if ( b->circularBuf == NULL ) { if ( b->circularBuf == NULL ) {
LOG_E(HW, "received data on not connected socket %d\n", events[nbEv].data.fd); LOG_E(HW, "received data on not connected socket %d\n", events[nbEv].data.fd);
continue; continue;
...@@ -507,8 +516,20 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi ...@@ -507,8 +516,20 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
ssize_t blockSz; ssize_t blockSz;
if ( b->headerMode) if(t->typeStamp == ENB_MAGICDL_FDD){
LOG_I(HW,"Server side info: Beam index %d, path loss %lf\n", b->th.option_value, t->chan_pathloss);
}else {
LOG_I(HW,"Receiver side info: Beam index %d, path loss %lf\n", b->th.option_value,t->chan_pathloss);
}
//pathloss = beam_id*10
t->chan_pathloss = b->th.option_value * 10;
if ( b->headerMode){
blockSz=b->remainToTransfer; blockSz=b->remainToTransfer;
//LOG_I(HW,"====== Timestamp %lu ===== Beam Index ====== %d , path loss %lf \n ", b->th.timestamp, b->th.option_value, t->chan_pathloss);
}
else else
blockSz= b->transferPtr+b->remainToTransfer < b->circularBufEnd ? blockSz= b->transferPtr+b->remainToTransfer < b->circularBufEnd ?
b->remainToTransfer : b->remainToTransfer :
...@@ -528,8 +549,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi ...@@ -528,8 +549,7 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
AssertFatal((b->remainToTransfer-=sz) >= 0, ""); AssertFatal((b->remainToTransfer-=sz) >= 0, "");
b->transferPtr+=sz; b->transferPtr+=sz;
if (b->transferPtr==b->circularBufEnd - 1) if (b->transferPtr==b->circularBufEnd - 1) b->transferPtr=(char *)b->circularBuf;
b->transferPtr=(char *)b->circularBuf;
// check the header and start block transfer // check the header and start block transfer
if ( b->headerMode==true && b->remainToTransfer==0) { if ( b->headerMode==true && b->remainToTransfer==0) {
...@@ -546,7 +566,19 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi ...@@ -546,7 +566,19 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
nsamps_for_initial; nsamps_for_initial;
LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp); LOG_W(HW,"UE got first timestamp: starting at %lu\n", t->nextTimestamp);
b->trashingPacket=true; b->trashingPacket=true;
} else if ( b->lastReceivedTS < b->th.timestamp) {
}
else if ( b->lastReceivedTS < b->th.timestamp) {
int nbAnt= b->th.nbAnt; int nbAnt= b->th.nbAnt;
if ( b->th.timestamp-b->lastReceivedTS < CirSize ) { if ( b->th.timestamp-b->lastReceivedTS < CirSize ) {
...@@ -556,6 +588,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi ...@@ -556,6 +588,8 @@ static bool flushInput(rfsimulator_state_t *t, int timeout, int nsamps_for_initi
b->circularBuf[(index*nbAnt+a)%CirSize].i = 0; b->circularBuf[(index*nbAnt+a)%CirSize].i = 0;
} }
} }
} else { } else {
memset(b->circularBuf, 0, sampleToByte(CirSize,1)); memset(b->circularBuf, 0, sampleToByte(CirSize,1));
} }
...@@ -610,8 +644,20 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -610,8 +644,20 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
if (nbAnt != 1) { if (nbAnt != 1) {
LOG_W(HW, "rfsimulator: only 1 antenna tested\n"); LOG_W(HW, "rfsimulator: only 1 antenna tested\n");
} }
rfsimulator_state_t *t = device->priv; rfsimulator_state_t *t = device->priv;
for(int sock=0;sock<FD_SETSIZE;sock++){
buffer_t *b=&t->buf[sock];
//LOG_W(HW,"beam index %d",b->th.option_value);
}
//Printing the pathloss
if(t->typeStamp == UE_MAGICDL_FDD){
LOG_I(HW," RX side, pathLoss-defualt %lf\n", t->chan_pathloss);
}
LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps); LOG_D(HW, "Enter rfsimulator_read, expect %d samples, will release at TS: %ld\n", nsamps, t->nextTimestamp+nsamps);
// deliver data from received data // deliver data from received data
// check if a UE is connected // check if a UE is connected
...@@ -662,6 +708,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -662,6 +708,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n", LOG_I(HW, "No samples Tx occured, so we send 1 sample to notify it: Tx:%lu, Rx:%lu\n",
t->lastWroteTS, t->nextTimestamp); t->lastWroteTS, t->nextTimestamp);
//LOG_I(HW,"Testing Log");
rfsimulator_write_internal(t, t->nextTimestamp, rfsimulator_write_internal(t, t->nextTimestamp,
samplesVoid, 1, samplesVoid, 1,
t->tx_num_channels, 1, true); t->tx_num_channels, 1, true);
...@@ -703,6 +750,8 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -703,6 +750,8 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
// Add all input nodes signal in the output buffer // Add all input nodes signal in the output buffer
for (int sock=0; sock<FD_SETSIZE; sock++) { for (int sock=0; sock<FD_SETSIZE; sock++) {
buffer_t *ptr=&t->buf[sock]; buffer_t *ptr=&t->buf[sock];
//LOG_I(HW,"Beam id %d\n", ptr->th.option_value);
if ( ptr->circularBuf ) { if ( ptr->circularBuf ) {
bool reGenerateChannel=false; bool reGenerateChannel=false;
...@@ -710,12 +759,17 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -710,12 +759,17 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
//fixme: when do we regenerate //fixme: when do we regenerate
// it seems legacy behavior is: never in UL, each frame in DL // it seems legacy behavior is: never in UL, each frame in DL
if (reGenerateChannel) if (reGenerateChannel)
{
random_channel(ptr->channel_model,0); random_channel(ptr->channel_model,0);
}
if (t->poll_telnetcmdq) if (t->poll_telnetcmdq)
t->poll_telnetcmdq(t->telnetcmd_qid,t); t->poll_telnetcmdq(t->telnetcmd_qid,t);
for (int a=0; a<nbAnt; a++) {//loop over number of Rx antennas for (int a=0; a<nbAnt; a++) {//loop over number of Rx antennas
if ( ptr->channel_model != NULL ) // apply a channel model if ( ptr->channel_model != NULL ) // apply a channel model
{
rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a], rxAddInput( ptr->circularBuf, (struct complex16 *) samplesVoid[a],
a, a,
ptr->channel_model, ptr->channel_model,
...@@ -723,10 +777,15 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -723,10 +777,15 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
t->nextTimestamp, t->nextTimestamp,
CirSize CirSize
); );
buffer_t *b=&t->buf[a];
//ptr->channel_model->path_loss_dB=-132.24+10* b->th.option_value -RC.ru[0]->frame_parms->pdsch_config_common.referenceSignalPower;
//LOG_I(HW,"====== path loss in dB %f \n ", ptr->channel_model->path_loss_dB);
}
else { // no channel modeling else { // no channel modeling
sample_t *out=(sample_t *)samplesVoid[a]; sample_t *out=(sample_t *)samplesVoid[a];
int nbAnt_tx = ptr->th.nbAnt;//number of Tx antennas int nbAnt_tx = ptr->th.nbAnt;//number of Tx antennas
//LOG_I(HW, "nbAnt_tx %d\n",nbAnt_tx); //int UEbeam_id = ptr->th.beam_id;
//LOG_I(HW, "***** beam id at UE **** %d\n",UEbeam_id);
for (int i=0; i < nsamps; i++) {//loop over nsamps for (int i=0; i < nsamps; i++) {//loop over nsamps
for (int a_tx=0; a_tx<nbAnt_tx; a_tx++){//sum up signals from nbAnt_tx antennas for (int a_tx=0; a_tx<nbAnt_tx; a_tx++){//sum up signals from nbAnt_tx antennas
out[i].r+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].r; out[i].r+=ptr->circularBuf[((t->nextTimestamp+i)*nbAnt_tx+a_tx)%CirSize].r;
...@@ -745,6 +804,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo ...@@ -745,6 +804,7 @@ int rfsimulator_read(openair0_device *device, openair0_timestamp *ptimestamp, vo
*ptimestamp, t->nextTimestamp, *ptimestamp, t->nextTimestamp,
signal_energy(samplesVoid[0], nsamps)); signal_energy(samplesVoid[0], nsamps));
return nsamps; return nsamps;
} }
int rfsimulator_request(openair0_device *device, void *msg, ssize_t msg_len) { int rfsimulator_request(openair0_device *device, void *msg, ssize_t msg_len) {
abort(); abort();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment