Openbts SW
Openbts SW
Openbts SW
DLECS 7/25/2011
ABRUPT
Page 2
Tables: Table 1-L3 RR messages 21 Table 2- L3 RR messages (cont.) 22 Table 3-L3 MM messages 24 Table 4-L3 CC messages 26 Table 5-some of the supported commands in OpenBTS List of abbreviations:
RR MM CC BTS CLI HLR MOC MTC Radio Resource Mobility Management Call Control Base Transceiver Station Command Line Interpreter Home Location Register Mobile Originated Call Mobile Terminated Call
32
ABRUPT
Page 3
Chapter 1
1.1 Introduction
OpenBTS is an open-source UNIX application that uses the Universal Software Radio Peripheral (USRP) to implement GSM air interface (Um) to standard GSM handset and uses the Asterisk software PBX to connect calls. The combination of the ubiquitous GSM air interface with VoIP backhaul could form the basis of a new type of cellular network that could be deployed and operated at substantially lower cost than existing technologies in green fields in the developing world. In plain language, we are working on a new kind of cellular network that can be installed and operated at about 1/10 the cost of current technologies, but that will still be compatible with most of the handsets that are already in the market. This technology can also be used in private network applications (wireless PBX, rapid deployment, etc.) at much lower cost and complexity than conventional cellular. Telecom industry is one of the rapidly growing industries all over the world. The entrance of opensource team into the telecom industry made a revolutionized change in the industry. Asterisk was a typical example for it which was a featured PBX for home users, enterprises, VoIP service providers and telecoms in such a low cost that anyone even imagined. Asterisk is both an Open Source Community and a commercial product from Digium[1] . Now again another open source coming which allows standard GSM-compatible mobile phones to make telephone calls without using existing telecommunication providers networks. ie we can build up our own network just like vodafone, airtel or any. The project was started by HarvindSamra and David A. Burgess and named it as OpenBTS. . OpenBTS is notable for being the first free software implementation of the industry-standard GSM protocol stack[1] .
Base Transceiver Station In typical GSM networks, the end point of the system is the Base Transceiver Station (BTS) which sends radio frequency signal to and from mobile devices or a modem. The BTS comes under Base station Controller (BSC) with implements the communication between there radio signals with MSC/VLR. The MSC/VLR is responsible to authenticate the user against the database Home Location Register (HLR), Authentication Center (AuC), call setup and call routing. A typical GSM network diagram is shown in Figure 1.
ABRUPT
Page 4
OpenBTS replaces the entire setup with Universal Software Radio Peripheral (USRP), and a computer. USRP to receive and transmit the GSM signaling using GNURadio as a driver software. OpenBTS package plays the role of MSC/VLR and Asterisk software PBX will be used to connect calls. Figure 2 shows a typical OpenBTS network.
Rural/village telephony and text messaging Cellular coverage in remote areas (e. g. ships, oil rigs) Law enforcement and security operations Rapidly deployable emergency communications Network emulation and handset testing
ABRUPT
Page 5
1.4 Threads
The implementation of the OpenBTS makes use of the POSIX thread library, pthreads. For those unfamiliar with threads or who have an aversion to them, this may seem frightening and strange, but the effect of this approach is to greatly simplify the code in each layer of the BTS. You can have N threads each with K states or one thread with KN states. We choose the former. The price of threads is discipline in the use of synchronized interthread communication. Do use mutexes. Do not just use volatiles. The general rule is that single-state transformational operations are performed with direct calls while multi-state machines, especially those with internal timeout behaviors, have their own threads ABRUPT Page 7
ABRUPT
1.4.10 Logical Channel Structure and Subclasses Following the OSI model, each logical channel is processed in three layers: L1, L2, L3. Each layer is represented by an object (a layer processor) that has read and write methods on its high and low sides. These objects are persistent over the life of the application. In the normal course of the OpenBTS application, the destructors for these classes should never be invoked. The layer processor classes are: L1FECEncoder. Accepts L2Frame objects, encodes them into TxBurst objects. Algorithms defined in GSM 05. 03. L1FECDecoder. Accepts RxBursts from the TDM sublayer and processes them into L2Frame objects. Algorithms defined in GSM 05. 03. L1FEC. A container for a channels L1FECEncoder and L1FECDecoder. L2LAPDm. The L2LAPDm transacts L2Frame objects with L1 and L3Frame objects with L3. Implements the LAPDm state machine as described in GSM 04.06 and ITU-T Q. 921. L3StateMachine. The L3StateMachine transacts L3Frame objects with L2. Implements the protocols of GSM 04. 08 and also interfaces with SIP entities. BCH (broadcast channels) SCH, FCCH, BCCH NDCCH (non-dedicated control channels) CCCH (downlink unicast), RACH (uplink shared) DCCH (dedicated control channels, Dm) SDCCH, SACCH, FACCHF (full rate) TCHF (full rate speech, GSM 06. 10, Bm). Many traffic channel classes are ignored here, as are half-rate channels. They are not a priority in a first release.
1.5
The TDM sublayer forms the interface between the physical channels on the transceiver interface and the logical channels in the higher layers. It implements the rules of GSM 05. 02. All LCHs on an ARFCN share a common TDM sublayer. In the uplink side, the TDM sublayer accepts all of the RxBurst objects from a single ARFCN and demultiplexes them according to their frame count timestamps into a table of LogicalChannel objects. In the downlink side, the multiplexing layer is a pass-through to the transceiver interface, but with mutex controls and serialization.
ABRUPT
Page 10
The protocol on the master clock interface has a single message that periodically indicates the current value of the BTS master clock, with an additional advance to compensate for latency. This message is an unacknowledged indication from the transceiver to the GSM stack. These are human-readable ASCII messages sent once per super frame and whenever the clock advance value is adjusted. The protocol on the per-ARFCN control interface has commands for power control, tuning and configuration of the channel combination on each slot. Each command has a corresponding response for integrity on the UDP link; they are human-readable ASCII messages. The protocol on the per-ARFCN data interface uses binary messages to convey RxBurst and TxBurst objects with one burst per UDP packet to minimize latency. There are no acknowledgments on this interface because there is no point in retransmitting packets in a lowlatency real time link.
ABRUPT
Page 11
ABRUPT
Page 12
ABRUPT
Page 13
1.9.3.1 Implemented procedures in callcontrol.cpp Mobile originated call procedure Mobile terminated call procedure Emergency calls Test calls
ABRUPT
Page 14
Steps of mobile originated call : CM Service Request (MM, 9.2.9), decode. This message indicates to the BTS that the Phone will require ISDN-style (connection-oriented) services. CM Service Accept (MM, 9.2.5), encode. This message allows us to bypass authentication and proceed directly to ISDN-style/Q.931call control. CM Service Reject (MM, 9.2.6), encode. This message is sent to reject service if the call setup cannot be performed for some reason, such as an lack of available traffic channels. Setup (CC, 9.3.23), decode. Simply skip unsupported elements based on T and L fields when parsing. This message triggers an INVITE message to the Asterisk server that starts the hybrid Q.931/SIP call setup procedure. Call Proceeding (CC, 9.3.3), encode. Assignment Command (RR, 9.1.2), encode. This message moves the transaction from the SDCCH to the TCH/FACCH. Assignment Complete (RR, 9.1.3), decode. This is the first message sent from the phone on the newly assigned TCH/FACCH. Alerting (CC, 9.3.1), encode. This message corresponds to the SIP 180 Ringing message. Progress (CC, 9.3.17), encode. This message is needed to keep the connection alive when Asterisk delays are large. It is similar in purpose to the SIP 100 Trying message. Connect (CC, 9.3.5), encode. This message corresponds to the SIP 200 OK message. Connect Acknowledge (CC, 9.3.6), decode. This message corresponds to the SIP ACK message.
ABRUPT
Page 15
ASTERISK
BTS CM Service Request CM Service Accept setup send INVITE() call proceeding assignment command Assignment Complete alerting progress send ok() send ACK for OK connect connect acknowlege
MS
MOC implementation in OpenBTS Mobile originated call is implemented in OpenBTS in the file CallControl.cpp & CallControl.h through the two functions MOCStarter which implements the MOC sequence until the transaction is moved from the SDCCH to the TCH/FACCH & MOCController which implements the rest of the MOC sequence Sequence diagram for MOC:
OpenBTS
DCCHDispatch
MobilityManagement
CallControl
MOCController()
ABRUPT
Page 16
BTS Paging Request Type 1 Paging Response setup call confirmed assignment command Assignment Complete alerting progress connect connect acknowlege
MS
MTC implementation in OpenBTS: Mobile terminated call is implemented in OpenBTS in the file CallControl.cpp & CallControl.h through the two functions MTCStarter which implements the MTC sequence until the transaction ABRUPT Page 17
OpenBTS
DCCHDispatch
MobilityManagement
CallControl
MTCController()
1.9.3.2 Implemented procedures in DCCHDispatch.cpp Dispatcher for messages passing through DCCH Dispatcher for RR messages passing through DCCH Dispatcher for MM messages passing through DCCH Important functions: 1- void Control::DCCHDispatcher(LogicalChannel *DCCH): persistent-thread control function for the DCCH. 2- void DCCHDispatchRR(const L3RRMessage* req, LogicalChannel *DCCH): Dispatch the appropriate controller for a Radio Resource message. 3- void DCCHDispatchRR(const L3RRMessage* req, LogicalChannel *DCCH) 4- void DCCHDispatchMM(const L3MMMessage* req, LogicalChannel *DCCH): Dispatch the appropriate controller for a Mobility management message. 1.9.3.3 Implemented procedures in mobilitymanagement.cpp: Imsi detach Location update A handler for CM service request sending the welcome message
ABRUPT
Page 18
ABRUPT
Page 19
Some important functions: void L3Message::write(L3Frame& dest) const: writes a l3 message (header skip indicator , pd , message type then calls the function that writes the l3 message's body. GSM::L3Message* GSM::parseL3(const GSM::L3Frame& source): Parses l3 messages and determines which type is it(RR,MM,CC).
There are three main types of L3 messages which are implemented in the Open BTS project: radio resource messages mobility management messages call control messages
These messages are used in debugging problems occurring during the communication between the BTS and the MS and they are logged through the logging file of the project.
ABRUPT
Page 20
ABRUPT
Page 21
ABRUPT
Page 22
The first two files contain functions that are responsible for structuring the RR messages as specified in the standards , they also provide parsing methods for messages that come from the MS as a response for any of the RR messages. Each message is implemented by a function that is responsible for structuring the message and is named like that messagename::writebody( ) For incoming messages that need to be parsed the message is named like that messagename::parsebody( ) Example: Parsing the page response message which is initiated by the MS as a response for any of the following RR messages : Paging request type 1 Paging request type 2 Paging request type 3
The other two files provide methods to ease dealing with the elements that form the RR messages. ABRUPT Page 23
L3 MM messages
L3 MM messages implemented in Open BTS: IMSI Detach Indication CM Service Request CM Service Accept CM Service Reject CM Service Abort CM Re-establishment Request Identity Response Identity Request MM Information Location Updating Accept Location Updating Reject Location Updating Request MM Status
ABRUPT
Page 24
The first two files contain functions that are responsible for structuring the MM messages as specified in the standards. Each message is implemented by a function that is responsible for structuring the message and is named like that messagename::writebody( ). The other two files provide methods to ease dealing with the elements that form the MM messages.
ABRUPT
Page 25
ABRUPT
Page 26
The first two files contain functions that are responsible for structuring the CC messages as specified in the standards. Each message is implemented by a function that is responsible for structuring the message and is named like that messagename::writebody( ) The other two files provide methods to ease dealing with the elements that form the CC messages.
ABRUPT
Page 27
The first two files implement the algorithms and the state machines of the LAPDM protocol. The other two files implement methods for structuring and formatting L2 meesages. For further details on L2 LAPDM please see GSM 04.06 . 1.9.4.3 LAYER 1 It represents the physical layer of the GSM stack. It maps physical channel into logical channels, sends and receives bits from the transceiver module, interfaces with the transceiver through the transceiver manager module. The interface with the transceiver is through a UDP port to ensure portability and modularity for both modules. LAYER 1 in OpenBTS: Layer 1 is implemented through the following files : GSML1FEC.cpp GSML1FEC.h GSMLogicalChannel.h GSMLogicalChannel.cpp GSMTDMA.h GSMTDMA.cpp
The GSML1FEC.h file contains the classes representing encoders and decoders for different logical channels here are some of them: ABRUPT class L1Encoder Abstract class for L1 encoders. In most subclasses, writeHighSide() drives the processing. class L1Decoder An abstract class for L1 decoders. writeLowSide() drives the processing. class L1FEC Page 28
The GSML1FEC.h file implements the encoders and decoders for the various logical channels and also the L1 FEC which is an encapsulated encoder and decoder.
The GSML1FEC.cpp file contains some important functions such as: void FCCHL1Encoder::generate() BCCHL1Encoder::generate() void SCHL1Encoder::generate() void RACHL1Decoder::serviceLoop()
The first three functions are called through service loops ,they run continuously until the looping condition is violated , these functions are responsible for sending the data sent by the logical channel calling it Example: void FCCHL1Encoder::generate(): Responsible for sending the zero burst which is sent on the FCCH logical channel as specified in the GSM standards. The fourth function has a service loop pulls RACH bursts from a FIFO and sends them to the decoder. GSMLogicalChannel.h & GSMLogicalChannel.cpp: provide classes and methods to deal with the logical channels in general such as open & close or constructors and service loops that weren't mentioned in GSML1FEC.cpp and GSML1FEC.h. GSMTDMA.h & GSMTDMA.cpp are responsible for mapping logical channels into physical channels. Other important files GSMCommon.cpp GSMCommon.h GSMConfig.cpp GSMConfig.h Page 29
ABRUPT
GSMCommon.cpp and GSMCommon.h contain some important functions which set the uplink and downlink frequencies and calculate the current frame number besides other functions. GSMConfig.cpp and GSMConfig.h contain the GSMConfig class which holds the GSM configuration parameters such as: Network color code Base Station color code GSM operating band Copy of the BTS master clock Encoded L2 frames to be sent on the BCCH Encoded L3 frames to be sent on the SACCH
GSMSAPMux.cpp and GSMSAPMux.h implement methods needed for dealing with a SAPMUX. SAPMux is a multipexer that connects a single L1 to multiple L2s. "service access point" in GSM/ISDN is analogous to port number in IP. GSM allows up to 4 SAPs, although only two are presently used.
ABRUPT
Page 30
1.9.10 doc Projects documentation. 1.9.11 tests Test fixtures for subsets of OpenBTS components. 1.9.12 Smqueue RFC-3428 store-and-forward server for SMS.
ABRUPT
Page 31
Setlogfile
Printtmsis [\"clear\"] -- print/clear the TMSI table Sendsms cellID send SMS to <IMSI>, addressed from <src>, after prompting [MCC MNC LAC CI] -- get/set location area identity (MCC, MNC, LAC) and cell ID (CI)
ABRUPT
Page 32
ABRUPT
Page 33
ABRUPT
Page 34
1.10.4 GNU radio setup Install guile Install sdcc Install JACK,libjack-dev Install libosip Install libqtgui4,python-qt4,libgnuradio-qtgui0,python-gnuradio-qtgui Install Python-lxml,Python-Cheetah ==> for grc Install libortp-dev ==> for OpenBts code configure Cd GNU radio Enable ./configure:type chmod a+x ./configure in gnuradio-3.3.0 and gnuradio3.3.0/usrp2/firmware Enable ./configure.gui ./configure After ./ configure you should make sure that gr-usrp compnent was successfully installed. If the configuration is successful the following message should appear on the terminal:
ABRUPT
Page 35
If you get an error telling you that the python or ld_library paths are not installed correctly then make sure that python-gnuradio is installed 1.10.5 Testing the WBX Connect the usrp Type lsusrp in the terminal 1.10.6 Compiling and running openbts
Firstly, copy these files into ur code's directory: all files in /usr/share/libtool/config/ except the softlinks config.sub and config.guess copy config.sub and config.guess from /usr/share/misc to ur code's directory
Secondly, type the following commands in the terminal: aclocal autoconf autoheader automake ./configure make sudo make install cp OpenBTS.config.example OpenBTS.config alter the required settings in OpenBTS.config(mcc= 602 ,mnc= 04 or greater,arfcn =20) cd apps ./OpenBTS
ABRUPT
Page 36
ABRUPT
Page 37