== Gb interface using libosmogb

'libosmogb' is part of the libosmocore.git repository and implements the
Gb interface protocol stack consisting of the NS and BSSGP layers.  It
is used in a variety of Osmocom project, including OsmoSGSN,
OsmoGbProxy and OsmoPCU.

This section describes the configuration that libosmogb exposes via the
VTY.

=== Gb interface configuration

==== NS-over-UDP configuration

The GPRS-NS protocol can be encapsulated in UDP/IP.  This is the default
encapsulation for IP based GPRS systems.

.Example: GPRS NS-over-UDP configuration
----
OsmoSGSN(config-ns)# encapsulation udp local-ip 127.0.0.1 <1>
OsmoSGSN(config-ns)# encapsulation udp local-port 23000 <2>
----
The example above configures a libosmogb based application to listen for
incoming connections from PCUs on the specified address and port.

<1> Set the local side IP address for NS-over-UDP
<2> Set the local side UDP port number for NS-over-UDP. 23000 is the default

==== NS-over-FR-GRE configuration

The GPRS-NS protocol can alternatively be encapsulated over Frame Relay
(FR).  Traditionally this is communicated over SDH/PDH media, which we
don't support.  However, we can encapsulate the FR in GRE, and then that
in IP.

The resulting NS-FR-GRE-IP stack can be converted by an off-the-shelf
router with FR and IP support.

.Example: GPRS NS-over-FR-GRE configuration
----
OsmoSGSN(config-ns)# encapsulation framerelay-gre enabled 1 <1>
OsmoSGSN(config-ns)# encapsulation framerelay-gre local-ip 127.0.0.1 <2>
----
<1> Enable FR-GRE encapsulation
<2> Set the local side IP address for NS-over-FR-GRE

==== NS Timer configuration

The NS protocol features a number of configurable timers.

.List of configurable NS timers
|===
|tns-block|(un)blocking timer timeout (secs)
|tns-block-retries|(un)blocking timer; number of retries
|tns-reset|reset timer timeout (secs)
|tns-reset-retries|reset timer; number of retries
|tns-test|test timer timeout (secs)
|tns-alive|alive timer timeout(secs)
|tns-alive-retries|alive timer; number of retries
|===

=== Examining Gb interface status

There are several commands that can help to inspect and analyze the
currently running system status with respect to the Gb interfaces.

.Example: Inspecting NS state
----
OsmoSGSN> show ns
Encapsulation NS-UDP-IP     Local IP: 127.0.0.1, UDP Port: 23000
Encapsulation NS-FR-GRE-IP  Local IP: 0.0.0.0
----

.Example: Inspecting NS statistics
----
OsmoSGSN> show ns stats
Encapsulation NS-UDP-IP     Local IP: 10.9.1.198, UDP Port: 23000
Encapsulation NS-FR-GRE-IP  Local IP: 0.0.0.0
NSEI  101, NS-VC 101, Remote: BSS, ALIVE UNBLOCKED, UDP 10.9.1.119:23000
 NSVC Peer Statistics:
  Packets at NS Level  ( In):     1024 (2/s 123/m 911/h 0/d)
  Packets at NS Level  (Out):     1034 (0/s 151/m 894/h 0/d)
  Bytes at NS Level    ( In):   296638 (1066/s 22222/m 274244/h 0/d)
  Bytes at NS Level    (Out):   139788 (0/s 48225/m 91710/h 0/d)
  NS-VC Block count         :        0 (0/s 0/m 0/h 0/d)
  NS-VC gone dead count     :        0 (0/s 0/m 0/h 0/d)
  NS-VC replaced other count:        0 (0/s 0/m 0/h 0/d)
  NS-VC changed NSEI count  :        0 (0/s 0/m 0/h 0/d)
  NS-VCI was invalid count  :        0 (0/s 0/m 0/h 0/d)
  NSEI was invalid count    :        0 (0/s 0/m 0/h 0/d)
  ALIVE ACK missing count   :        0 (0/s 0/m 0/h 0/d)
  RESET ACK missing count   :        0 (0/s 0/m 0/h 0/d)
 NSVC Peer Statistics:
  ALIVE reponse time        :        0 ms
----

.Example: Inspecting BSSGP state
----
OsmoSGSN> show bssgp
NSEI   101, BVCI     2, RA-ID: 1-2-1-0, CID: 0, STATE: UNBLOCKED
NSEI   101, BVCI     0, RA-ID: 0-0-0-0, CID: 0, STATE: UNBLOCKED
----

FIXME: show nse

=== FIXME

==== Blocking / Unblocking / Resetting NS Virtual Connections

The user can manually perform operations on individual NSVCs:

* blocking a NSVC
* unblocking a NSVC
* resetting a NSVC

The VTY command used for this is the `nsvc (nsei|nsvci) <0-65535>
(block|unblock|reset)` command available from the ENABLE node.


=== Gb interface logging filters

There are some Gb-interface specific filters for the libosmocore
logging subsystem, which can help to reduce the logged output to
messages pertaining to a certain NS or BSSGP connection only.

.Example: enabling a log filter for a given NSEI
----
OsmoSGSN> logging filter nsvc nsei 23
----

.Example: enabling a log filter for a given NSVCI
----
OsmoSGSN> logging filter nsvc nsvci 23
----
