Compare commits

...

10 Commits

Author SHA1 Message Date
Kirill Zakharenko
a336f254dc bump version to 0.1.10~1 2016-03-28 11:46:20 +02:00
Kirill Zakharenko
43fa3cab67 debian: compile for atom arch with SSE3 optimizations 2016-03-28 11:34:23 +02:00
Alexander Chemeris
aa65b020e7 transceiver: WIP: Set default max delay to 2 samples.
Default value of 0 may be too harsh, especially given random Rx/Tx delay
in 1 SPS receive mode.
2016-03-25 18:48:28 +03:00
Alexander Chemeris
72d4404534 transceiver: Add an option to emulate a RACH delay in random filler mode. 2016-03-25 18:48:28 +03:00
Alexander Chemeris
7ed93551ba sigProcLib: Change number of head bits in detectRACHBurst() from 4 to 8.
To match GSM 05.02 Access Burst definition.
2016-03-25 18:48:28 +03:00
Alexander Chemeris
9460154b36 transceiver: Add an option to generate random Access Bursts. 2016-03-25 18:48:28 +03:00
Alexander Chemeris
2f09d69063 transceiver: Properly handle MAXDLY.
Previously MAXDLY value was applied to Normal Bursts, which was nice
when working with sloppy test equipment like CMD57, but useless for
real world usage. At the same time documentation and de facto usage
of MAXDLY in OsmoBTS and OpenBTS assumed that it actually applies to
Access Bursts (RACH). So this patch changes osmo-rx behavior to apply
MAXDLY to RACH bursts and introduces a new command MAXDLYNB for the
old behavior.
2016-03-25 18:48:28 +03:00
Alexander Chemeris
140a2076d9 transceiver: Log channel number in DEBUG output of demoded bursts. 2016-03-25 18:47:27 +03:00
Alexander Chemeris
67a8fb9d51 Common: Make sure gLogEarly() log to the same facilities as the normal log. 2016-03-25 18:47:27 +03:00
Alexander Chemeris
cd3d0e616d Common: Get rid of a compilation warning.
debugLogEarly was replaced to an empty space and arguments of the function
became operators, grouped together by ():
Configuration.cpp: In member function 'bool ConfigurationTable::defines(const string&)':
Configuration.cpp:272:28: warning: left operand of comma operator has no effect [-Wunused-value]
   debugLogEarly(LOG_ALERT, "configuration parameter %s not found", key.c_str());
                            ^

This fix removes debugLogEarly together with its arguments.
2016-03-25 18:47:27 +03:00
11 changed files with 148 additions and 30 deletions

View File

@@ -35,7 +35,7 @@
#ifdef DEBUG_CONFIG
#define debugLogEarly gLogEarly
#else
#define debugLogEarly
#define debugLogEarly(x,y,z)
#endif

View File

@@ -38,6 +38,14 @@
using namespace std;
// Switches to enable/disable logging targets
// MUST BE DEFINED BEFORE gConfig FOR gLogEarly() TO WORK CORRECTLY
bool gLogToConsole = true;
bool gLogToSyslog = false;
FILE *gLogToFile = NULL;
Mutex gLogToLock;
// Reference to a global config table, used all over the system.
extern ConfigurationTable gConfig;
@@ -67,10 +75,6 @@ const char *levelNames[] = {
"EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG"
};
int numLevels = 8;
bool gLogToConsole = true;
bool gLogToSyslog = false;
FILE *gLogToFile = NULL;
Mutex gLogToLock;
int levelStringToInt(const string& name)
@@ -269,9 +273,32 @@ void gLogInit(const char* name, const char* level, int facility)
void gLogEarly(int level, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vsyslog(level | LOG_USER, fmt, args);
if (gLogToSyslog) {
va_list args_copy;
va_copy(args_copy, args);
vsyslog(level | LOG_USER, fmt, args_copy);
va_end(args_copy);
}
if (gLogToConsole) {
va_list args_copy;
va_copy(args_copy, args);
vprintf(fmt, args_copy);
printf("\n");
va_end(args_copy);
}
if (gLogToFile) {
va_list args_copy;
va_copy(args_copy, args);
vfprintf(gLogToFile, fmt, args_copy);
fprintf(gLogToFile, "\n");
va_end(args_copy);
}
va_end(args);
}

View File

@@ -56,6 +56,9 @@ const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000
const BitVector GSM::gRACHSynchSequence("01001011011111111001100110101010001111000");
// |-head-||---------midamble----------------------||--------------data----------------||t|
const BitVector GSM::gRACHBurst("0011101001001011011111111001100110101010001111000110111101111110000111001001010110011000");
int32_t GSM::FNDelta(int32_t v1, int32_t v2)
{

View File

@@ -53,6 +53,8 @@ extern const BitVector gDummyBurst;
/** Random access burst synch. sequence */
extern const BitVector gRACHSynchSequence;
/** Random access burst synch. sequence, GSM 05.02 5.2.7 */
extern const BitVector gRACHBurst;
/**@name Modulus operations for frame numbers. */

View File

@@ -71,7 +71,7 @@ TransceiverState::~TransceiverState()
}
}
bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc)
bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay)
{
signalVector *burst;
@@ -90,6 +90,9 @@ bool TransceiverState::init(int filler, size_t sps, float scale, size_t rtsc)
case Transceiver::FILLER_EDGE_RAND:
burst = generateEdgeBurst(rtsc);
break;
case Transceiver::FILLER_ACCESS_RAND:
burst = genRandAccessBurst(rach_delay, sps, n);
break;
case Transceiver::FILLER_ZERO:
default:
burst = generateEmptyBurst(sps, n);
@@ -119,7 +122,8 @@ Transceiver::Transceiver(int wBasePort,
mTransmitLatency(wTransmitLatency), mRadioInterface(wRadioInterface),
rssiOffset(wRssiOffset),
mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans), mOn(false),
mTxFreq(0.0), mRxFreq(0.0), mTSC(0), mMaxExpectedDelay(0), mWriteBurstToDiskMask(0)
mTxFreq(0.0), mRxFreq(0.0), mTSC(0), mMaxExpectedDelayAB(2*rx_sps), mMaxExpectedDelayNB(2*rx_sps),
mWriteBurstToDiskMask(0)
{
txFullScale = mRadioInterface->fullScaleInputValue();
rxFullScale = mRadioInterface->fullScaleOutputValue();
@@ -156,7 +160,7 @@ Transceiver::~Transceiver()
* are still expected to report clock indications through control channel
* activity.
*/
bool Transceiver::init(int filler, size_t rtsc)
bool Transceiver::init(int filler, size_t rtsc, unsigned rach_delay)
{
int d_srcport, d_dstport, c_srcport, c_dstport;
@@ -212,7 +216,7 @@ bool Transceiver::init(int filler, size_t rtsc)
if (i && filler == FILLER_DUMMY)
filler = FILLER_ZERO;
mStates[i].init(filler, mSPSTx, txFullScale, rtsc);
mStates[i].init(filler, mSPSTx, txFullScale, rtsc, rach_delay);
}
return true;
@@ -535,18 +539,19 @@ int Transceiver::detectBurst(TransceiverState *state, signalVector &burst,
switch (type) {
case EDGE:
rc = detectEdgeBurst(burst, mTSC, threshold, mSPSRx,
amp, toa, mMaxExpectedDelay);
amp, toa, mMaxExpectedDelayNB);
if (rc > 0)
break;
else
type = TSC;
case TSC:
rc = analyzeTrafficBurst(burst, mTSC, threshold, mSPSRx,
amp, toa, mMaxExpectedDelay);
amp, toa, mMaxExpectedDelayNB);
break;
case RACH:
threshold = 6.0;
rc = detectRACHBurst(burst, threshold, mSPSRx, amp, toa);
rc = detectRACHBurst(burst, threshold, mSPSRx, amp, toa,
mMaxExpectedDelayAB);
break;
default:
LOG(ERR) << "Invalid correlation type";
@@ -753,9 +758,16 @@ void Transceiver::driveControl(size_t chan)
//set expected maximum time-of-arrival
int maxDelay;
sscanf(buffer,"%3s %s %d",cmdcheck,command,&maxDelay);
mMaxExpectedDelay = maxDelay; // 1 GSM symbol is approx. 1 km
mMaxExpectedDelayAB = maxDelay; // 1 GSM symbol is approx. 1 km
sprintf(response,"RSP SETMAXDLY 0 %d",maxDelay);
}
else if (strcmp(command,"SETMAXDLYNB")==0) {
//set expected maximum time-of-arrival
int maxDelay;
sscanf(buffer,"%3s %s %d",cmdcheck,command,&maxDelay);
mMaxExpectedDelayNB = maxDelay; // 1 GSM symbol is approx. 1 km
sprintf(response,"RSP SETMAXDLYNB 0 %d",maxDelay);
}
else if (strcmp(command,"SETRXGAIN")==0) {
//set expected maximum time-of-arrival
int newGain;
@@ -901,10 +913,11 @@ void Transceiver::driveReceiveRadio()
}
}
void Transceiver::logRxBurst(SoftVector *burst, GSM::Time time, double dbm,
void Transceiver::logRxBurst(size_t chan, SoftVector *burst, GSM::Time time, double dbm,
double rssi, double noise, double toa)
{
LOG(DEBUG) << std::fixed << std::right
<< " chan: " << chan
<< " time: " << time
<< " RSSI: " << std::setw(5) << std::setprecision(1) << rssi
<< "dBFS/" << std::setw(6) << -dbm << "dBm"
@@ -937,7 +950,7 @@ void Transceiver::driveReceiveFIFO(size_t chan)
nbits = gSlotLen * 3;
dBm = RSSI + rssiOffset;
logRxBurst(rxBurst, burstTime, dBm, RSSI, noise, TOA);
logRxBurst(chan, rxBurst, burstTime, dBm, RSSI, noise, TOA);
TOAint = (int) (TOA * 256.0 + 0.5); // round to closest integer

View File

@@ -54,7 +54,7 @@ struct TransceiverState {
~TransceiverState();
/* Initialize a multiframe slot in the filler table */
bool init(int filler, size_t sps, float scale, size_t rtsc);
bool init(int filler, size_t sps, float scale, size_t rtsc, unsigned rach_delay);
int chanType[8];
@@ -107,7 +107,7 @@ public:
~Transceiver();
/** Start the control loop */
bool init(int filler, size_t rtsc);
bool init(int filler, size_t rtsc, unsigned rach_delay);
/** attach the radioInterface receive FIFO */
bool receiveFIFO(VectorFIFO *wFIFO, size_t chan)
@@ -156,6 +156,7 @@ public:
FILLER_ZERO,
FILLER_NORM_RAND,
FILLER_EDGE_RAND,
FILLER_ACCESS_RAND,
};
private:
@@ -227,7 +228,8 @@ private:
double mTxFreq; ///< the transmit frequency
double mRxFreq; ///< the receive frequency
unsigned mTSC; ///< the midamble sequence code
unsigned mMaxExpectedDelay; ///< maximum expected time-of-arrival offset in GSM symbols
unsigned mMaxExpectedDelayAB; ///< maximum expected time-of-arrival offset in GSM symbols for Access Bursts (RACH)
unsigned mMaxExpectedDelayNB; ///< maximum expected time-of-arrival offset in GSM symbols for Normal Bursts
unsigned mWriteBurstToDiskMask; ///< debug: bitmask to indicate which timeslots to dump to disk
std::vector<TransceiverState> mStates;
@@ -274,7 +276,7 @@ protected:
/** set priority on current thread */
void setPriority(float prio = 0.5) { mRadioInterface->setPriority(prio); }
void logRxBurst(SoftVector *burst, GSM::Time time, double dbm,
void logRxBurst(size_t chan, SoftVector *burst, GSM::Time time, double dbm,
double rssi, double noise, double toa);
};

View File

@@ -75,6 +75,7 @@ struct trx_config {
unsigned rx_sps;
unsigned chans;
unsigned rtsc;
unsigned rach_delay;
bool extref;
Transceiver::FillerType filler;
bool diversity;
@@ -187,6 +188,9 @@ bool trx_setup_config(struct trx_config *config)
case Transceiver::FILLER_EDGE_RAND:
fillstr = "EDGE busrts with random payload";
break;
case Transceiver::FILLER_ACCESS_RAND:
fillstr = "Access busrts with random payload";
break;
}
std::ostringstream ost("");
@@ -266,7 +270,7 @@ Transceiver *makeTransceiver(struct trx_config *config, RadioInterface *radio)
trx = new Transceiver(config->port, config->addr.c_str(),
config->tx_sps, config->rx_sps, config->chans,
GSM::Time(3,0), radio, config->rssi_offset);
if (!trx->init(config->filler, config->rtsc)) {
if (!trx->init(config->filler, config->rtsc, config->rach_delay)) {
LOG(ALERT) << "Failed to initialize transceiver";
delete trx;
return NULL;
@@ -318,7 +322,8 @@ static void print_help()
" -c Number of ARFCN channels (default=1)\n"
" -f Enable C0 filler table\n"
" -o Set baseband frequency offset (default=auto)\n"
" -r Random burst test mode with TSC\n"
" -r Random Normal Burst test mode with TSC\n"
" -A Random Access Burst test mode with delay\n"
" -R RSSI to dBm offset in dB (default=0)\n"
" -S Swap channels (UmTRX only)\n",
"EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG");
@@ -333,6 +338,7 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
config->rx_sps = DEFAULT_RX_SPS;
config->chans = DEFAULT_CHANS;
config->rtsc = 0;
config->rach_delay = 0;
config->extref = false;
config->filler = Transceiver::FILLER_ZERO;
config->diversity = false;
@@ -341,7 +347,7 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
config->swap_channels = false;
config->edge = false;
while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:r:R:Se")) != -1) {
while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:r:A:R:Se")) != -1) {
switch (option) {
case 'h':
print_help();
@@ -381,6 +387,10 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
config->rtsc = atoi(optarg);
config->filler = Transceiver::FILLER_NORM_RAND;
break;
case 'A':
config->rach_delay = atoi(optarg);
config->filler = Transceiver::FILLER_ACCESS_RAND;
break;
case 'R':
config->rssi_offset = atof(optarg);
break;
@@ -417,6 +427,12 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
print_help();
exit(0);
}
if (config->rach_delay > 68) {
printf("RACH delay is too big %i\n\n", config->rach_delay);
print_help();
exit(0);
}
}
int main(int argc, char *argv[])

View File

@@ -1005,6 +1005,45 @@ signalVector *genRandNormalBurst(int tsc, int sps, int tn)
return burst;
}
/*
* Generate a random GSM access burst.
*/
signalVector *genRandAccessBurst(int delay, int sps, int tn)
{
if ((tn < 0) || (tn > 7))
return NULL;
if ((sps != 1) && (sps != 4))
return NULL;
if (delay > 68)
return NULL;
int i = 0;
BitVector *bits = new BitVector(88+delay);
signalVector *burst;
/* delay */
for (; i < delay; i++)
(*bits)[i] = 0;
/* head and synch bits */
for (int n = 0; i < 49+delay; i++, n++)
(*bits)[i] = gRACHBurst[n];
/* Random bits */
for (; i < 85+delay; i++)
(*bits)[i] = rand() % 2;
/* Tail bits */
for (; i < 88+delay; i++)
(*bits)[i] = 0;
int guard = 68-delay + !(tn % 4);
burst = modulateBurst(*bits, guard, sps);
delete bits;
return burst;
}
signalVector *generateEmptyBurst(int sps, int tn)
{
if ((tn < 0) || (tn > 7))
@@ -1816,21 +1855,22 @@ int detectGeneralBurst(signalVector &rxBurst,
*
* Correlation window parameters:
* target: Tail bits + RACH length (reduced from 41 to a multiple of 4)
* head: Search 4 symbols before target
* tail: Search 10 symbols after target
* head: Search 8 symbols before target
* tail: Search 4 symbols + maximum expected delay
*/
int detectRACHBurst(signalVector &rxBurst,
float thresh,
int sps,
complex &amp,
float &toa)
float &toa,
unsigned maxTOA)
{
int rc, target, head, tail;
CorrelationSequence *sync;
target = 8 + 40;
head = 4;
tail = 10;
head = 8;
tail = 4 + maxTOA;
sync = gRACHSequence;
rc = detectGeneralBurst(rxBurst, thresh, sps, amp, toa,

View File

@@ -122,6 +122,9 @@ signalVector *generateEmptyBurst(int sps, int tn);
/** Generate a normal GSM burst with random payload - 4 or 1 SPS */
signalVector *genRandNormalBurst(int tsc, int sps, int tn);
/** Generate an access GSM burst with random payload - 4 or 1 SPS */
signalVector *genRandAccessBurst(int delay, int sps, int tn);
/** Generate a dummy GSM burst - 4 or 1 SPS */
signalVector *generateDummyBurst(int sps, int tn);
@@ -192,13 +195,15 @@ bool energyDetect(signalVector &rxBurst,
@param sps The number of samples per GSM symbol.
@param amplitude The estimated amplitude of received RACH burst.
@param TOA The estimate time-of-arrival of received RACH burst.
@param maxTOA The maximum expected time-of-arrival
@return positive if threshold value is reached, negative on error, zero otherwise
*/
int detectRACHBurst(signalVector &rxBurst,
float detectThreshold,
int sps,
complex &amplitude,
float &TOA);
float &TOA,
unsigned maxTOA);
/**
Normal burst correlator, detector, channel estimator.

7
debian/changelog vendored
View File

@@ -1,3 +1,10 @@
osmo-trx (0.1.10~1) trusty; urgency=medium
* some EDGE support in master
* fairwaves/rach-filler branch
-- Kirill Zakharenko <earwin@gmail.com> Sun, 27 Mar 2016 19:37:39 +0100
osmo-trx (0.1.9) trusty; urgency=medium
* Ask Ivan, really

3
debian/rules vendored
View File

@@ -5,6 +5,9 @@ DEB_BUILD_HARDENING=1
%:
dh $@ --with autoreconf
override_dh_auto_configure:
dh_auto_configure -- --without-sse CFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2" CXXFLAGS="-DHAVE_SSE3 -march=atom -mtune=atom -O2"
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info