Testing OpenBSC with a FakeBTS

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Sat Oct 27 22:34:29 UTC 2012


On Mon, Oct 22, 2012 at 09:39:30PM +0200, Holger Hans Peter Freyther wrote:
> Hi,

Hi again,

I have updated the packages (so aptitude update, aptitude safe-upgrade) and
I have comitted and attached a simple Location Updating Request.

Start openbsc and roughly do the following:

$ gst LUTest.st
... it will fail because of a LU Reject, authorize the subscriber..
$ gst LUTest.st
... the LU should now succeed.


Some small explanations. First I create a class that inherits the OpenBSCTest
class and create a startTest method (called a selector in Smalltalk). In that
method I connect as a new BTS, then require any channel and send a LURequest
through this new lchan. I am then read/sending messages until the connection
comes to an end.

The Smalltalk syntax is explained here[1], it contains a very short explanation
of the Smalltalk syntax and features.


enjoy
	holger

[1] http://esug.heeg.de/whyusesmalltalktoteachoop/smalltalksyntaxonapostcard/


-------------- next part --------------
"
 (C) 2012 by Holger Hans Peter Freyther
 All Rights Reserved

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
"

PackageLoader fileInPackage: #FakeBTS.

FakeBTS.OpenBSCTest subclass: LUTest [
    <import: OsmoGSM>

    startTest [
        | lchan lu msg |
        "1. Connect to the BTS"
        self createAndConnectBTS: '1801/0/0'. 

        "2. Get a LCHAN"
        lchan := self requireAnyChannel.

        "3. Send the LU request" 
        lu := GSM48LURequest new.
        lu lai
            mcc: 1;
            mnc: 1;
            lac: 1.
        lu mi imsi: '901010000001111'.
        lchan sendGSM: lu toMessage.

        "Now deal with what the NITB wants"
        "4.1 Send the IMEI..."
        msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
        (msg isKindOf: GSM48IdentityReq)
            ifFalse: [^self error: 'Wanted identity request'].
        (msg idType isIMEI)
            ifFalse: [^self error: 'Wanted IMEI reqest'].
        msg := GSM48IdentityResponse new.
        msg mi imei: '6666666666666666'.
        lchan sendGSM: msg toMessage.
        
        "4.2 LU Accept"
        msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
        (msg isKindOf: GSM48LUAccept)
            ifFalse: [^self error: 'LU failed'].
        msg := GSM48TMSIReallocationComplete new.
        lchan sendGSM: msg toMessage.

        "4.3 MM Information for the time. ignore it"
        msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
        (msg isKindOf: GSM48MMInformation)
            ifFalse: [^self error: 'MM Information'].

        "4.4 release.. if we now don't close the LCHAN it will
        remain open for a bit. OpenBSC should and will start the
        approriate timer soon(tm)"
        msg := GSM48MSG decode: lchan nextSapi0Msg readStream.
        (msg isKindOf: GSM48RRChannelRelease)
            ifFalse: [^self error: 'RR Channel Release'].

        "4.5.. be nice... for now and send a disconnect."
        lchan releaseAllSapis.
    ]
]

Eval [
    | test |

    test := LUTest new
                startTest;
                stopBts;
                yourself.
]


More information about the OpenBSC mailing list