COM4 - Inter BTS Communication
COM4 - Inter BTS Communication
COM4 - Inter BTS Communication
By Ahmed Sayeed Mohammed Rawi Ahmed Fargaly Abd-El Rahman Ahmed Mohammed Othman Ahmed Mahmoud Emam Eslam Ahmed Saad
A Graduation Project Report Submitted to the Faculty of Engineering at Cairo University In Partial Fulfillment of the Requirements for the Degree of Bachelor of Science in Electronics and Communications Engineering
Table of Contents
List of Tables ................................................................................................................ iv List of Figures ................................................................................................................ v List of Symbols and Abbreviations............................................................................... vi Acknowledgments.........................................................................................................vii Abstract ........................................................................................................................ viii Chapter 1: 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 Introduction To The Project ..................................................................... 1
The Main Target .............................................................................................. 3 Hardware Requirements .................................................................................. 7 Software Requirements ................................................................................... 8 Layers of OpenBTS......................................................................................... 8 Core Modules .................................................................................................. 9 Original Data Flow .......................................................................................... 9 Network Organization ................................................................................... 12 GSM Control Repeater .................................................................................. 12 Synchronization and freq. correction in OpenBTS code ....................... 15
Introduction ................................................................................................... 15 ARFCN Mapping .......................................................................................... 15 Frequency correction Channel (FCCH) ........................................................ 16 Why? ...................................................................................................... 16
2.3.1 2.4
2.4.1 2.5
FCCH & SCH Detection and SCH Decoding ............................................... 18 Where? ................................................................................................... 18 How? ...................................................................................................... 18
2.6.1
Code Verification Results ...................................................................... 18 Report Preparation ................................. Error! Bookmark not defined.
Report Contents ............................................. Error! Bookmark not defined. Report Formatting ......................................... Error! Bookmark not defined. Printing................................................... Error! Bookmark not defined. Paragraph and Font Formatting ............. Error! Bookmark not defined. Important Remarks................................. Error! Bookmark not defined.
Report Submission ........................................ Error! Bookmark not defined. Useful Features in MS Word......................... Error! Bookmark not defined. Examples for Tables and Figures .................. Error! Bookmark not defined. Conclusion ............................................................................................. 36
Chapter 5:
iii
List of Tables
Please insert your list of tables here. Below is an example of a list of tables generated using MS Word Insert Table of Figures feature.
Table 3-1: An empty table showing empty fields. ....... Error! Bookmark not defined.
iv
List of Figures
Figure 1: Typical GSM network diagram ---------------------------------------------- 1 Figure 2: OpenBTS Network----------------------------------------------------------- 1 Figure 3: Original OpenBTS Connections Architecture. ------------------------------ 4 Figure 4: OpenBTS Connection through GSM Um Repeater. ------------------------- 5 Figure 5: USRP 1 Rev 4.5 with additional 52MHz clock ------------------------------ 7 Figure 6: Typical upstream data flow in the GSM air interface of the OpenBTS -- 11 Figure 7: Typical downstream data flow in the GSM air interface of the OpenBTS. ----------------------------------------------------------------------------------------- 11 Figure 8: Components of the OpenBTS application suite and their communication channels as installed in each access point. Sharp-cornered boxes are hardware components. Round-cornered boxes are software components. ---------------------- 12 Figure 9: The sequence of encoding data to generate encrypted burst---------------- 13 Figure 10: example of the mapping of logical channels ---------------------------- 15
Please insert here any symbols and abbreviations that you commonly use in your report. Example:
SNR Tx Rx Signal-to-Noise Ratio Transmitter Receiver
vi
Acknowledgments
Please insert the acknowledgments here. In this section, you may thank those who provided help and support to you during the course of your project.
vii
Abstract
Please insert the project abstract here. The abstract is a one-page summary of the project. It should include clearly what was done in the project and the reached results.
viii
Chapter 1:
The Open BTS Project is an open-source UNIX application that uses the Universal Software Radio Peripheral (USRP) to present a GSM air interface (Um) to standard GSM handset and uses the Asterisk VoIP PBX to connect calls. Open BTS replaces the entire setup in conventional GSM BTS shown in Figure 1, which is a dumb device that is managed externally by a base station controller (BSC) and connects calls in a remote mobile switching center (MSC).
The USRP is used to receive and transmit the GSM signaling using GNU Radio as 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.
I.
Why Build an Open Source GSM Stack? 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. 1
Since these new hybrid networks are not readily compatible with legacy networks, and since radical two-tier pricing would be disruptive for existing carriers, we are not likely to see this kind of innovation from the conventional telecom community. This is the primary motivation for starting this project: a vision of truly universal telephone service.
II.
GSM is a good choice precisely because it is old and boring. Everyone knows it works and 80% of the worlds carriers are still using it. Its a proven technology that is well-suited to the target application. The specification is publicly available and in a few more years most of the essential patents will expire. CDMA physical layers are too complex for an inexpensive all-software radio and do not scale well for low-capacity cells. CMDA capacity comes in increments of 50 or more subscriber lines and the lowest layers of your radio must process all of that bandwidth whether you intend to use it or not. By contrast, GSM capacity comes in increments of 7-8 lines and a well-managed radio can even ignore inactive parts of the signal. Beyond the technical issues, IS-95-style CMDA (including cdma2000) is tightly controlled intellectual property. You cant even get a copy of the specification without signing an NDA and paying several hundred dollars.
III.
What about GPRS/EDGE and UMTS? Future versions of the Open BTS may well support GPRS and EDGE. GPRS,
when available, should be a software-only upgrade for any installed Open BTS system. EDGE support may require additional computational resources but the additional software is not complex, at least when compared to the rest of the BTS. UMTS is a radically different CDMA-style physical layer and well outside the current scope of this project.
IV.
There are a lot of people out there who would rather not blanket Africa with WiWhatever than find a way to make GSM dirt cheap. Its sexier to talk about the newest air interface and that talk gets a lot a buzz, but the truth is that that WiWhatever is poorly suited to mobile telephony. WiFi range is far too short for mobile coverage in rural areas. For example, youre not going to cover 700 square miles with a single WiFi tower, but thats exactly what GSM was made to do. If access points are connected through different ISPs, handovers will be unreliable. The phones are expensive and power-hungry, and compared to GSM they always will be. WiFi may become a decent technology for semi-mobile telephones in dense urban areas, but its not a mobile phone standard and its not well-matched to the rural cellular application. WiMax has most of the problems of WiFi. To make matters worse, most WiMax bands dont penetrate structures very well. Most WiMax deployers are planning to solve this problem by saturating large buildings with small access points. Thats fine in Manhattan and London, but we dont see anyone putting femtocells in a million houses when those households couldnt afford phones in the first place. More important than all of that is to remember the goal of the Open BTS: universal telephone service. Our project philosophy is that it is much better to give people basic telephone service with an upgrade path to 250 kb/sec EDGE than to generate a lot of hype over a scorching fast broadband technology that can probably never be truly universal. Dont let the perfect be the enemy of the goo d. Wi- Whatevers do have a place in Open BTS, though: backhaul. The standard Open BTS backhaul is likely to be redundant-path point-to-point WiFi or WiMax.
the mobile sets (MS). The system architecture in this case is shown in Figure 3, where, for simplicity, two BTSs only are connected via the IP-network. The Um interface is handled by the GSM side of the OpenBTS to manage connections of the MSs to the BTSs. The software modules of the GSM side are the GSM stack, with its 3layer model, and the transceiver, which acts as a baseband modem, both running on the host processor. The radio hardware is implemented on the USRP, its daughterboard and external RF components. The software for the IP side is composed of a SIP message handler and VoIP soft switch, the ASTERISK. A GSM/SIP protocol processor module reacts to the L3 messages, including RR, MM and CM messages, and translates the MM and CM messages between the GSM and SIP sides, completing the software suite of the OpenBTS. Non-local calls are routed by the ASTERISK soft switch as VoIP traffic through the IP-Network to the other BTSs. Such architecture requires an IP-network access at each BTS location, which is a costly solution for isolated rural areas. Hence we propose the following two alternatives for connecting the BTSs. One is through the use of a VoIP/GSM gateway to the BTS and the other is through modifying the OpenBTS software suite to act as a GSM repeater.
We propose another alternative for connecting the BTSs through a GSM Um repeater, as shown in Figure 4 and described below.
In this architecture OpenBTS A operates as a master BTS, with its Asterisks data base covering the other slave BTSs in the service area, and oper ates at an ARFCN A. OpenBTS B represents one of the slave BTSs, connected to its local MSs at an ARFCN B, and repeating MM and CC signaling messages, as well as some traffic bursts, to OpenBTS A at one or more time slots of ARFCN A. The modules of OpenBTS B, other than the GSM Repeater Control module, pertain to either the MSs Side; which operates as a BTS in the same manner as the original OpenBTS modules, or the master BTS side; which operate as a MS attached to the master BTS. The differences between both side and the main functions of the GSM Repeater Control module are explained as follows. Radio B2: This could be another USRP, just as Radio B1, with the down-link and uplink frequencies tuned to match receive and transmit frequencies of ARFCN A, respectively. Transceiver B2: This is another instantiation of the transceiver module, with modifications to handle some of the up-link and down-link channels that are not used in the original OpenBTS code. These channels are the up-link frequency correction (FCCH), synchronization (SCH), access grant (AGCH) and paging (PCH) channels, and the down-link RATCH channel. This module should start by searching for the FCCH burst of the OpenBTS A and thence correct any frequency offset to synchronize its carrier with ARFCN A. Then it looks for the SCH burst of OpenBTS A and gets the frame number (FN) and time-slot number (TN) from it - with the help of the GSM Stack Extension module - and synchronize its FN and TN to the master BTS timing.
GSM Stack Extension: This module will instantiate some more objects from the original GSM Stack module to handle L1, L2 and L3 layers for the extra channels mentioned above paragraph to implement the MS mode of operation. GSM Repeater Control: This module shall manage the operation of the repeater through proper initialization and attachment to the master BTS, then it continuously receive L3 messages from both the MS side and the BTS side and react to them in order to fulfill the repeater function as follow: RR Messages: Messages received from the MS side shall be reacted by
assigning the required radio resources locally (SDCCH and TCH), in a way similar to the original OpenBTS code. RR messages from the master BTS side shall be used to extract and assign the SDCCH and TCH of the master BTS side. A table shall be held for the correspondence between the resources allocated to both sides. MM and CM Messages: Messages originating from one side shall be
switched to the other side using the above RR correspondence table. The above way of operation has the advantage of simplified control, but burdens the link between the master and slave with extra local traffic channels. This could be extended later by modifying the alerting CM message to indicate if a call is local to the slave BTS, and modify the TCH assignment to be a local time slot instead of going through the BTSs link. It is worth noting that the all the slave BTS software can be run on a single PC, with 2 USB outlets connected to 2 USRPs, one for each ARFCN. There are also other modifications that should be made in the dial plan of the master ASTERISK, but this should be simple. Another extension that makes use of one USRP can be made by reserving few time slots of ARFCN A for the local traffic of OpenBTS B, and operating the slave BTS at the same ARFCN A at the reserved time slots. This, however, requires fast uplink downlink frequency switching during the burst time. Also, the BTSs link time-slots capacity can also be tripled by using 8-PSK modulation instead of the binary GMSK, as used in EDGE.
The general design approach of OpenBTS is avoid implementing any function above L3, so at L3 or L4 every sub-protocol of GSM is either terminated locally or translated through a gateway to some other protocol for handling by an external application. Similarly, OpenBTS itself does not contain any speech transcoding functions above the L1 FEC parts.
1. In L3, a control function generates an L3 message, serializes the message into an L3 frame and sends it into the logical channel, which in turn passes it down to L2. 2. The L2 processor breaks the L2 frame into segments, wraps each segment in an L2 frame. Each L2 frame is sent down to L1 according to the LAPDm state machine of GSM 04. 06 and ITU-T Q. 921.LAPDm may also generate additional L2 frames on its own according to its acknowledgment and retransmission rules. 3. The L1 FEC processor encodes each L2 frame according to the rules of (GSM 05. 03) generating four outgoing radio bursts. Each radio burst is time tagged with its intended transmission time according to the TDM rules of GSM 05. 02. These bursts are passed on to the TDM interface. 4. The downstream TDM sub- layer is just a mutex-controlled socket interface where the radio bursts from L1 are reformatted into messages on the transceivers datagram interface. 5. Upon arriving in the transceiver, the outgoing radio bursts are sorted into a priority queue according to transmission time. Bursts are pulled from the queue as they become ready for transmission and the modulated according to GSM 05. 04. The modulated waveform samples are sent to the USRP over the standard time tagged USB interface. If no burst is ready for transmission at a given time the transceiver generates an appropriate filling sequence. 6. In the USRP the samples are converted to an analog waveform for transmission over the radio channel.
10
Figure 6: Typical upstream data flow in the GSM air interface of the OpenBTS
Figure 7: Typical downstream data flow in the GSM air interface of the OpenBTS.
11
Figure 8: Components of the OpenBTS application suite and their communication channels as installed in each access point. Sharp-cornered boxes are hardware components. Round-cornered boxes are software components.
12
A thread will be used to make that link between the different flows at slave. To ensure proper functionality for logical control messages, all logical control channels should be bidirectional channels to be able to forward all type of messages and provide smooth flow without errors and without losing any amount of data. Due to that we listed the unidirectional channels and write functions to make the reverse operation. The original bidirectional channels are lifted without modification. The following list shows logical control channels needed modification with a specification for the needed modification.
Table 1: Needed modification on control channels
Logical Channel AGCH NCH PCH RACH FCCH SCH BCCH FACCH TCH SDCCH
Needed modification Decoder Decoder Decoder Encoder Decoder Decoder Decoder ----------
As the implementation of Encoders and Decoders is existed at layer 1, the modified functions and added operations are implemented in two specified files GSML1FEC.cpp and GSML1FEC.h. Depending on GSM concepts, encoding is applied for messages the moves from BTS to MS (Mobile Station) and decoding will be for the reverse direction. The following graph shows the flow of encoding and decoding and the full encoding and decoding steps.
Data
BTS
Interleaving
Encrypted burst
MS
Encoding Path
13
The complete 1. d 2. p 3. u 4. c 5. I 6. e
process to make encoding: data bits. The actual payloads from L2 and the vocoders. parity bits. These are calculated from d. uncoded bits. A concatenation of d, p and inner tail bits. coded bits. These are the convolutionally encoded from u. interleaved bits. These are the output of the interleaver. encrypted bits. These are the channel bits in the radio bursts.
Its necessary to notify that not all logical channels need the full encoding path to be encoded, e.g. RACH encoding and decoding processes d oesnt need interleaving step.
14
Chapter 2:
OpenBTS code
2.1 Introduction
The goal is to implement a totally new mobile station system in the OpenBTS. As OpenBTS hierarchy has been changed and the concept of master and slave OpenBTSs has been added. In the new system, each slave consists of two USRP kits with two OpenBTS codes running simultaneously. The first USRP will act as BTS and the second USRP will act as a mobile station. As mobile station needs different control channels to make time and frequency synchronization with the master BTS, FCCH and SCH control channels are implemented in OpenBTS code to enable it to act as a mobile station. So, an Uplink path has been added to make the signal flow in OpenBTS bidirectional. To achieve that goal, a detecting code for FCCH and SCH has been added at transceiver (Layer 0) and new decoders are added for both control channels at GSM Stack (Layer 1) then receiving SCH in physical layer level to decode it and obtain included information like NCC, BCC and Frame number.
15
2.3.1.3 FCCH Scenario BTS sends FCCH at time slot 0 in BCCH-TRX bursts. All 142 bits of data are filled with zeros. Therere exactly 5 FCCHs per 51 multiframes as in Figure #. FCCH enables MS to identify the frequency of BTS. To make correct synchronization for frequency and time, FCCH should be sent first then SCH. GSM 05.01, 05.02. 2.3.1.4 Requirements Its required to detect FCCH burst and obtain the correct frequency, fix any error in the frequency or any shift happened which may cause wrong reception.
16
2.4.1.3 SCH parameters calculation The BSIC consists of six bits. Three bits of it represent the PLMN color code with a range from 0 to 7, and the other three represent BS color code with a range from 0 to 7. The RFN is 19 bits long and consists of : Tl (11 bits) = FN div (26 x 51) Range from 0 to 2,047 T2 (5 bits) = FN mod (26) Range 0 to 25 T3 (3 bits) = (FN mod (51) - 1) div(l0) Range 0 to 4 Where, FN represents the TDMA frame number. The layout of BSIC and RFN exists within the message part of the synchronization sequence and is shown in Figure 12. SCH, FACCH, and BCCH channels cannot be frequency hopped as these channels carry synchronization and system-related
In the BSIC, the channel exists in the downlink direction only and is used for point-to-multipoint communication.
How?
FCCH and SCH Code
18
Chapter 3: OpenBTS
3.1 Introduction
GSM
CONTROL
REPEATER
IN
This module shall manage the operation of the repeater through proper initialization and attachment to the master BTS, then it continuously receive L3 messages from both the MS side and the BTS side and react to them . The main steps in order to fulfill the repeater functions as follow: RR Messages: Messages received from the MS side shall be reacted by assigning the required radio resources locally (SDCCH and TCH), in a way similar to the original OpenBTS code. RR messages from the master BTS side shall be used to extract and assign the SDCCH and TCH of the master BTS side. A table shall be held for the correspondence between the resources allocated to both sides. MM and CM Messages: Messages originating from one side shall be switched to the other side using the above RR correspondence table. The above way of operation has the advantage of simplified control, but burdens the link between the master and slave with extra local traffic channels. This could be extended later by modifying the alerting CM message to indicate if a call is local to the slave BTS, and modify the TCH assignment to be a local time slot instead of going through the BTSs link. It is worth noting that the all the slave BTS software can be run on a single PC, with 2 USB outlets connected to 2 USRPs, one for each ARFCN. There are also other modifications that should be made in the dial plan of the master ASTERISK, but this should be simple.
19
message to MS side of the Slave BTS to transmit it to Master BTS through air interface UM. In this architecture OpenBTS A operates as a master BTS, with its Asterisks data base covering the other slave BTSs in the service area, and operates at an ARFCN A. OpenBTS B represents one of the slave BTSs, connected to its local MSs at an ARFCN B, and repeating MM and CC signaling messages, as well as some traffic bursts, to OpenBTS A at one or more time slots of ARFCN A. Control is a hybrid module used as interface layer between SIP module and GSM Stack in traditional OpenBTS. Most GSM L3messages and VoIP messages terminate at Control module. Everything in this control directory should be in the Control namespace. Components: 1. Radio Resource: Functions for RR procedures (paging, access grant). 2. Mobility Management: Functions for MM procedures (CM service, location updating). 3. Call Control: Functions for CC (mobile originated, mobile terminated).
20
By using the function parsel3( ) we can detect 1. PD Protocol Discriminator PD ( ) 2. MTI Message Type Identifier MTI ( )
3.3.2 How?
The first task was to find the part in OpenBTS code which forwards L3 messages from GSM Stack and repeats them to the second USRP kit in slave. This USRP kit will act as mobile station and will forward messages to master BTS. The second task is to implement a class to create UDP sockets which used to make time transfer application. Then use UDP sockets to transfer messages between two processes running on same PC. The first process will run the BTS code and the second one will run MS code at slave part.
21
The class should consist of two socket-ports one for receiving and other for transmitting. A thread is used to run the receiving socket independent on code algorithm at anytime. The socket for transmitting the message runs under mutex lock & unlock to avoid failure to bind and to prevent two threads write at the same socket at the same time mutual exclusion. The class has some member functions to allow the start of reception L3Frame thread and sending L3Frame operation. The function that receives the L3Frame from logical channel to make control function on it is found at ControlCommon file named getmessage ( )
3.3.3 Where?
"ControlCommon.h", "ControlCommon.cpp"
3.3.3.1 Added part at ControlCommon.h
/* i4:The additional headers needed to include "thread.h" due to need to ceate "mRepThread" "Sockets.h" due to need to use datagram class for UDP "GSMCommon.h" , "GSMTransfer.h" due to l3frame and Bitvector */ #include #include #include #include "Threads.h" "Sockets.h" "GSMCommon.h" "GSMTransfer.h"
namespace GSM { class class class class class class class class class class class class Time; L3Message; GSMConfig; LogicalChannel; SDCCHLogicalChannel; CCCHLogicalChannel; TCHFACCHLogicalChannel; L3Cause; L3CMServiceRequest; L3LocationUpdatingRequest; L3IMSIDetachIndication; L3PagingResponse;
//i4:added new forward refs used in RepManager class L3Frame; enum Primitive;}; /*i4: This the class responsible for repeation process & Receiving messages from other side "listening" */
22
class RepManager { private: // i4:Two user datagram sockets one for sending "mRepSocketW" // and other for Receiving "mRepSocket" UDPSocket mRepSocket; UDPSocket mRepSocketW; // i4:"mRepThread" is thread for listening operation to listen and receive // at any time message from other side come Thread mRepThread; // i4: "mDataSocketLock" To avoid to be error socket in use and //permit to operation write at same port at same time Mutex mDataSocketLock; public: // i4:Constructor for class to assign the UDP sockets needed for operation RepManager(int Srcport,const char* Desddress, int DesPort); // i4:Function to start thread of listening void start(); // i4:"send" It perform the operation of sending the "l3frame" to other side void send(GSM::L3Frame *l3frame); // i4: "RepHandler" perform the action required inside thread //(asking if any message rcv ) void RepHandler(); friend void* RepLoopAdapter(RepManager*); }; void* RepLoopAdapter(RepManager *repm); // i4:Global object of RepManager class to be availabe to use it's // member functions where i need extern RepManager *grep; } //Control
23
defines
void RepManager::send(L3Frame *l3frame) { char ptr[l3frame->size()] ; for(int i=0;i<(l3frame->size());i++) { if(l3frame->bit(i)){ ptr[i]='1'; } else { ptr[i]='0'; } }
24
break; case RELEASE: ptr[l3frame->size()]='1'; break; case DATA: ptr[l3frame->size()]='2'; break; case UNIT_DATA: ptr[l3frame->size()]='3'; break; case ERROR: ptr[l3frame->size()]='4'; break; case HARDRELEASE:ptr[l3frame->size()]='5'; break; } ptr[l3frame->size()+1]='\0'; mDataSocketLock.lock(); mRepSocketW.write(ptr); mDataSocketLock.unlock(); } /* i4: "RepHandler" the function called inside listening thread which responsible for receiving char* buffer and parse it to extract the (data,primitive) and create l3frame and store them in queue until send RACH request and take channel to send it downstream */ void RepManager::RepHandler() { char buffer[MAX_UDP_LENGTH]; unsigned ra; int msgLen = mRepSocket.read(buffer); cout<< buffer<< endl; if (msgLen<=0) { cout << "read error on REPEATER " << msgLen; return; } // buffer buffer 0's and 1's Primitive Primitivee; BitVector rcv(buffer); BitVector rcv_l3frame; rcv_l3frame=rcv.segment(0,msgLen-2); BitVector rcv_primitive; rcv_primitive=rcv.segment(msgLen-2,1); char *primit=rcv_primitive.begin(); switch(*primit) { case '0':Primitivee=ESTABLISH;break; case '1':Primitivee=RELEASE;break; case '2':Primitivee=DATA;break; case '3':Primitivee=UNIT_DATA;break; case '4':Primitivee=ERROR;break; case '5':Primitivee=HARDRELEASE;break; }
25
L3Frame rcved(rcv_l3frame,Primitivee); if (l3fifo.empty()){ //randam send to l1RACHencoder ra = rand() % 32 + 160 ; //RACHL1Encoder rach(ra); } l3fifo.push(rcved); buffer[msgLen]='\0'; } /* i4:thread function responsible to call "RepHandler" */
26
#include <string> #include <iostream> using namespace std; class RepManager; queue <L3Frame> l3fifo; class RepManager { private: UDPSocket mRepSocket; Thread mRepThread; UDPSocket mRepSocketW; Mutex mDataSocketLock; public: RepManager(int Srcport,const char* Desddress, int DesPort); void start(); void send(L3Frame *l3frame); void RepHandler(); friend void* RepLoopAdapter(RepManager*); }; void* RepLoopAdapter(RepManager *repm); RepManager *grep=new RepManager(7778,"127.0.0.1",8888);
switch(l3frame->primitive()) { case ESTABLISH: ptr[l3frame->size()]='0'; break; case RELEASE: ptr[l3frame->size()]='1'; break; case DATA: ptr[l3frame->size()]='2';
27
break; case UNIT_DATA: ptr[l3frame->size()]='3'; break; case ERROR: ptr[l3frame->size()]='4'; break; case HARDRELEASE:ptr[l3frame->size()]='5'; break; } ptr[l3frame->size()+1]='\0'; mDataSocketLock.lock(); mRepSocketW.write(ptr); mDataSocketLock.unlock(); }
void RepManager::RepHandler() { char buffer[MAX_UDP_LENGTH]; unsigned ra; int msgLen = mRepSocket.read(buffer); cout<< buffer<< endl; if (msgLen<=0) { cout << "read error on REPEATER " << msgLen; return; } // buffer buffer 0's and 1's Primitive Primitivee; BitVector rcv(buffer); BitVector rcv_l3frame; rcv_l3frame=rcv.segment(0,msgLen-2); BitVector rcv_primitive; rcv_primitive=rcv.segment(msgLen-2,1); char *primit=rcv_primitive.begin(); switch(*primit) { case '0':Primitivee=ESTABLISH;break; case '1':Primitivee=RELEASE;break; case '2':Primitivee=DATA;break; case '3':Primitivee=UNIT_DATA;break; case '4':Primitivee=ERROR;break; case '5':Primitivee=HARDRELEASE;break; } L3Frame rcved(rcv_l3frame,Primitivee); if (l3fifo.empty()){//rach ra = rand() % 32 + 160 ; } l3fifo.push(rcved); cout<<ra<<endl; buffer[msgLen]='\0'; } void* RepLoopAdapter(RepManager *repm)
28
#endif
29
int main(){ grep->start(); BitVector v2("00000000000000000011000000000000001111111111111110000000000"); Primitive pri=DATA; L3Frame la(v2,pri); while (1){ grep->send(&la); }; return 0; }
1st terminal: cd Desktop/.... g++ - pthread -o 0 ss0.cpp Sockets.cpp Timeval.cpp BitVector.cpp GSMCommon.cpp 2nd terminal: cd Desktop/.... g++ -pthread -o 1 ss1.cpp Sockets.cpp Timeval.cpp BitVector.cpp GSMCommon.cpp Threads.cpp Threads.cpp
30
Chapter 4:
4.1
4.1.1 Introduction
In a way to produce architecture like the one in GSM, the BTS must be under controlled by the master BTS. It can be done by using the Mobile Station (MS) concept in the slave BTS. The slave BTS can call the master BTS by requesting a channel from the Master BTS. The channel request must be sent by the slave to the master on the RACH, then master assigns a new channel to the slave - if available - and the master informs slave using Access Grant.
4.1.2 How?
It can be done by two directions: It is needed to reverse all functions of the RACH Decoder. It is needed to find the Encoder which takes the same way of the RACH Encoder.
Referring to GSM Standard 05.03 (see below), It is noticed that RACH takes the same way in encoding as Synchronous channel (SCH). The encoding process takes the following steps: Encryption process. Generation of Data bits. Generation of Parity bits. Generation of Data's Tail bits. Convolution Code. Adding Synchronous bits. Adding Tail bits. Transmission of the burst.
31
32
To ensure that an access burst arrives at the BTS during the proper time period the number of bits for the access burst was set to only 88 bits with a larger guard period of 68.2 bits. The maximum distance between BTS and MS is, with this timing, about 35 km. The normal burst would not fit into the receiver window if the unknown propagation delay was greater than zero. That is the reason why the normal burst is used only after the distance of the MS from the BTS is determined, and the MS is able to adjust its transmission accordingly.
33
u(k) = C(k-8) for k = 8,9,...,13 u(k) = 0 for k = 14,15,16,17 (tail bits) The bits {e(0),e(1),..., e(35)} are obtained by the same convolutional code of rate 1/2 as for TCH/FS, defined by the polynomials: G0 = 1 + D3 + D4 G1 = 1 + D + D3 + D4 and with: e(2k) = u(k) + u(k-3) + u(k-4) e(2k+1) = u(k) + u(k-1) + u(k-3) + u(k-4) for k = 0,...,17 ; u(k) = 0 for k < 0
34
4.1.6.2 ESTABLISHMENT CAUSE (octet 1) This information field indicates the reason for requesting the establishment of a connection. This field has a variable length (from 3 bits up to 6 bits). 4.1.6.3 RANDOM REFERENCE (octet 1) This is an unformatted field with variable length (from 5 bits down to 2 bits). The Channel Request message is coded as follows: (Random Reference field is filled with 'x'). For more details, see 04.08.
35
Chapter 5:
Conclusion
36
References
Below are some examples of citations following the IEEE standard: A. B. Author, The paper title, Journal name, vol. 50, no. 12, pp. 27022712, Dec. 2002. C. D. Another, Book title, 2nd ed. New York: Wiley, 1998.
37
Appendix
Insert your appendix (appendices) here. The appendix should be used to provide any useful information, material, or derivations that is relevant to the project but should not be written in the report body in order not to interrupt the flow of the text.
38