== Overview

=== About OsmoPCU

OsmoPCU is the Osmocom implementation of the GPRS PCU (Packet Control Unit)
element inside the GPRS network. Depending on the BTS type the PCU will be
co-located within the BTS or run in co-location with the BSC.

[[pcu_co_located_with_bts]]
==== OsmoPCU in co-location with OsmoBTS

In most OsmoPCU-supported base stations, the PCU is co-located with the BTS.
In this scenario OsmoPCU and OsmoBTS run on the same host system. Both are
interconnected using a unix domain socket based interface.
(see also: <<pcu_sock_iface>>)

[[fig-gprs-pcubts]]
.GPRS network architecture with PCU in BTS
[graphviz]
----
digraph G {
	rankdir=LR;
	MS0 [label="MS"]
	MS1 [label="MS"]
	MS0->BTS [label="Um"]
	MS1->BTS [label="Um"]
	BTS->BSC [label="Abis"]
	BSC->MSC [label="A"]
	BTS->PCU [label="pcu_sock"]
	PCU->SGSN [label="Gb"]
	SGSN->GGSN [label="GTP"]
	PCU [color=red]
	{ rank=same BTS PCU }
}
----

NOTE: Depending on the hardware architecture, OsmoPCU may also have direct
access on the PHY interface to exchange PDCH traffic efficiently. The socket
interface is then only used for signalling.

==== OsmoPCU in co-location with OsmoBSC

Classic E1 based BTSs usually do not include a PCU. Instead those base stations
typically rely on an external PCU that is co-located with the BSC. The
signalling traffic (paging, channel assignments ect.) is then exchanged with the
BTS via RSL, while the PDCH traffic is handled by the PCU through a dedicated
TRAU frame based E1 connection.

OsmoPCU supports this scenario as well. Due to the dedicated E1 connection, the
implementation is complex and strongly hardware specific. As of now (March 2023)
OsmoPCU supports Ericsson RBS2000/RBS6000 only. This implementation has been
made possible through funding by the NLnet Foundation.

[[fig-gprs-pcubts]]
.GPRS network architecture with PCU in BTS
[graphviz]
----
digraph G {
	rankdir=LR;
	MS0 [label="MS"]
	MS1 [label="MS"]
	MS0->BTS [label="Um"]
	MS1->BTS [label="Um"]
	BTS->BSC [label="Abis"]
	BSC->MSC [label="A"]
	BTS->PCU [label="pcu_sock"]
	PCU->SGSN [label="Gb"]
	SGSN->GGSN [label="GTP"]
	PCU [color=red]
	{ rank=same BTS PCU }
}
----

When OsmoPCU runs in co-location to OsmoBSC, both are connected through the
same unix domain socket interface as mentioned above.
(see also: <<pcu_co_located_with_bts>>) The socket is used to pass signalling
traffic between PCU and BSC while the PCU controls the PDCH by directly talking
to the BTS CCU (channel coding unit) through a dedicated E1 connection. The
E1 line interface uses TRAU frames and is vastly comparable to the interface that
is used when speech is transferred.

Since the PCU is mainly set up by OsmoBSC (or OsmoBTS) via the PCU socket, the
configuration in the BSC co-located scenario is no different from the BTS
co-located scenario. However, since the PCU requires a direct E1 connection to
the BTS an E1 line must be set up. (See also: <<cfg_e1_line>>)

=== Software Components

OsmoPCU consists of a variety of components, including

* Gb interface (NS/BSSGP protocol)
* `pcu_sock` interface towards OsmoBTS (or OsmoBSC)
* TBF management for uplink and downlink TBF
* RLC/MAC protocol implementation
* per-MS context for each MS currently served
* CSN.1 encoding/decoding routines

==== Gb Implementation

OsmoPCU implements the ETSI/3GPP specified Gb interface, including TS
08.16 (NS), TS 08.18 (BSSGP) protocols. As transport layer for NS, it
supports NS/IP (NS encapsulated in UDP/IP).

The actual Gb Implementation is part of the libosmogb library, which is
in turn part of the libosmocore software package.  This allows the same
Gb implementation to be used from OsmoPCU, OsmoGbProxy as well as
OsmoSGSN.

The Gb Implementation supports two different dialects:

* `classic` dialect, which implements a non-standard dialect from the days
  where Frame Relay was the default and no IP transport had yet been
  specified by 3GPP.
* `ip-sns` dialect, which implements the 3GPP standard for NS-over-IP,
  including the IP-SNS protocol.

In case of doubt, and assuming you are directly interfacing to a
modern 3rd party SGSN, use the `ip-sns` dialect.

Selection of the dialect is done using the `gb-dialect` VTY option at the `pcu` node.

[[pcu_sock_iface]]
==== `pcu_sock` Interface to OsmoBTS/OsmoBSC

The interface towards OsmoBTS/OsmoBSC is called 'pcu_sock' and implemented
as a set of non-standardized primitives over a unix domain socket. The
default file system path for this socket is `/tmp/pcu_bts`.

The PCU socket path can be freely configured to a different file/path name,
primarily to permit running multiple independent BTS+PCU (or BSC+PCU) pairs
on a single Linux machine without having to use filesystem namespaces or other
complex configurations.

NOTE: If you change the PCU socket path on OsmoBTS/OsmoBSC by means of the
`pcu-socket` VTY configuration command, you must ensure to make the
identical change on the OsmoPCU side.
