> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/smc/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/overview.md).

# Policy Control Overview

## What is Policy Control?

> [!NOTE]
> SMC enforces QoS at the UPF through PFCP Quality Enforcement Rules (QERs). When a charging rule carries a `qosInformation` map, SMC converts the bandwidth AVPs into a PFCP QER and links it to all PDRs for that rule. This allows pre-provisioned or Gx-dynamic rules to enforce per-rule Maximum Bit Rate (MBR) and Guaranteed Bit Rate (GBR) limits. SMC does not negotiate QoS parameters with the UE in GTP signalling.

Policy control governs **how traffic is treated** within the network. It determines:
- Which services or applications users can access
- Traffic detection and metering
- Charging rule installation per service

Policy control is distinct from:
- **AAA** - Identity verification and session tracking (`Who are you? Can you access the network?`)
- **Charging** - Billing data collection and quota management (`How much did you use? Do you have credit?`)

The question policy control answers is: **"How should we handle this user's traffic?"**

References:
- 3GPP TS 29.212 - Policy and Charging Control (PCC) over Gx reference point
- 3GPP TS 29.512 - 5G System; Session Management Policy Control Service (Npcf)
- [AAA Overview](https://docs.cennso.com/components/smc/latest/guides/aaa/overview.md) - Understanding the three concerns

## Policy and Charging Control (PCC) Architecture

3GPP defines the Policy and Charging Control (PCC) architecture, which combines:
1. **Policy rules** - Traffic treatment decisions
2. **Charging instructions** - Which rating group to use for billing

Despite the name "Policy and Charging Control", these are **two distinct concerns**:

### Policy Concern

**Purpose:** Control how traffic flows through the network

**Components:**
- **PCC rules** - Define traffic filters, metering, and charging parameters
- **Application detection** - Identify traffic patterns and apply rules
- **Service authorisation** - Allow or block specific services

**Controlled by:**
- PCRF (Policy and Charging Rules Function) in 4G
- PCF (Policy Control Function) in 5G
- Static provisioning in SMC configuration

**Interfaces:**
- **Gx** - Diameter-based policy control for 4G (TS 29.212)
- **Npcf** - HTTP/2-based policy control for 5G (TS 29.512)

### Charging Concern

**Purpose:** Enable billing for network usage

**Components:**
- **Rating groups** - Billing categories (for example, "video" or "web browsing")
- **Metering method** - How to measure usage (duration, volume, events)
- **Online/offline enablement** - Use real-time quota or generate CDRs
- **Charging triggers** - When to send charging records

**Controlled by:**
- OCS (Online Charging System) via Ro
- OFCS (Offline Charging System) via Rf
- Static provisioning in PCC rules

**Interfaces:**
- **Rf** - Diameter offline charging (CDR generation) (TS 32.299)
- **Ro** - Diameter online charging (credit control) (TS 32.299)

### The Connection

PCC rules **combine both concerns** in a single data structure:

```yaml
aaa:
  applicationDetection:
    rules:
      video-streaming:
        # Policy concern
        type: classic
        precedence: 100
        additionalSDF:
          - "permit out tcp from any to assigned 443"

        # Charging concern
        ratingGroup: 2000  # "Video" billing category
        onlineEnabled: true
        offlineEnabled: true
        meteringMethod: 1  # Volume-based billing
```

This is why they're called "Policy and Charging Control" together - the same rule defines both concerns.

## Policy Control in SMC

SMC implements PCC through multiple mechanisms:

### 1. Static PCC Rules

Pre-configured rules in helm chart configuration. Always applied, never change during session.

```yaml
aaa:
  applicationDetection:
    rules:
      default-rule:
        type: classic
        precedence: 1000
        onlineEnabled: false
        offlineEnabled: true
        ratingGroup: 3000
        additionalSDF:
          - "permit out ip from any to assigned"
```

See [PCC Rules Configuration](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/pcc-rules.md) for details.

### 2. Dynamic PCC Rules via Gx

Rules provided by PCRF during session establishment or modification via Diameter Gx interface.

**Use cases:**
- Subscriber-specific policies based on profile
- Time-of-day policies
- Location-based policies
- Sponsored data (application provider pays)
- Service-based policies (for example, video streaming gets different QoS)

See [Gx Configuration](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/gx.md) for details.

### 3. Predefined Rules via Gx

PCRF references rules by name, actual rule definition is in SMC configuration. Allows PCRF to activate pre-configured rules without sending full rule definition.

```yaml
# Rule defined in SMC
aaa:
  applicationDetection:
    rules:
      premium-video:
        type: classic
        precedence: 50
        onlineEnabled: true
        ratingGroup: 2100

# PCRF sends: "Activate rule premium-video on this session"
```

See [Gx Configuration](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/gx.md) for details.

### 4. Dynamic PCC Rules via Npcf (5G)

In 5G, the PCF provides policies via HTTP/2 using the Npcf_SMPolicyControl service.

> [!CAUTION]
> SMC's Npcf implementation currently supports **predefined rules only**. The PCF can only reference rules defined in SMC configuration, not send fully dynamic rules.

See [Npcf Configuration](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/npcf.md) for details and limitations.

## Static vs Dynamic Rules

### Static Rules

**Characteristics:**
- Defined in helm chart configuration
- Applied to all sessions (or based on simple conditions)
- Cannot change during session lifetime
- Simple to configure and troubleshoot
- No external policy server required

**Use cases:**
- Test and development environments
- Simple deployments without differentiated services
- Default/fallback policies when PCRF/PCF unavailable
- Baseline policies applied to all users

**Advantages:**
- No dependency on external servers
- Predictable behaviour
- Lower latency (no network round-trip)
- Easier troubleshooting

**Disadvantages:**
- Not subscriber-specific
- Cannot adapt to changing conditions
- Requires helm chart update to change policies

### Dynamic Rules

**Characteristics:**
- Provided by PCRF (Gx) or PCF (Npcf) during session
- Can be subscriber-specific or context-specific
- Can be installed, modified, or removed during session lifetime
- Requires integration with policy server

**Use cases:**
- Subscriber-specific QoS based on service tier (gold/silver/bronze)
- Time-of-day policies (cheaper data at night)
- Location-based policies (different QoS for home vs roaming)
- Service-specific policies (video streaming, VoIP, web browsing)
- Sponsored data (application provider payment model)
- Policy changes during active session (upgrade/downgrade)

**Advantages:**
- Highly flexible and adaptive
- Subscriber-specific policies
- Real-time policy changes
- Centralised policy management

**Disadvantages:**
- Dependency on PCRF/PCF availability
- Higher latency for session establishment
- More complex troubleshooting
- Potential for policy server to become bottleneck

### Predefined Rules (Hybrid Approach)

PCRF/PCF references rules by name, but the rule definition is staticin SMC configuration.

**Characteristics:**
- Rule definitions in helm chart (like static)
- Rule activation/deactivation by PCRF/PCF (like dynamic)
- PCRF/PCF decides **which** rules to apply, SMC defines **what** those rules do

**Use cases:**
- Limited set of standard policy profiles (for example, "premium", "standard", or "basic")
- Reduce message size on Gx/Npcf interfaces
- Simplify PCRF/PCF logic (reference by name instead of full rule)
- Balance flexibility and simplicity

**Advantages:**
- Smaller Gx/Npcf messages (rule names instead of full rules)
- PCRF/PCF controls which rules apply without knowing all details
- Easier to version control and audit rule definitions
- Reduced PCRF/PCF complexity

**Disadvantages:**
- Still requires helm chart update to modify rule content
- PCRF/PCF must know available rule names
- Less flexible than fully dynamic rules

## Policy Control vs Charging

It's crucial to understand the distinction, even though PCC rules contain both:

| Concern | Question | Configuration | Runtime Control |
|---|---|---|---|
| **Policy** | How to handle traffic? | Traffic filters, metering, rule selection | PCRF/PCF or static config |
| **Charging** | How to bill usage? | Rating groups, metering method | OCS (Ro) or OFCS (Rf) |

**Example scenario:**

```yaml
aaa:
  applicationDetection:
    rules:
      video-streaming:
        type: classic
        precedence: 100       # Policy: match before lower-priority rules
        additionalSDF:
          - "permit out tcp from any to assigned 443"

        ratingGroup: 2000     # Charging: bill as "video"
        onlineEnabled: true   # Charging: check quota with OCS
        meteringMethod: 1     # Charging: bill by volume
```

**Policy perspective:** "This traffic matches the video-streaming rule and is accounted separately."

**Charging perspective:** "This traffic is billed as rating group 2000 with online charging enabled."

The PCRF/PCF controls **which rules apply**. The OCS controls the **charging** (quota, credit). They're separate systems with separate concerns, connected via PCC rules.

## Documentation Structure

Follow this order to understand policy control in SMC:

1. **[PCC Rules Configuration](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/pcc-rules.md)** - Rule structure, parameters, types
2. **[Gx Interface](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/gx.md)** - 4G policy control with Diameter
3. **[Npcf Interface](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/npcf.md)** - 5G policy control with HTTP/2

For charging configuration, see:
- [Charging Overview](https://docs.cennso.com/components/smc/latest/guides/aaa/charging/overview.md)
- [Rf Offline Charging](https://docs.cennso.com/components/smc/latest/guides/aaa/charging/rf.md)
- [Ro Online Charging](https://docs.cennso.com/components/smc/latest/guides/aaa/charging/ro.md)

## Common Deployment Patterns

### Pattern 1: Fully Static

No external policy server, all rules in configuration.

```yaml
aaa:
  # No gx or npcf configuration

  applicationDetection:
    rules:
      default:
        type: classic
        precedence: 1000
        onlineEnabled: false
        offlineEnabled: true
        ratingGroup: 1000
        additionalSDF:
          - "permit out ip from any to assigned"
```

**Use case:** Simple deployments, test environments, no differentiated services.

### Pattern 2: Static Rules + Gx Control

Rules defined statically, Gx controls which rules apply per subscriber.

```yaml
aaa:
  gx:
    enabled: true
    standalone: false
  
  oss:
    destinations:
      - addr: "pcrf.example.com"
        port: 3868
    destinationRealm: "pcrf.example.com"
  
  applicationDetection:
    rules:
      premium:
        type: classic
        precedence: 50
        onlineEnabled: true
        ratingGroup: 1000
      standard:
        type: classic
        precedence: 100
        onlineEnabled: true
        ratingGroup: 2000
```

PCRF sends: `Charging-Rule-Name` AVP with "premium" or "standard" based on subscriber profile.

**Use case:** Tiered service offerings with pre-defined policies.

### Pattern 3: Fully Dynamic Gx

PCRF sends full rule definitions dynamically.

```yaml
aaa:
  gx:
    enabled: true
    standalone: false
  
  oss:
    destinations:
      - addr: "pcrf.example.com"
        port: 3868
    destinationRealm: "pcrf.example.com"
  
  # Minimal or no pre-defined rules
  applicationDetection:
    rules:
      fallback:
        type: classic
        precedence: 10000  # Lowest priority
        offlineEnabled: true
        ratingGroup: 9999
```

PCRF sends: `Charging-Rule-Install` AVP with full rule definition (`Charging-Rule-Definition`).

**Use case:** Highly dynamic policies, subscriber-specific bandwidth, application-specific QoS.

### Pattern 4: 5G with Npcf Predefined Rules

5G policy control using PCF with predefined rules (current SMC capability).

```yaml
aaa:
  npcf:
    enabled: true
    URI: "http://pcf.example.com:8080/npcf-smpolicycontrol/v1/sm-policies"
    timeout: 2000

  applicationDetection:
    rules:
      default-rule:
        type: classic
        precedence: 1000
        onlineEnabled: false
        offlineEnabled: true
        ratingGroup: 3000
      premium-rule:
        type: classic
        precedence: 500
        onlineEnabled: true
        ratingGroup: 1000
```

PCF activates predefined rules by `pccRuleId` matching a rule name in `applicationDetection.rules` during session establishment.

**Use case:** 5G SA networks with limited PCF integration.

## Troubleshooting Policy

### No Policy Rules Applied

**Symptom:** Sessions established but no policy rules visible in metrics or logs.

**Possible causes:**
- No static rules configured
- Gx/Npcf not enabled or not connected
- PCRF/PCF not sending rules

**Solution:**

1. Verify static rules exist in configuration
2. Check Gx/Npcf connectivity
3. Review PCRF/PCF logs for policy provision errors
4. Check SMC logs for policy installation messages

### Wrong Rule Applied

**Symptom:** Traffic matching the wrong rule, unexpected charging behaviour.

**Possible causes:**
- Rule precedence conflict (higher-priority rule matching first)
- PCRF/PCF sending different rule name than expected
- Static rule SDF not matching traffic

**Solution:**

1. Check rule precedence (lower number = higher priority)
2. Review rule SDF filters (`additionalSDF`)
3. Verify PCRF/PCF provisioning logs

## Related Documentation

- [AAA Overview](https://docs.cennso.com/components/smc/latest/guides/aaa/overview.md) - Understanding AAA vs Policy vs Charging
- [PCC Rules Configuration](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/pcc-rules.md) - Rule structure and parameters
- [Gx Interface](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/gx.md) - 4G Diameter policy control
- [Npcf Interface](https://docs.cennso.com/components/smc/latest/guides/aaa/policy/npcf.md) - 5G HTTP/2 policy control
- [Charging Overview](https://docs.cennso.com/components/smc/latest/guides/aaa/charging/overview.md) - Charging concepts
- [Diameter Concepts](https://docs.cennso.com/components/smc/latest/guides/aaa/diameter-concepts.md) - Generic Diameter transport
