Technology

Diameter Gy & Online Charging: How OCS Enables Real-Time Billing

A prepaid subscriber stream’s a video & the moment their balance hits zero, the session stop’s or redirect’s to a top-up page. A postpaid subscriber set’s a monthly spending cap & the network respect’s it down to the last megabyte. Neither experience is possible if the network only count’s usage after the fact. The network has to ask for permission before delivering service.

That is exactly what diameter gy ocs does. Diameter Gy is the interface through which network gateway’s request credit & the Online Charging System (OCS) is the platform that grants, track’s & revoke’s that credit in real time. Together they form the backbone of real-time billing in the 4G/LTE Core Network & remain essential across 3G & 5G. In this article, we explain how Gy work’s, what the OCS does, where the Diameter Routing Agent & Home Subscriber Server fit in & why MVNO’s rely on this architecture.

What Is Diameter Gy?

Diameter Gy is the reference point between the Policy & Charging Enforcement Function (PCEF), typically the P-GW in 4G or the GGSN in 3G & the OCS. It is based on the Diameter Credit Control Application (DCCA) defined in RFC 4006 & profiled by 3GPP for packet-switched charging.

In simple term’s, Gy let’s the gateway say: “This subscriber want’s to use data. How much can I let them have?” The OCS answe’s with a quota & the gateway enforce’s it.

The Core Message Flow

Gy sessions revolve around Credit-Control-Request (CCR) & Credit-Control-Answer (CCA) message’s:

  • CCR-Initial: sent when a data session start’s. The gateway ask’s for an initial quota.
  • CCA-Initial: the OCS check’s the balance, reserve’s credit & return’s the granted unit’s.
  • CCR-Update: sent when the quota is nearly used up, a validity timer expires or a trigger event occurs (such as a change of radio access type or location). The gateway report’s what was consumed & request’s more.
  • CCR-Terminate: sent when the session end’s, reporting final usage so the OCS can release unused credit & finalize the charge.

Key AVPs to Know

Diameter carrie’s data in Attribute-Value Pairs (AVPs). The most important ones in Gy are:

  • Multiple-Services-Credit-Control (MSCC): the container for per-service credit request’s & grant’s.
  • Granted-Service-Unit (GSU): the quota the OCS authorize’s, in volume, time or event’s.
  • Used-Service-Unit (USU): what the subscriber actually consumed since the last report.
  • Rating-Group: identifie’s the type of traffic (for example, general internet, video, or a zero-rated service) so each can be priced differently.
  • Final-Unit-Indication (FUI): tells the gateway that this is the last grant & what to do when it runs out.

Where the Diameter Routing Agent Fits

In a small network, a gateway might connect directly to a single OCS. In a real operator environment, that approach does not scale. TheDiameter Routing Agent (DRA) sits between the gateway’s & the charging platform to handle routing, load balancing, failover & topology hiding.

With a DRA in place, the P-GW does not need to know how many OCS node’s exist or which one hold’s a particular subscriber’s session. It send’s the CCR to the DRA, which route’s it correctly, keep’s session’s sticky to the right node & reroute’s traffic if a node fail’s. For operator’s with multiple gateway’s, multiple OCS instance’s & several vendor’s, the DRA turn’s a tangle of point-to-point link’s into a manageable, resilient signaling layer.

Setting up the connection itself follow’s standard Diameter procedures: peer’s establish a transport connection, exchange capabilitie’s using Capabilities-Exchange-Request & Answer message’s & then monitor link health with Device-Watchdog message’s.

Online vs. Offline Charging

3GPP defines two charging model’s & understanding the difference clarifies why Gy matter’s.

 Online charging (Gy / OCS)Offline charging (Rf / CDF)
TimingReal time, before & during serviceAfter service, based on record’s
Credit controlYes, credit is reserved & enforcedNo, usage is recorded only
OutputBalance updates & quota grant’sCharging Data Record’s (CDRs) for billing
Typical usePrepaid, spend limit’s, real-time bundlesTraditional postpaid billing

Two neighboring interfaces are often confused with Gy. Gx connects the gateway to the policy function (PCRF) & controls policy rule’s such as QoS & traffic steering, not charging. Ro serve’s a similar credit-control role as Gy but for IMS service’s such as voice over LTE. Gy is specifically about charging for packet data session’s.

In practice, many operator’s run both model’s. Prepaid & hybrid subscriber’s use online charging, while offline record’s still feed reporting, reconciliation & postpaid invoicing.

How the OCS Handles Real-Time Charging

The OCS is more than a balance counter. It is a high-performance platform that must respond to each credit request in millisecond’s, because every delay is felt by the subscriber as a slow connection.

Credit Reservation & Quota Management

Rather than granting a subscriber’s entire balance in one go, the OCS hands out credit in small slices. If a subscriber has 500 MB left, the OCS might grant 10 MB at a time. The granted amount is reserved so it cannot be spent twice across simultaneous session’s. When the gateway reports usage & ask’s for more, the OCS deduct’s the actual consumption, releases any unused reservation & issues the next slice.

This approach protect’s the operator from over-consumption while ensuring the subscriber is never charged for credit they did not use.

Rating & Balance Management

Before granting credit, the OCS must work out what the usage cost’s. It applies tariff’s, bundle’s, allowance’s, time-of-day rule’s & promotion’s based on the rating group & the subscriber’s plan. It also manages multiple balance’s at once: a monthly data bundle, a bonus allowance, a main account balance & top-up’s, consumed in a defined priority order.

What Happens When Credit Runs Out

When the balance is nearly exhausted, the OCS includes a Final-Unit-Indication in its answer. This tell’s the gateway what to do once the final grant is used:

  • Terminate: end the session.
  • Redirect: send the subscriber to a top-up or notification page.
  • Restrict access: allow only specific destination’s, such as the operator’s recharge portal.

This is the mechanism behind the familiar “you’ve run out of data” landing page.

OCS & the Home Subscriber Server

The Home Subscriber Server (HSS) & the OCS are often mentioned together, but they have different job’s. The HSS is the master database for subscriber identity in the 4G/LTE Core Network. It stores authentication credential’s, subscription profile’s & service authorization data & it support’s attach, authentication & mobility procedure’s. The OCS, by contrast, owns the money side: balance’s, rating logic & credit control.

In simple term’s, the HSS answer’s “Who is this subscriber & what are they allowed to connect to?” & the OCS answer’s “Can they afford this & how much should we charge?” Both are consulted during a session & keeping their data aligned, especially for provisioning & plan change’s, is a key part of a well-run core network.

Across Network Generations

Charging concept’s stay consistent as network’s evolve, but the element’s change:

  • 3G Core Network: the GGSN act’s as the charging enforcement point & uses Gy toward the OCS for packet data, alongside legacy mechanism’s for circuit-switched voice & SMS.
  • 4G/LTE Core Network: the P-GW take’s over as the PCEF, using Gy for data & Ro for IMS-based service’s. This is where Diameter-based online charging is most widely deployed today.
  • 5G Core Network: the architecture moves to a service-based design. The Session Management Function (SMF) talks to the Charging Function (CHF) over the Nchf interface using HTTP/2 & REST-style APIs instead of Diameter. This is called converged charging & it merge’s online & offline charging into a single service. Concepts like quota grant’s, rating group’s & final-unit handling carry over, which make’s the transition easier for teams already fluent in Gy. Many operator’s run Diameter & 5G charging side by side for years during migration, often with an OCS or converged charging platform supporting both.

Use Case: Real-Time Charging for MVNOs

Mobile Virtual Network Operator’s (MVNOs) do not own radio network’s, but they compete on pricing, flexibility & customer experience. That makes a capable OCS central to their business model. Without real-time charging, an MVNO cannot offer prepaid bundle’s, instant top-up’s, usage alert’s or custom plan’s.

There are two common integration models:

  • Light MVNO or MVNE-hosted: the MVNO uses an enabler’s platform & Gy signaling is handled between the host network & the MVNE’s charging system.
  • Full MVNO: the MVNO runs its own core & charging, connecting to the host network & using a DRA to route Diameter traffic reliably.

Typical MVNO scenarios include:

  • Prepaid bundles & top-ups with real-time balance deduction
  • Roaming & wholesale charging, including inter-operator settlement
  • IoT & enterprise plans with pooled data & per-device limits
  • Rapid plan launches, where new offers can be configured in the OCS without touching the network

For MVNOs, the speed at which they can define & launch a new tariff is a direct competitive advantage & a flexible OCS is what makes that possible.

Common Challenges & Best Practices

Deploying & operating Gy at scale brings recurring challenges. These practices help:

  1. Tune latency & timers. Set the Tx timer & CCR retransmission behavior so that slow answers do not stall session’s & measure end-to-end response times across the gateway, DRA & OCS.
  2. Size quotas carefully. Quotas that are too small create excessive signaling load, while quota’s that are too large risk revenue leakage or overspend. Use validity time to force periodic reporting for long, slow session’s.
  3. Build in redundancy. Use the DRA to route around failed OCS node’s & deploy geographically redundant site’s to avoid a single point of failure.
  4. Define credit-control failure handling. Decide in advance whether the gateway should terminate, continue or retry when the OCS is unreachable. Many operators choose to continue service during short outage’s to protect customer experience, accepting some leakage.
  5. Test & monitor continuously. Use traffic simulation before launch & rely on call tracing & signaling analytic’s in production to spot failed CCR’s, result-code spikes & unusual consumption patterns early.

Conclusion

Real-time billing depend’s on a simple principle: the network ask’s before it deliver’s. Diameter Gy provide’s the language for that conversation & the OCS provide’s the intelligence, tracking balance’s, applying rate’s & enforcing limit’s within millisecond’s. With a Diameter Routing Agent keeping signaling resilient, a Home Subscriber Server managing subscriber identity & a charging model that carrie’s from the 3G Core Network through the 4G/LTE Core Network to the 5G Core Network, operator’s & MVNO’s can deliver accurate, flexible & fair charging to every subscriber.

Understanding diameter gy ocs is a good first step when considering charging system design’s or optimization. If you’re designing or re-designing your charging network, talk to our team about creating the right charging system for your network.

Frequently Asked Questions

Q. What is Diameter Gy used for?

Ans. Diameter Gy is used for online charging of packet data sessions. It lets the P-GW or GGSN request credit from the OCS before allowing subscribers to use data.

Q.What is the difference between Gy & Gx?

Ans. Gy handles charging & credit control, while Gx handles policy control such as QoS & traffic rules. Gy talks to the OCS & Gx talks to the PCRF.

Q.Does 5G still use Diameter Gy?

Ans. Not natively. The 5G Core Network uses the Nchf interface between the SMF & the CHF for converged charging. However, Gy remains widely used in 4G & in networks that are migrating to 5G.

Q.What is the difference between an OCS & a billing system?

Ans. The OCS charges in real time & controls whether service is allowed. A billing system works after the fact, producing invoices & managing customer accounts from usage records.

READ ALSO: Where to Put Your Home EV Charger and How to Power It Safely

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button