RFC 5189

Middlebox Communication (MIDCOM) Protocol Semantics

๐Ÿ“… published March 2008, from ietf

RFC 5189: Middlebox Communication (MIDCOM) Protocol Semantics ๐Ÿฆ‹

Okay bestie, let's get into it! ๐Ÿ’– This is RFC 5189, and it's giving standards-track main character energy ๐Ÿ‘‘

  • Network Working Group ๐ŸŒธ
  • Number: RFC 5189
  • Title: Middlebox Communication (MIDCOM) Protocol Semantics
  • Authors: M. Stiemerling (NEC), J. Quittek (NEC), T. Taylor (Nortel)
  • Category: Standards Track โœจ
  • Date: March 2008 ๐Ÿ—“๏ธ
  • Obsoletes: RFC 3989 ๐Ÿ’€

Status of This Memo ๐Ÿ“œ

So this document is an Internet standards track protocol spec for the whole Internet community, and it literally asks people to talk about it and suggest improvements ๐Ÿซถ Check the current edition of "Internet Official Protocol Standards" (STD 1) for the standardization state and status of this protocol. And the distribution of this memo is unlimited, so share it with everyone ๐ŸŒˆ

Abstract ๐Ÿฆ‹

Okay so this doc lays out the semantics for a Middlebox Communication (MIDCOM) protocol. MIDCOM agents use it to talk to middleboxes like firewalls and Network Address Translators (NATs) ๐Ÿ”ฅ Now, the semantics bit doesn't pin down a concrete syntax or a transport protocol, so it's not the full recipe. But a real protocol is expected to implement these semantics or, more likely, a superset of them ๐Ÿ’œ The MIDCOM protocol semantics come from the MIDCOM requirements, the MIDCOM framework, and working group decisions. And yes, this document obsoletes RFC 3989 ๐Ÿ’…

Table of Contents ๐Ÿงš

   1. Introduction ....................................................4
      1.1. Terminology ................................................5
      1.2. Transaction Definition Template ............................7
   2. Semantics Specification .........................................8
      2.1. General Protocol Design ....................................8
           2.1.1. Protocol Transactions ...............................8
           2.1.2. Message Types .......................................9
           2.1.3. Session, Policy Rule, and Policy Rule Group ........10
           2.1.4. Atomicity ..........................................11
           2.1.5. Access Control .....................................11
           2.1.6. Middlebox Capabilities .............................12
           2.1.7. Agent and Middlebox Identifiers ....................12
           2.1.8. Conformance ........................................13
      2.2. Session Control Transactions ..............................13
           2.2.1. Session Establishment (SE) .........................14
           2.2.2. Session Termination (ST) ...........................16
           2.2.3. Asynchronous Session Termination (AST) .............16
           2.2.4. Session Termination by Interruption of Connection ..17
           2.2.5. Session State Machine ..............................17
      2.3. Policy Rule Transactions ..................................18
           2.3.1. Configuration Transactions .........................19
           2.3.2. Establishing Policy Rules ..........................19
           2.3.3. Maintaining Policy Rules and Policy Rule Groups ....20
           2.3.4. Policy Events and Asynchronous Notifications .......21
           2.3.5. Address Tuples .....................................21
           2.3.6. Address Parameter Constraints ......................23
           2.3.7. Interface-Specific Policy Rules ....................25
           2.3.8. Policy Reserve Rule (PRR) ..........................25
           2.3.9. Policy Enable Rule (PER) ...........................30
           2.3.10. Policy Rule Lifetime Change (RLC) .................36
           2.3.11. Policy Rule List (PRL) ............................38
           2.3.12. Policy Rule Status (PRS) ..........................39
           2.3.13. Asynchronous Policy Rule Event (ARE) ..............41
           2.3.14. Policy Rule State Machine .........................42
      2.4. Policy Rule Group Transactions ............................43
           2.4.1. Overview ...........................................43
           2.4.2. Group Lifetime Change (GLC) ........................44
           2.4.3. Group List (GL) ....................................46
           2.4.4. Group Status (GS) ..................................47
   3. Conformance Statements .........................................48
      3.1. General Implementation Conformance ........................49
      3.2. Middlebox Conformance .....................................50
      3.3. Agent Conformance .........................................50
   4. Transaction Usage Examples .....................................50
      4.1. Exploring Policy Rules and Policy Rule Groups .............50
      4.2. Enabling a SIP-Signaled Call ..............................54

   5. Compliance with MIDCOM Requirements ............................59
      5.1. Protocol Machinery Requirements ...........................59
           5.1.1. Authorized Association .............................59
           5.1.2. Agent Connects to Multiple Middleboxes .............60
           5.1.3. Multiple Agents Connect to Same Middlebox ..........60
           5.1.4. Deterministic Behavior .............................60
           5.1.5. Known and Stable State .............................60
           5.1.6. Status Report ......................................61
           5.1.7. Unsolicited Messages (Asynchronous Notifications) ..61
           5.1.8. Mutual Authentication ..............................61
           5.1.9. Session Termination by Any Party ...................61
           5.1.10. Request Result ....................................62
           5.1.11. Version Interworking ..............................62
           5.1.12. Deterministic Handling of Overlapping Rules .......62
      5.2. Protocol Semantics Requirements ...........................62
           5.2.1. Extensible Syntax and Semantics ....................62
           5.2.2. Policy Rules for Different Types of Middleboxes ....63
           5.2.3. Ruleset Groups .....................................63
           5.2.4. Policy Rule Lifetime Extension .....................63
           5.2.5. Robust Failure Modes ...............................63
           5.2.6. Failure Reasons ....................................63
           5.2.7. Multiple Agents Manipulating Same Policy Rule ......63
           5.2.8. Carrying Filtering Rules ...........................64
           5.2.9. Parity of Port Numbers .............................64
           5.2.10. Consecutive Range of Port Numbers .................64
           5.2.11. Contradicting Overlapping Policy Rules ............64
      5.3. Security Requirements .....................................64
           5.3.1. Authentication, Confidentiality, Integrity .........64
           5.3.2. Optional Confidentiality of Control Messages .......64
           5.3.3. Operation across Untrusted Domains .................65
           5.3.4. Mitigate Replay Attacks ............................65
   6. Security Considerations ........................................65
   7. IAB Considerations on UNSAF ....................................66
   8. Acknowledgements ...............................................66
   9. References .....................................................67
      9.1. Normative References ......................................67
      9.2. Informative References ....................................67
   Appendix A. Changes from RFC 3989 .................................69

1. Introduction ๐Ÿ’–

So the MIDCOM working group already came up with a framework [MDC-FRM] and a list of requirements [MDC-REQ] for middlebox communication ๐ŸŽ€ The next step toward an actual MIDCOM protocol is writing down protocol semantics. These are constrained by those two docs, but not completely spelled out by them, so there's some room to decide things ๐Ÿงš

This memo proposes semantics for the MIDCOM protocol, and it's fully compliant with the requirements in [MDC-REQ] and with the working group's consensus on semantic issues โœจ This document obsoletes RFC 3989 [MDC-SEM], so if you're still on that one, it's time to upgrade bestie ๐Ÿ’…

Following the working group charter, the semantics are aimed at packet filters and Network Address Translators (NATs) ๐Ÿ”ฅ They support applications that need dynamic configuration of these middleboxes ๐ŸŒˆ

The semantics are defined in terms of transactions. There are two basic types: request transactions and asynchronous transactions. Then there are two concrete kinds of request transactions: configuration transactions and monitoring transactions ๐Ÿฆ‹

For each transaction, the semantics are specified by describing: (1) the parameters of the transaction; (2) how request messages get processed at the middlebox; (3) the state transitions at the middlebox caused by request transactions, or indicated by asynchronous transactions, respectively; and (4) the reply and notification messages the middlebox sends to the agent to tell it about the state change ๐Ÿ“ฌ It's giving very organized, very intentional ๐Ÿ’œ

The semantics can be implemented by any protocol that supports these two transaction types and is flexible enough about transaction parameters ๐Ÿซถ Different protocols might need to extend the semantics below. They might add more transactions, add more parameters to transactions, or split a single transaction into a set of transactions โญ No matter what extensions get added, the semantics below give the minimum necessary subset of what must be implemented ๐Ÿ“

Here's how the rest of this doc is laid out ๐Ÿ—บ๏ธ Section 2 describes the protocol semantics, and it's split into four subsections:

  • General Protocol Design (section 2.1)
  • Session Control (section 2.2)
  • Policy Rules (section 2.3)
  • Policy Rule Groups (section 2.4)

Section 3 has the conformance statements for MIDCOM protocol definitions and MIDCOM protocol implementations, with respect to the semantics defined in section 2 ๐ŸŒธ Section 4 gives two elaborated usage examples ๐Ÿงš And finally, section 5 explains how the semantics meet the MIDCOM requirements ๐Ÿ‘‘ Let's keep going!! ๐Ÿ’…โœจ

1.1. Terminology ๐ŸŽ€

Okay so this memo borrows its definitions from the framework [MDC-FRM] and requirements [MDC-REQ] docs, which is very neat of it ๐Ÿ’…. On top of that, there are a few extra terms you need to know:

  • request transaction ๐Ÿฆ‹: a request transaction is a whole little journey. The agent sends a request message to the middlebox, the middlebox processes it, a reply message comes back from the middlebox to the agent, and optionally, notification messages get sent from the middlebox to agents other than the one who asked. A request transaction might cause a state transition at the middlebox.
  • configuration transaction ๐Ÿ› ๏ธ: this is a request transaction that asks for a state change in the middlebox. If it's accepted, it causes a state change at the middlebox.
  • monitoring transaction ๐Ÿ‘€: this is a request transaction that asks for state information from the middlebox. It does not cause a state transition at the middlebox.
  • asynchronous transaction โšก: this one isn't triggered by an agent at all. It can happen without any agent taking part in a session with the middlebox. Potentially, it includes notification messages going from the middlebox to agents that are in an open session. A notification message gets sent to each agent that needs to hear about the asynchronous event, and the message shows the state transition at the middlebox.
  • agent-unique ๐Ÿงฉ: an agent-unique value is unique within the agent's context, and that context covers all the MIDCOM sessions the agent is part of. The agent is the one who assigns it.
  • middlebox-unique ๐Ÿงฉ: a middlebox-unique value is unique within the middlebox's context, which covers all the MIDCOM sessions the middlebox is part of. The middlebox is the one who assigns it.
  • policy rule ๐Ÿ“œ: in general, a policy rule is "a basic building block of a policy-based system. It is the binding of a set of actions to a set of conditions -- where the conditions are evaluated to determine whether the actions are performed" [RFC3198]. In the MIDCOM world, the condition is a specification of a set of packets that the rules get applied to. Each rule's set of actions always has just one element, and that element is either action "reserve" or action "enable".
  • policy reserve rule ๐ŸŒท: a policy rule with a reserve action. Its policy condition is always true. The action reserves either just an IP address, or an IP address plus a range of port numbers, on neither side, one side, or both sides of the middlebox, depending on how the middlebox is configured.
  • policy enable rule ๐Ÿšช: a policy rule with an enable action. Its policy condition is a descriptor of one or more unidirectional or bidirectional packet flows, and the policy action lets packets belonging to that flow traverse the middlebox. The descriptor identifies the protocol, the flow direction, and the source and destination addresses, optionally with a range of port numbers.
  • NAT binding ๐ŸŒ‰: okay, this one's a bit sneaky ๐Ÿ™ˆ. The term NAT binding as used in this document does not necessarily mean a NAT bind as defined in [NAT-TERM]. In MIDCOM semantics, a NAT binding is an abstraction that lets two endpoints communicate through the NAT-type middlebox. An enable action may result in a NAT bind or a NAT session, depending on the request and its parameters.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119]. ๐Ÿซถ

1.2. Transaction Definition Template ๐ŸŒธ

Here's the deal: the semantics of the MIDCOM protocol get specified per transaction, section by section. Each transaction specification has the entries below. Parameter entries, failure reason, and notification message type only show up if they actually apply ๐Ÿ’–.

  • transaction-name: a descriptive name for this type of transaction.
  • transaction-type: the transaction type is either 'configuration', 'monitoring', or 'asynchronous'. See section 1.1 for what each transaction type means.
  • transaction-compliance: this entry says either 'mandatory' or 'optional'. For the details, see section 2.1.8.
  • request-parameters: this entry lists every parameter needed for the request, with a description of each one.
  • reply-parameters (success): this entry lists all the parameters that get sent back from the middlebox to the agent as a positive response to the earlier request, with a description of each one.
  • failure reason: every negative reply has two parameters: a request identifier that says which request the reply is for, and a parameter that gives the failure reason. These two are compulsory, so the template doesn't list them. What the template does have is a list of possible failure reasons the second parameter might show. That list is not exhaustive, and a concrete protocol specification may extend it โœจ.
  • notification message type: this entry describes the notification message type that the transaction may use.
  • semantics: this entry describes what the transaction actually means. In particular, it covers how the middlebox processes the request message, and which middlebox state transitions the transaction causes or is caused by.

2. Semantics Specification ๐Ÿ’…

2.1. General Protocol Design ๐ŸŽ€

The semantics specification is all about finding a balance ๐Ÿง . It wants to properly support applications that need dynamic configuration of middleboxes, and it also wants the protocol to stay simple to specify and implement.

Protocol interactions are organised into transactions. The state of a middlebox is described by state machines, and those state machines are made of states and state transitions. One transaction may cause, or be caused by, state transitions in more than one state machine. But for each state machine, there is no more than one transition per transaction ๐Ÿฆ‹.

2.1.1. Protocol Transactions โœจ

State transitions get kicked off in one of two ways: either by a request message from the agent to the middlebox, or by some other event at the middlebox. In the first case, the middlebox tells the agent about the state transition by sending a reply message. In the second case, the middlebox sends an unsolicited asynchronous notification message to each agent affected by the transaction, as long as that agent is taking part in an open session with the middlebox ๐Ÿ“จ.

Request and reply messages both carry an agent-unique request identifier. That's how the agent figures out which sent request a received reply belongs to ๐Ÿ”.

An analysis of the requirements showed that three kinds of transactions are required:

  • Configuration transactions, which let the agent request state transitions at the middlebox ๐Ÿ› ๏ธ.
  • Asynchronous transactions, which let the middlebox report state changes that the agent did not ask for โšก.
  • Monitoring transactions, which let the agent request state information from the middlebox ๐Ÿ‘€.

Configuration transactions and asynchronous transactions provide the basic MIDCOM protocol functionality ๐ŸŒˆ. They're tied to middlebox state transitions, and they cover setting up and tearing down MIDCOM sessions and policy rules.

Monitoring transactions aren't tied to middlebox state transitions at all. Agents use them to look at the number, status, and properties of the policy rules that have been set up at the middlebox ๐Ÿ”ญ.

As specified in detail in section 3, configuration transactions and asynchronous transactions are mandatory except of the Group Lifetime Change (GLC). They must be implemented by a compliant middlebox ๐Ÿงš. The GLC transaction and some of the monitoring transactions are optional ๐Ÿ’œ.

2.1.2. Message Types

okay so MIDCOM has three flavours of message: requests, replies, and notifications ๐Ÿฆ‹ and each flavour comes in different types. the semantics doc only pins a message type down by its list of parameters. the order of those params and how they're encoded is up to whatever concrete protocol gets written later ๐Ÿ’… a protocol is also allowed to tack on extra params or mash several together, as long as all the info from the semantics is still in there somewhere โœจ

for requests and positive replies, you get one message type per request transaction. each reply transaction defines its parameter list (for the request and the successful reply) using the transaction definition template from section 1.2 ๐ŸŽ€

if a request fails, the middlebox sends a negative reply back to the agent ๐Ÿฅบ it's the same for every request transaction: it carries the request identifier so the agent knows which request it's answering, plus a parameter saying why it failed ๐Ÿ’€

there are three notification types: the Session Termination Notification (STN), the Policy Rule Event Notification (REN), and the Group Event Notification (GEN). every one of them carries a middlebox-unique notification identifier ๐ŸŒธ

STN the Session Termination Notification has that identifier plus one parameter giving the reason the middlebox ended the session ๐Ÿงš

REN the Policy Rule Event Notification has the notification identifier, a policy rule identifier, and the remaining policy lifetime ๐Ÿ’œ

GEN the Group Event Notification has the notification identifier, a policy rule group identifier, and the remaining policy rule group lifetime ๐Ÿซถ


2.1.3. Session, Policy Rule, and Policy Rule Group

all transactions sort into three buckets: ones about sessions, ones about policy rules, and ones about policy rule groups ๐ŸŒˆ rule groups are handy for showing how rules relate to each other, and for simplifying things because you can do one transaction per group instead of one per rule ๐Ÿ“

sessions and policy rules are stateful at the middlebox ๐Ÿ˜ญ their states don't depend on each other, so their state machines (one per session, one per policy rule) can be kept separate ๐Ÿฆ‹ rule groups are stateful too, but the middlebox doesn't have to store any state for them, since the group's state is implicitly defined by the states of all the rules in it (see section 2.4) โœจ

splitting session state from policy rule state keeps the semantics spec simple and makes implementation easier too, so that's how it's structured, with two separate state machines to illustrate things ๐Ÿ’– real protocol state machines will probably be more complex than the ones here, but they're expected to be a superset of the semantics state machines in this document ๐Ÿ’…


2.1.4. Atomicity

all request transactions are atomic with respect to each other ๐Ÿ”ฅ that means the middlebox never interrupts processing of one request to handle another request that's arriving or already queued ๐Ÿ˜ค this holds even when requests come in from different sessions at the same time ๐Ÿ‘‘ asynchronous transactions are the exception, though: they can interrupt and/or terminate processing of a request at any time ๐Ÿ’€

from the agent's point of view, all request transactions are atomic too ๐ŸŽ€ the middlebox doesn't start processing a request until the whole request has arrived ๐Ÿซถ no intermediate state is stable at the middlebox, and no intermediate state gets reported to any agent ๐Ÿ™ˆ

the number of transactions in this document is pretty small, because we cut it down to a minimal set that still meets the requirements ๐ŸŒธ a real implementation might need to split some of the transactions below into two or more transactions of the protocol, for reasons like protocol constraints or wanting more flexibility ๐Ÿงš that's generally fine, but keep in mind it might change the atomicity of the affected transactions โญ


2.1.5. Access Control

ownership decides who gets access to policy rules and policy rule groups ๐Ÿ”‘ when a rule is created, it gets a middlebox-unique identifier for use in later transactions ๐Ÿชช on top of that, every rule has an owner, which is the authenticated agent that set it up ๐Ÿ‘‘ the middlebox uses the owner attribute to control access: whenever an authenticated agent wants to modify an existing rule, the middlebox checks who owns it and whether the requesting agent is allowed to act on that owning agent's rules ๐Ÿ’…

all rules in the same rule group must have the same owner ๐Ÿซถ so an agent either has access to every member of a group or to none of them ๐Ÿฆ‹

the middlebox can be configured to let specific authenticated agents access and modify rules with certain owners ๐ŸŒˆ a sensible default is letting each agent access its own rules ๐Ÿ’– it might also be nice to set up an agent identity as an administrator that can modify all rules owned by any agent ๐Ÿ‘‘ configuring authorization at the middlebox, though, is outside the scope of the MIDCOM semantics and protocol ๐Ÿ™ˆ


2.1.6. Middlebox Capabilities

at session setup it's really useful for the agent to learn what the middlebox can do ๐Ÿงš so the session establishment procedure in section 2.2.1 includes sending capability info from the middlebox to the agent โœจ the capabilities covered are:

  • Support of firewall function
  • List of supported NAT functions, perhaps including
    • address translation
    • port translation
    • protocol translation
    • twice-NAT
  • Internal IP address wildcard support
  • External IP address wildcard support
  • Port wildcard support
  • Supported IP version(s) for internal network: IPv4, IPv6, or both
  • Supported IP version(s) for external network: IPv4, IPv6, or both
  • List of supported optional MIDCOM protocol transactions
  • Support for interface-specific policy rules
  • Policy rule persistence: persistent or non-persistent (a rule is persistent when the middlebox can save the rule to a non- volatile memory, e.g., a hard disk or flash memory)
  • Maximum remaining lifetime of a policy rule or policy rule group
  • Idle-timeout of policy rules in the middlebox (reserved and enabled policy rules not used by any data traffic for the time of this idle-timeout are deleted automatically by the middlebox; for the deletion of policy rules by middleboxes, see section 2.3.13, "Asynchronous Policy Rule Event (ARE)").
  • Maximum number of simultaneous MIDCOM sessions

a concrete protocol spec can extend this list with more info that's useful for the agent ๐ŸŽ€


2.1.7. Agent and Middlebox Identifiers

so that agents and middleboxes can each keep multiple sessions going, every request message carries a parameter identifying the requesting agent, and every reply and notification message carries a parameter identifying the middlebox ๐Ÿฆ‹ these aren't listed in each transaction's description because they're shared by all of them, and the individual semantics descriptions don't reference them ๐ŸŒธ they aren't necessarily passed explicitly as MIDCOM parameters, since the underlying (secure) transport protocol might provide them ๐Ÿงš agent identifiers are middlebox-unique at the middlebox, and middlebox identifiers are agent-unique at the agent โœจ


2.1.8. Conformance

the MIDCOM requirements in [MDC-REQ] call for protocol capabilities that the transactions below are designed to meet ๐Ÿ’– that doesn't mean every middlebox has to support all of these transactions ๐Ÿ™ˆ the set of supported transactions it announces can differ between authenticated agents ๐Ÿซถ during the capability exchange at session establishment, the middlebox tells the agent which transactions that agent is authorized to perform ๐Ÿ’… some transactions have to be offered to every authenticated agent ๐Ÿ”ฅ

each transaction definition below has a conformance entry saying either 'mandatory' or 'optional' ๐ŸŒˆ a mandatory transaction needs to be implemented by every middlebox offering MIDCOM service, and it must be offered to each of the authenticated agents ๐Ÿ’œ an optional transaction doesn't necessarily need to be implemented by a middlebox, and the middlebox may offer it only to certain authenticated agents ๐Ÿฆ‹ a middlebox may offer one, several, all, or none of the optional transactions to agents ๐Ÿ“ whether an agent may use an optional request transaction is decided by the middlebox's authorization procedure, which this document doesn't specify ๐Ÿงš


2.2. Session Control Transactions

a valid MIDCOM session has to be established before any transaction on policy rules or policy rule groups is possible ๐Ÿ”‘ a MIDCOM session is an authenticated and authorized association between an agent and a middlebox ๐Ÿซถ agents start sessions, and either the agent or the middlebox can end them ๐Ÿ’… both agents and middleboxes can take part in several sessions (with different entities) at the same time ๐Ÿ‘‘ to tell sessions apart, each party uses local session identifiers ๐Ÿชช

all transactions are carried within a MIDCOM session ๐ŸŒธ

session control has three transactions โœจ

  • Session Establishment (SE)
  • Session Termination (ST)
  • Asynchronous Session Termination (AST)

the first two are configuration transactions the agent starts, and the last one is an asynchronous transaction the middlebox starts ๐Ÿฆ‹

2.2.1. Session Establishment (SE) ๐Ÿ’–

okay so this is the transaction that opens a MIDCOM session ๐Ÿฆ‹

  • transaction-name: session establishment
  • transaction-type: configuration
  • transaction-compliance: mandatory

request-parameters (what the agent sends ๐Ÿ“จ):

  • request identifier: a little ID that's unique to the agent ๐Ÿชช, so it can match each request with its reply.
  • version: the version of the MIDCOM protocol ๐ŸŽ€
  • middlebox challenge (mc): an authentication challenge token that checks the middlebox is legit ๐Ÿ”. It's only in the first iteration of the request, see below.
  • agent authentication (aa): a token that proves the agent is legit to the middlebox ๐Ÿซถ. It gets updated in the second iteration of the request with the answer to the middlebox challenge.

reply-parameters (success) (what the middlebox sends back โœจ):

  • request identifier: matches the identifier of the request
  • middlebox authentication (ma): proves the middlebox is legit to the agent ๐Ÿ’…
  • agent challenge (ac): an authentication challenge token for the agent's authentication
  • middlebox capabilities: a list describing what the middlebox can do. See section 2.1.6 for the full list ๐Ÿงš

failure reason (the sad girl list ๐Ÿ’€):

  • authentication failed
  • no authorization
  • protocol version of agent and middlebox do not match
  • lack of resources

semantics ๐ŸŒˆ

So this SE transaction is how a MIDCOM session gets established. For mutual authentication (both sides checking each other, which is the main character move ๐Ÿ‘‘), two SE transactions back to back are required, as shown in Figure 1:

             agent                                       middlebox
               | session establishment request               |
               |  (with middlebox challenge mc)              | CLOSED
               |-------------------------------------------->|
               |                                             |
               | successful reply (with middlebox            |
               |  authentication ma and agent challenge ac)  |
               |<--------------------------------------------|
               |                                             | NOAUTH
               | session establishment request               |
               |  (with agent authentication aa)             |
               |-------------------------------------------->|
               |                                             |
               | successful reply                            |
               |<--------------------------------------------|
               |                                             | OPEN
               |                                             |

            Figure 1: Mutual Authentication of Agent and Middlebox

Session establishment can be simplified to a single transaction ๐Ÿ“. In that case, the server challenge and agent challenge are omitted by the sender or ignored by the receiver. Authentication must be provided by other means instead, for example by Transport Layer Security (TLS) [RFC4346] or IPsec [RFC4302][RFC4303]. Literally a whole different vibe ๐Ÿ™ˆ

The middlebox checks with its policy decision point whether the requesting agent is authorized to open a MIDCOM session. If it's not, the middlebox sends a negative reply with 'no authorization' as the failure reason ๐Ÿ’€. If authentication and authorization both work out, the session is established โœจ, and the agent may start requesting transactions on policy rules and policy rule groups ๐Ÿฆ‹.

Part of the successful reply is an indication of the middlebox's capabilities. Iconic ๐Ÿ’œ


2.2.2. Session Termination (ST) ๐ŸŒธ

  • transaction-name: session termination
  • transaction-type: configuration
  • transaction-compliance: mandatory

request-parameters:

  • request identifier: an agent-unique identifier for matching the corresponding request and reply at the agent ๐Ÿชช

reply-parameters (success only):

  • request identifier: matches the identifier of the request

semantics ๐Ÿฅ€

This transaction is used to close the MIDCOM session on behalf of the agent ๐Ÿ‘‹. After session termination, the middlebox keeps all established policy rules until their lifetime expires, or until an event occurs that causes the middlebox to terminate them ๐ŸŽ€.

The middlebox always generates a successful reply ๐Ÿ’–. After sending that reply, the middlebox won't send any more messages to the agent within the current session. It also won't process any further requests within this session, whether it got them while handling the session termination request or gets them later. Bye bye, no more chat ๐Ÿซ 


2.2.3. Asynchronous Session Termination (AST) ๐Ÿ””

  • transaction-name: asynchronous session termination
  • transaction-type: asynchronous
  • transaction-compliance: mandatory
  • notification message type: Session Termination Notification (STN)

reply-parameters (success only):

  • termination reason: the reason why the session is terminated

semantics ๐Ÿ’…

The middlebox may decide to terminate a MIDCOM session at any time ๐Ÿ˜ญ. Before it actually terminates the session, the middlebox generates an STN message and sends it to the agent. After sending the notification, the middlebox won't process any further requests from the agent, even if they're already queued up at the middlebox ๐Ÿ™…โ€โ™€๏ธ.

Same as before, after session termination the middlebox keeps all established policy rules until their lifetime expires, or until an event occurs for which the middlebox terminates them ๐ŸŒˆ.

Unlike in other asynchronous transactions, only one notification gets sent, since there's only one agent affected by the transaction. Solo queen energy ๐Ÿ‘‘


2.2.4. Session Termination by Interruption of Connection ๐Ÿ”Œ

If a MIDCOM session is based on an underlying network connection, the session can also end when that connection gets interrupted ๐Ÿ’”. If the middlebox detects this, it terminates the session immediately โšก. The effect on established policy rules is the same as for the Asynchronous Session Termination ๐Ÿฆ‹.


2.2.5. Session State Machine ๐Ÿง 

There's a state machine that shows how the session transactions work together, see Figure 2 โœจ. The transaction abbreviations are explained in the headings of each transaction section ๐ŸŽ€.

All sessions start in state CLOSED ๐ŸŒธ. If mutual authentication is already provided by other means, a successful SE transaction can move the session to state OPEN โœจ. Otherwise, it moves to state NOAUTH ๐Ÿซถ. From NOAUTH, a failed second SE transaction sends you back to CLOSED ๐Ÿ˜ญ, and a successful SE transaction moves you to OPEN ๐Ÿ’–.

At any time, an AST transaction or a connection failure can happen, which moves you back to CLOSED ๐Ÿฅ€. A successful ST transaction from either NOAUTH or OPEN also returns you to CLOSED ๐Ÿ‘‹. The parameters of the transactions are explained in Figure 2. The value mc=0 represents an empty middlebox challenge ๐Ÿงš

                                   mc = middlebox challenge
                SE/failure         ma = middlebox authentication
                +-------+          ac = agent challenge
                |       v          aa = agent authentication
               +----------+
               |  CLOSED  |----------------+
               +----------+                | SE(mc!=0)/
                  |   ^  ^                 |  success(ma,ac)
         SE(mc=0, |   |  | AST             |
          aa=OK)/ |   |  | SE/failure      v
          success |   |  | ST/success +----------+
                  |   |  +------------|  NOAUTH  |
                  |   |               +----------+
                  |   | AST                | SE(mc=0,
                  v   | ST/success         |  aa=OK)/
               +----------+                |  success
               |   OPEN   |<---------------+
               +----------+

               Figure 2: Session State Machine

2.3. Policy Rule Transactions ๐ŸŽ€

This section explains the semantics of transactions on policy rules ๐Ÿ’œ. The following transactions are specified:

  • Policy Reserve Rule (PRR) ๐Ÿชช
  • Policy Enable Rule (PER) ๐Ÿ”ฅ
  • Policy Rule Lifetime Change (RLC) โณ
  • Policy Rule List (PRL) ๐Ÿ“‹
  • Policy Rule Status (PRS) ๐Ÿ‘€
  • Asynchronous Policy Rule Event (ARE) ๐Ÿ””

The first three transactions (PRR, PER, RLC) are configuration transactions initiated by the agent ๐Ÿ› ๏ธ. The fourth and fifth (PRL, PRS) are monitoring transactions ๐Ÿ‘๏ธ. The last one (ARE) is an asynchronous transaction ๐ŸŒŠ. The PRL and PRS transactions don't have any effect on the policy rule state machine, so they're giving observe-only ๐Ÿ™ˆ

Before any transaction can start, a valid MIDCOM session must be established first ๐Ÿ”.


2.3.1. Configuration Transactions ๐Ÿ› ๏ธ

Policy rule transactions PER and RLC are the core of the MIDCOM protocol ๐Ÿ‘‘. Both are mandatory, and they serve for:

  • configuring NAT bindings (PER) ๐ŸŒ‰
  • configuring firewall pinholes (PER) ๐Ÿ•ณ๏ธ
  • extending the lifetime of established policy rules (RLC) โณ
  • deleting policy rules (RLC) ๐Ÿ—‘๏ธ

Some cases require knowing in advance which IP address (and port number) NAT would pick in a PER transaction. That info is required before there's enough to finish a complete PER transaction (see the example in section 4.2 ๐Ÿงฉ). To support those cases, the core transactions get extended by the Policy Reserve Rule (PRR) transaction, which serves for:

  • reserving addresses and port numbers at NATs (PRR) ๐ŸŒธ

2.3.2. Establishing Policy Rules ๐Ÿฆ‹

Both PRR and PER establish a policy rule ๐Ÿ’–. The action within the rule is 'reserve' if it's set by PRR, and 'enable' if it's set by PER โœจ.

The Policy Reserve Rule (PRR) transaction is used to set up an address reservation on neither side, one side, or both sides of the middlebox, depending on the middlebox configuration ๐ŸŽ€. The transaction returns the reserved IP addresses, plus the optional ranges of port numbers, to the agent. No address binding or pinhole configuration happens at the middlebox, so packet processing at the middlebox stays unchanged ๐Ÿซถ.

On pure firewalls ๐Ÿงฑ, the PRR transaction is successfully processed without any reservation. But the state transition of the MIDCOM protocol engine is exactly the same as on NATs, which is lowkey wild ๐Ÿคฏ.

On a traditional NAT (see [NAT-TRAD]), only an external address gets reserved. On a twice-NAT, an internal and an external address both get reserved ๐ŸŒˆ. The reservation at a NAT covers required resources, such as IP addresses and port numbers, held for future use ๐Ÿ“. How the reservation is done depends on the NAT's implementation ๐Ÿ› ๏ธ. In both cases, the reservation is either an IP address on its own, or an IP address combined with a range of port numbers ๐Ÿ’œ.

The Policy Enable Rule (PER) transaction is used to establish a policy rule that affects packet processing at the middlebox ๐Ÿ”ฅ. Depending on its input parameters, it can use a reservation made by a PRR transaction, or create a new rule from scratch ๐Ÿงš.

On a NAT, the enable action is interpreted as a bind action, which sets up bindings between internal and external addresses ๐ŸŒ‰. At a firewall, the enable action is interpreted as one or more allow actions that configure pinholes ๐Ÿ•ณ๏ธ. The number of allow actions depends on the parameters of the request and on the firewall's implementation ๐Ÿ’….

On a combined NAT/firewall, the enable action is interpreted as a combination of bind and allow actions ๐Ÿ‘‘.

The PRR transaction and the PER transaction are described in more detail in sections 2.3.8 and 2.3.9 below ๐Ÿ“–โœจ.

2.3.3. Maintaining Policy Rules and Policy Rule Groups ๐ŸŽ€

Okay so every policy rule gets its own middlebox-unique identifier ๐Ÿ†”โœจ Nobody else at that middlebox gets the same one, bestie.

Every rule also has an owner ๐Ÿ‘‘ Access control is based on ownership, so who can touch a rule depends on who owns it (see section 2.1.5) ๐Ÿ” And the owner never changes for the whole life of the rule. Iconic loyalty ๐Ÿ’…

Each rule has its own lifetime โณ When that lifetime runs out, the rule gets terminated at the middlebox. Usually the middlebox says "bye" to a rule with an ARE transaction ๐Ÿ‘‹ A Policy Rule Lifetime Change (RLC) transaction can stretch a rule's lifetime, but only up to the limit the middlebox set at session setup ๐Ÿ™…โ€โ™€๏ธ An RLC can also shorten a rule's lifetime, or delete the rule outright by asking for a lifetime of zero ๐Ÿ—‘๏ธ (Also, rule lifetimes can get changed by the Group Lifetime Change (GLC) transaction too, so keep that in mind ๐Ÿง )

Every policy rule belongs to exactly one policy rule group ๐Ÿงš That membership doesn't change while the rule is alive. Picking the group happens as part of the transaction that creates the rule ๐Ÿ› ๏ธ If the agent doesn't name a group, that same transaction makes a brand new one, and the middlebox picks its identifier ๐Ÿ†• If the agent does name a group, the new rule just joins that existing group ๐Ÿซถ A group only exists while it still has member rules. Once every policy in the group has reached the end of its lifetime, the group is gone ๐ŸŒ…

Agents can look at the properties and status of every policy rule they're allowed to access by using the Policy Rule Status (PRS) transaction ๐Ÿ”โœจ

2.3.4. Policy Events and Asynchronous Notifications ๐Ÿ””

So when a policy rule changes its state, or its remaining lifetime changes in some way other than just ticking down with time, every agent that can access that rule and has an open session with the middlebox gets told ๐Ÿ“ฃ If the agent asked for the change explicitly in a request message, the middlebox answers that agent with the matching reply ๐Ÿ’Œ Everyone else who can access the policy gets a Policy Rule Event Notification (REN) message instead ๐Ÿ””

Here's the tea โ˜• A middlebox can serve several agents at once, each in its own parallel session. The sets of policy rules those agents can access might overlap ๐Ÿซ‚ For example, there could be an agent who authenticates as an administrator and can access every policy of every agent ๐Ÿ‘‘ Or there could be a backup agent running alongside a main agent, authenticating as the same entity as the main agent ๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘

For a PER, PRR, or RLC transaction, the requesting agent gets back a PER, PRR, or RLC reply, respectively ๐Ÿ“ฌ Every other agent that can access the created, modified, or terminated rule (and has an open session with the middlebox) gets a REN message carrying the policy rule identifier (PID) and the rule's remaining lifetime ๐Ÿ†”โณ

If a rule gets terminated because its lifetime got truncated, or because of some other event that no agent started, the middlebox sends a REN message to each agent that can access that rule and has an open session with the middlebox ๐Ÿšจ This is what keeps every agent up to date on the latest state of all the rules it can access, which is honestly so important ๐Ÿฅน

2.3.5. Address Tuples ๐ŸŒธ

Request and reply messages for the PRR, PER, and PRS transactions carry address specifications for IP and transport addresses ๐Ÿ“ฆ These parameters include:

  • IP version
  • IP address
  • IP address prefix length
  • transport protocol
  • port number
  • port parity
  • port range

The request message of PER and the reply message of PRS also carry a direction of flow parameter ๐Ÿงญ For UDP and IP, this parameter says which way packets travel through the middlebox. With 'inbound', UDP packets go from outside to inside. With 'outbound', they go from inside to outside. Either way, the packets can only cross the middlebox in one direction ๐Ÿšช If you want a bidirectional flow, you use 'bidirectional' as the direction of flow parameter ๐Ÿ”

TCP is always bidirectional, but the direction of flow parameter still gets defined for it, like this ๐Ÿงต

  • inbound: bidirectional TCP packet flow. The first packet, with the TCP SYN flag set and the ACK flag not set, must arrive at the middlebox at the outside interface.
  • outbound: bidirectional TCP packet flow. The first packet, with the TCP SYN flag set and the ACK flag not set, must arrive at the middlebox at the inside interface.
  • bidirectional: bidirectional TCP packet flow. The first packet, with the TCP SYN flag set and the ACK flag not set, may arrive at the inside or outside interface.

We call this whole set of parameters an address tuple ๐ŸŽ€ An address tuple specifies either a communication endpoint at an internal or external device, or addresses the middlebox has allocated. This document distinguishes four kinds of address tuples, shown in Figure 3 ๐Ÿ‘€

    +----------+                                 +----------+
    | internal | A0    A1 +-----------+ A2    A3 | external |
    | endpoint +----------+ middlebox +----------+ endpoint |
    +----------+          +-----------+          +----------+

                Figure 3: Address Tuples A0 - A3
  • A0 - internal endpoint: Address tuple A0 specifies a communication endpoint of a device within the internal network, from the middlebox's point of view.
  • A1 - middlebox inside address: Address tuple A1 specifies a virtual communication endpoint at the middlebox within the internal network. A1 is the destination address for packets going from the internal endpoint to the middlebox, and the source for packets going from the middlebox to the internal endpoint.
  • A2 - middlebox outside address: Address tuple A2 specifies a virtual communication endpoint at the middlebox within the external network. A2 is the destination address for packets going from the external endpoint to the middlebox, and the source for packets going from the middlebox to the external endpoint.
  • A3 - external endpoint: Address tuple A3 specifies a communication endpoint of a device within the external network, from the middlebox's point of view.

For a firewall, the inside and outside endpoints are identical to the corresponding external or internal endpoints, respectively ๐Ÿงฑ So the installed policy rule sets the same value in A2 as in A0 (A0=A2), and the same value in A1 as in A3 (A1=A3) ๐Ÿชž

For a traditional NAT, A2 gets a value different from A0, but the NAT binds them together ๐Ÿ”— Same as with the firewall, A1 has the same value as A3 in a traditional NAT ๐Ÿ’œ

For a twice-NAT, there are two bindings of address tuples, because A1 and A2 are both assigned values by the NAT ๐ŸŒ€ The middlebox outside address A2 is bound to the internal endpoint A0, and the middlebox inside address A1 is bound to the external endpoint A3 ๐Ÿฆ‹

2.3.6. Address Parameter Constraints โœจ

okay so, the address tuple parameters come with some rules that apply to basically every message that uses them ๐Ÿ’… instead of repeating them in every single transaction description, they're all summarized right here, so you don't need them again later ๐ŸŽ€

MIDCOM semantics in this doc cover IPv4 and IPv6 as network protocols, and TCP and UDP (running over IPv4 and IPv6) as transport protocols ๐ŸŒธ Any other transport protocol, like Stream Control Transmission Protocol (SCTP), isn't defined in these semantics, but concrete protocol specs may support it ๐Ÿฆ‹

The IP version parameter has either the value 'IPv4' or 'IPv6' ๐Ÿ’– In a policy rule, the value of the IP version parameter must be the same for address tuples A0 and A1, and for A2 and A3 ๐Ÿซถ

The value of the IP address parameter must conform with the specified IP version โœจ

Wildcarding is allowed for the IP address of an address tuple ๐Ÿงš Whether it's allowed at all, or how wide the range can be, depends on the middlebox's local policy, so check section 6, "Security Considerations" too ๐Ÿ™ˆ Wildcarding is set with the IP address prefix length parameter. Like with any prefix length, this parameter says how many high-significance bits of the IP address are fixed, and the remaining low-significance bits get wildcarded ๐ŸŒˆ

The transport protocol parameter can be 'TCP', 'UDP', or 'ANY' ๐Ÿ“ If it's 'ANY', the middlebox only considers IP headers for packet handling, so the transport header isn't looked at at all ๐Ÿ‘€ The port number, port range, and port parity values don't matter when the protocol parameter is 'ANY' ๐Ÿ’… In a policy rule, the value of the transport protocol parameter must be the same for all address tuples A0, A1, A2, and A3 ๐Ÿ”ฅ

The port number parameter is either zero or a positive integer ๐ŸŽ€ A positive integer names a specific UDP or TCP port number. Zero means port wildcarding for whatever protocol the transport protocol parameter names ๐Ÿ’œ If the port number parameter is zero, the port range parameter doesn't matter at all ๐Ÿ™ˆ Depending on the transport protocol, this parameter might really be about ports, or it might be about an equivalent concept ๐Ÿงš

The port parity parameter is used differently for Policy Reserve Rules (PRRs) and Policy Enable Rules (PERs), so pay attention here ๐Ÿ‘‘ For a PRR, the value can be 'odd', 'even', or 'any'. It specifies the parity of the first (lowest) reserved port number ๐ŸŒธ

For a PER, the port parity parameter tells the middlebox whether the port numbers it allocates should have the same parity as the matching internal or external port numbers ๐Ÿฆ‹ In this context, the value is 'same' or 'any' โœจ If it's 'same', the parity of the port number of A0 must match the parity of the port number of A2, and the parity of the port number of A1 must match the parity of the port number of A3 ๐Ÿ’– If the value is 'any', there are no constraints on the parity of any port number ๐Ÿซถ

The port range parameter specifies a run of consecutive port numbers. Its value is a positive integer ๐ŸŒˆ Just like the port number parameter, it defines a set of consecutive ports that starts at the port number parameter's value (the lowest port) and has as many elements as the port range parameter says. A value of 1 means a single port number ๐Ÿ“ The port range parameter must have the same value for each address tuple A0, A1, A2, and A3 ๐Ÿ’…

A single policy rule P with a port range greater than one is basically the same as a set of policy rules P_1, P_2, ..., P_n, where n equals the port range value ๐Ÿคฏ Each of those rules has a port range of 1. Policy rule P_1 holds address tuples A0_1, A1_1, A2_1, and A3_1, and each one contains the first port number from the matching address tuple in P. Policy rule P_2 holds A0_2, A1_2, A2_2, and A3_2, each with the second port number, and so on ๐ŸŽ€


2.3.7. Interface-Specific Policy Rules ๐Ÿฆ‹

Usually, agents request policy rules knowing only A0 and A3, which are the address tuples (see section 2.3.5) ๐Ÿ’โ€โ™€๏ธ But in very special cases, agents might need to pick the interfaces the requested policy rule gets bound to ๐Ÿ‘‘ Honestly, the middlebox is usually careful about this when it reserves or enables a policy rule, since it knows its whole configuration ๐Ÿง  For agents that do want to choose, the Policy Reserve Rule (PRR) and Policy Enable Rule (PER) transactions have optional parameters, called:

  • inside interface: The selected interface on the inside of the middlebox, i.e., in the private or protected address realm. ๐Ÿ 
  • outside interface: The selected interface on the outside of the middlebox, i.e., in the public address realm. ๐ŸŒ

The Policy Rule Status (PRS) transactions include these optional parameters in their replies, but only when they're supported ๐Ÿ’œ

Agents can find out at session startup whether the middlebox supports interface-specific policy rules, by checking the middlebox capabilities (see section 2.1.6) ๐ŸŒธ That's the vibe, bestie ๐Ÿ’–

2.3.8. Policy Reserve Rule (PRR) โœจ

Here's the PRR, the transaction where the agent basically says "hold these addresses and ports for me, bestie" ๐ŸŽ€ It's a configuration transaction and it's mandatory, so no skipping it ๐Ÿ’…

transaction-name: policy reserve rule

transaction-type: configuration
transaction-compliance: mandatory

request-parameters ๐ŸŒธ

  • request identifier: an agent-unique ID so the agent can match each reply to its request ๐Ÿชช
  • group identifier: the group this policy reserve rule should belong to. As indicated in section 2.3.3, if this value is not supplied, the middlebox assigns a new group for this policy reserve rule ๐Ÿงš
  • service: the NAT service the agent wants from the middlebox. Allowed values are 'traditional' or 'twice' ๐Ÿ’–
  • internal IP version: the IP version requested on the inside of the middlebox; see section 2.3.5.
  • internal IP address: the IP address of the internal communication endpoint (A0 in Figure 3); see section 2.3.5.
  • internal port number: the port number of the internal communication endpoint (A0 in Figure 3); see section 2.3.5.
  • inside interface (optional): the interface on the inside of the middlebox; see section 2.3.7.
  • external IP version: the IP version requested on the outside of the middlebox; see section 2.3.5.
  • outside interface (optional): the interface on the outside of the middlebox; see section 2.3.7.
  • transport protocol: see section 2.3.5. ๐Ÿฆ‹
  • port range: how many consecutive port numbers to reserve; see section 2.3.5.
  • port parity: the requested parity of the first (lowest) port number to reserve. Allowed values are 'odd', 'even', and 'any'. See also section 2.3.5. ๐Ÿ“
  • policy rule lifetime: the lifetime the agent proposes for the requested policy rule โญ

reply-parameters (success) ๐Ÿ‘‘

  • request identifier: matches the identifier of the request ๐Ÿซถ
  • policy rule identifier: a middlebox-unique policy rule identifier. The middlebox assigns it, and it's used as the policy rule handle in later policy rule transactions, especially to point at this policy reserve rule in a subsequent PER transaction ๐Ÿ”‘
  • group identifier: the group this policy reserve rule is a member of ๐ŸŒˆ
  • reserved inside IP address: the reserved IPv4 or IPv6 address on the inside of the middlebox. For an outbound flow, this is the destination the internal endpoint sends its packets to (A1 in Figure 3). For an inbound flow, it's the apparent source address of the packets as forwarded to the internal endpoint (A0 in Figure 3). The middlebox only reserves and reports an inside address when twice-NAT is in effect. Otherwise, an empty value for the addresses means no inside reservation was made. See also section 2.3.5. ๐Ÿ™ˆ
  • reserved inside port number: see section 2.3.5.
  • reserved outside IP address: the reserved IPv4 or IPv6 address on the outside of the middlebox. For an inbound flow, this is the destination the external endpoint sends its packets to (A2 in Figure 3). For an outbound flow, it's the apparent source address of the packets as forwarded to the external endpoint (A3 in Figure 3). If the middlebox is configured as a pure firewall, an empty value for the addresses means no outside reservation was made. See also section 2.3.5. ๐Ÿง
  • reserved outside port number: see section 2.3.5.
  • policy rule lifetime: the lifetime the middlebox actually grants. When it runs out, the reservation gets revoked, unless a policy enable rule in a PER transaction has already replaced it ๐Ÿ’€

failure reason ๐Ÿฅ€

  • agent not authorized for this transaction
  • agent not authorized to add members to this group
  • lack of IP addresses
  • lack of port numbers
  • lack of resources
  • specified inside/outside interface does not exist
  • specified inside/outside interface not available for specified service

notification message type: Policy Rule Event Notification (REN) ๐Ÿ“ฃ

semantics ๐Ÿ’…

The agent can use this transaction to reserve an IP address, or a combo of IP address, transport type, port number, and port range, on neither side, one side, or both sides of the middlebox. Whatever it takes to get a flow enabled โœจ Usually the PRR shows up when you need to reserve stuff before you have enough info for a full policy enable rule transaction. See section 4.2 for an example ๐ŸŒท

When the middlebox gets the request, it figures out how many address (and port) reservations it needs based on its configuration. If it only offers packet filter services, it doesn't reserve anything and returns empty values for the reserved inside and outside IP addresses and port numbers. If it's set up for twice-NAT, it reserves both inside and outside IP addresses (plus an optional range of port numbers) and returns them. Otherwise, it reserves and returns an outside IP address (plus an optional range of port numbers), and returns empty values for the reserved inside address and port range. ๐ŸŒธ

The A0 parameters (inside IP address version, inside IP address, and inside port number) help the middlebox work out the correct NAT mapping, and therefore A2 if needed. Once a PRR transaction has reserved an outside address (A2) for an internal endpoint (A0) at the middlebox, the middlebox must ensure that this reserved A2 stays available in any later PER and PRR transactions. Lowkey a big deal ๐Ÿ”’

For middleboxes that support interface-specific policy rules, as defined in section 2.3.7, the optional inside and outside interface parameters must both be included in the request, or neither of them should be included. When they're there, the middlebox uses the outside interface parameter to pick the interface where the outside address tuple (outside IP address and port number) gets reserved, and the inside interface parameter to pick the interface where the inside address tuple (inside IP address and port number) gets reserved. Without them, the middlebox picks the interfaces based on its internal configuration. ๐Ÿฆ‹

If there's a lack of resources, like available IP addresses, port numbers, or storage for more policy rules, the reservation fails and an appropriate failure reply gets generated. Not it ๐Ÿ’€

If the agent specifies a policy rule group that doesn't exist, or an existing one that the requesting agent doesn't own, then no new policy rule is established and an appropriate failure reply gets generated. ๐Ÿ™…โ€โ™€๏ธ

If it succeeds, this transaction creates a new policy reserve rule. If the agent specified an existing policy rule group, the new policy rule becomes a member of it. If no group is specified, a new group gets created with the new policy rule as its only member. The middlebox generates a middlebox-unique identifier for the new policy rule. The owner of the new policy rule is the authenticated agent that sent the request. ๐Ÿ‘‘

The middlebox picks a lifetime that's greater than zero and less than or equal to the smaller of the requested value and the maximum lifetime the middlebox set at session startup:

0 <= lt_granted <= MINIMUM(lt_requested, lt_maximum)

where

   - lt_granted is the lifetime actually granted by the middlebox
   - lt_requested is the lifetime the agent requested
   - lt_maximum is the maximum lifetime specified at session
     setup

A middlebox with NAT capability always reserves a middlebox external address tuple (A2) in response to a PRR request. In the special case of a combined twice-NAT/NAT middlebox, the agent can request only NAT service or twice-NAT service by picking the service parameter 'traditional' or 'twice'. An agent with no preference picks 'twice'. The 'traditional' value should only be used to select traditional NAT service on middleboxes that offer both traditional NAT and twice-NAT. With 'twice', the combined twice-NAT/NAT middlebox reserves A2 and A1. With 'traditional', it only reserves A2. An agent must always use the PRR transaction to choose NAT-only or twice-NAT service on a combined twice-NAT/NAT middlebox. A firewall middlebox ignores this parameter. ๐ŸŽ€

If the protocol identifier is ANY, the middlebox only reserves available inside and/or outside IP address(es). The reserved address(es) get returned to the agent. In this case, the request parameters "port range" and "port parity", and the reply parameters "inside port number" and "outside port number", don't matter at all ๐Ÿ™ƒ

If the protocol identifier is UDP or TCP, a combo of an IP address and a consecutive sequence of port numbers, starting with the specified parity, gets reserved on neither side, one side, or both sides of the middlebox, as appropriate. The IP address(es) and the first (lowest) reserved port number(s) in that sequence get returned to the agent. (This also applies to other protocols that support ports or the equivalent.) ๐ŸŒˆ

After a new policy reserve rule is successfully established and the reply has been sent to the requesting agent, the middlebox checks whether any other authenticated agents with open sessions can access the new policy rule. If it finds one or more, it sends a REN message reporting the new policy rule to each of them. Main character energy for the whole group ๐Ÿ“ฃ

MIDCOM agents use the policy enable rule (PER) transaction to enable policy reserve rules that were already set up by a policy reserve rule (PRR) transaction. See also section 2.3.2. ๐Ÿฆ‹


2.3.9. Policy Enable Rule (PER) ๐Ÿงš

Next up is the PER, the one that flips a reserved rule on ๐Ÿ”ฅ

transaction-name: policy enable rule

transaction-type: configuration

transaction-compliance: mandatory

request-parameters ๐Ÿ’–

  • request identifier: an agent-unique ID for matching the request and reply at the agent ๐Ÿชช
  • policy reserve rule identifier: a reference to an existing policy reserve rule created by a PRR transaction. This can be empty, in which case the middlebox must assign any necessary addresses and port numbers within this PER transaction. If it isn't empty, the following request parameters don't matter: group identifier, transport protocol, port range, port parity, internal IP version, external IP version. ๐ŸŒธ
  • group identifier: the group this policy enable rule should be a member of. As indicated in section 2.3.3, if this value isn't supplied, the middlebox assigns a new group for this policy reserve rule. ๐Ÿซถ
  • transport protocol: see section 2.3.5. ๐Ÿฆ‹
  • port range: how many consecutive port numbers to reserve; see section 2.3.5. โœจ
  • port parity ๐Ÿ’–: The requested parity of the port number(s) to be mapped. Allowed values of this parameter are 'same' and 'any'. See also section 2.3.5.
  • direction of flow ๐Ÿฆ‹: This parameter specifies the direction of enabled communication, either 'inbound', 'outbound', or 'bidirectional'.
  • internal IP version ๐ŸŒธ: Requested IP version at the inside of the middlebox; see section 2.3.5.
  • internal IP address ๐ŸŽ€: The IP address of the internal communication endpoint (A0 in Figure 3); see section 2.3.5.
  • internal port number ๐Ÿงš: The port number of the internal communication endpoint (A0 in Figure 3); see section 2.3.5.
  • inside interface (optional) ๐Ÿ“: Interface at the inside of the middlebox; see section 2.3.7.
  • external IP version โœจ: Requested IP version at the outside of the middlebox; see section 2.3.5.
  • external IP address ๐Ÿ’œ: The IP address of the external communication endpoint (A3 in Figure 3); see section 2.3.5.
  • external port number ๐ŸŒˆ: The port number of the external communication endpoint (A3 in Figure 3), see section 2.3.5.
  • outside interface (optional) ๐Ÿ‘‘: Interface at the outside of the middlebox; see section 2.3.7.
  • policy rule lifetime โณ: A lifetime proposal to the middlebox for the requested policy rule.

reply-parameters (success): ๐ŸŽ‰

  • request identifier: An identifier matching the identifier of the request.
  • policy rule identifier: A middlebox-unique policy rule identifier. It is assigned by the middlebox and used as policy rule handle in further policy rule transactions. If a policy reserve rule identifier was provided in the request, then the returned policy rule identifier has the same value.
  • group identifier: A reference to the group of which the policy enable rule is a member. If a policy reserve rule identifier was provided in the request, then this parameter identifies the group of which the policy reserve rule was a member.
  • inside IP address: The IP address provided at the inside of the middlebox (A1 in Figure 3). In case of a twice-NAT, this parameter will be an internal IP address reserved at the inside of the middlebox. In all other cases, this reply-parameter will be identical with the external IP address passed with the request. If the policy reserve rule identifier parameter was supplied in the request and the respective PRR transaction reserved an inside IP address, then the inside IP address provided in the PER response will be the identical value to that returned by the response to the PRR request. See also section 2.3.5.
  • inside port number: The internal port number provided at the inside of the middlebox (A1 in Figure 3); see also section 2.3.5.
  • outside IP address: The external IP address provided at the outside of the middlebox (A2 in Figure 3). In case of a pure firewall, this parameter will be identical with the internal IP address passed with the request. In all other cases, this reply-parameter will be an external IP address reserved at the outside of the middlebox. See also section 2.3.5.
  • outside port number: The external port number provided at the outside of the NAT (A2 in Figure 3); see section 2.3.5..
  • policy rule lifetime: The policy rule lifetime granted by the middlebox.

failure reason: ๐Ÿšจ

  • agent not authorized for this transaction
  • agent not authorized to add members to this group
  • no such policy reserve rule
  • agent not authorized to replace this policy reserve rule
  • conflict with already existing policy rule (e.g., the same internal address-port is being mapped to different outside address-port pairs)
  • lack of IP addresses
  • lack of port numbers
  • lack of resources
  • no internal IP wildcarding allowed
  • no external IP wildcarding allowed
  • specified inside/outside interface does not exist
  • specified inside/outside interface not available for specified service
  • reserved A0 to requested A0 mismatch

notification message type: Policy Rule Event Notification (REN) ๐Ÿ“ฃ

semantics: ๐Ÿง 

This transaction can be used by an agent to enable communication between an internal endpoint and an external endpoint independently of the type of middlebox (NAT, NAPT, firewall, NAT-PT, combined devices), for unidirectional or bidirectional traffic. It's giving universal compatibility ๐Ÿ’…

The agent sends an enable request specifying the endpoints (optionally including wildcards) and the direction of communication (inbound, outbound, bidirectional). The communication endpoints are displayed in Figure 3. The basic operation of the PER transaction can be described by:

  1. the agent sending A0 and A3 to the middlebox,
  2. the middlebox reserving A1 and A2 or using A1 and A2 from a previous PRR transaction,
  3. the middlebox enabling packet transfer between A0 and A3 by binding A0-A2 and A1-A3 and/or by opening the corresponding pinholes, both according to the specified direction, and
  4. the middlebox returning A1 and A2 to the agent.

In case of a pure packet filtering firewall, the returned address tuples are the same as those in the request: A2=A0 and A1=A3. Each partner uses the other's real address. ๐Ÿ™ˆ In case of a traditional NAT, the internal endpoint may use the real address of the external endpoint (A1=A3), but the external endpoint uses an address tuple provided by the NAT (A2!=A0). In case of a twice-NAT device, both endpoints use address tuples provided by the NAT for addressing their communication partner (A3!=A1 and A2!=A0).

If a firewall is combined with a NAT or a twice-NAT, the replied address tuples will be the same as for pure traditional NAT or twice-NAT, respectively, but the middlebox will configure its packet filter in addition to the performed NAT bindings. In case of a firewall combined with a traditional NAT, the policy rule may imply more than one enable action for the firewall configuration, as incoming and outgoing packets may use different source-destination pairs. ๐Ÿ”ฅ

For middleboxes supporting interface-specific policy rules, as defined in section 2.3.7, the optional inside and outside interface parameters must both be included in the request, or neither of them should be included. In the presence of these parameters, the middlebox uses the outside interface parameter to select the interface at which the outside address tuple (outside IP address and port number) is bound, and the inside interface parameter to select the interface at which the inside address tuple (inside IP address and port number) is bound. Without the presence of these parameters, the middlebox selects the particular interfaces based on its internal configuration.

Checking the Policy Reservation Rule Identifier ๐Ÿ”

If the parameter specifying the policy reservation rule identifier is not empty, then the middlebox checks whether the referenced policy rule exists, whether the agent is authorized to replace this policy rule, and whether this policy rule is a policy reserve rule.

In case of success, this transaction creates a new policy enable rule. If a policy reserve rule was referenced, then the policy reserve rule is terminated without an explicit notification sent to the agent (other than the successful PER reply).

The PRR transaction sets the internal endpoint A0 during the reservation process. In the process of creating a new policy enable rule, the middlebox may check whether the requested A0 is equal to the reserved A0. The middlebox may reject a PER request with a requested A0 not equal to the reserved A0 and must then send an appropriate failure message. Alternatively, the middlebox may change A0 due to the PER request.

The middlebox generates a middlebox-unique identifier for the new policy rule. If a policy reserve rule was referenced, then the identifier of the policy reserve rule is reused.

The owner of the new policy rule is the authenticated agent that sent the request.

Checking the Policy Rule Group Identifier ๐Ÿงฉ

If no policy reserve rule was specified, then the policy rule group parameter is checked. If a non-existing policy rule group is specified, or if an existing policy rule group is specified that is not owned by the requesting agent, then no new policy rule is established, and an appropriate failure reply is generated.

If an already existing policy rule group is specified, then the new policy rule becomes a member. If no policy group is specified, then a new group is created with the new policy rule as its only member.

If the transport protocol parameter value is 'ANY', then the middlebox enables communication between the specified external IP address and the specified internal IP address. The addresses to be used by the communication partners to address each other are returned to the agent as inside IP address and outside IP address. If the reservation identifier is not empty and if the reservation used the same transport protocol type, then the reserved IP addresses are used.

For the transport protocol parameter values 'UDP' and 'TCP', the middlebox acts analogously as for 'ANY' but also maps ranges of port numbers, keeping the port parity, if requested. โœจ

The configuration of the middlebox may fail because of lack of resources, such as available IP addresses, port numbers, or storage for further policy rules. It may also fail because of a conflict with an established policy rule. In case of a conflict, the first-come first-served mechanism is applied. Existing policy rules remain unchanged and arriving new ones are rejected. However, in case of a non-conflicting overlap of policy rules (including identical policy rules), all policy rules are accepted.

The middlebox chooses a lifetime value that is greater than zero and less than or equal to the minimum of the requested value and the maximum lifetime specified by the middlebox at session startup, i.e.,

0 <= lt_granted <= MINIMUM(lt_requested, lt_maximum)

where:

  • lt_granted is the lifetime actually granted by the middlebox
  • lt_requested is the lifetime the agent requested
  • lt_maximum is the maximum lifetime specified at session setup

In each case of failure, an appropriate failure reply is generated. The policy reserve rule that is referenced in the PER transaction is not affected in case of a failure within the PER transaction -- i.e., the policy reserve rule remains. ๐Ÿซถ

After a new policy enable rule is successfully established and the reply message has been sent to the requesting agent, the middlebox checks whether there are other authenticated agents participating in open sessions that can access the new policy rule. If the middlebox finds one or more of these agents, then it sends a REN message reporting the new policy rule to each of them. ๐ŸŒŸ

2.3.10. Policy Rule Lifetime Change (RLC) โœจ

transaction-name: policy rule lifetime change

transaction-type: configuration

transaction-compliance: mandatory

okay so this is the RLC transaction, and it's giving "I'd like to change how long this rule sticks around, please" ๐Ÿ’… It's a configuration transaction, so the agent is basically asking the middlebox to edit a rule's lifetime. ๐Ÿฆ‹

request-parameters:

  • request identifier: an agent-unique ID so the agent can match its request to the reply ๐ŸŽ€
  • policy rule identifier: which policy rule's lifetime you want to change. This can be either a policy reserve rule or a policy enable rule ๐ŸŒธ
  • policy rule lifetime: the new lifetime you're proposing for the rule ๐Ÿ’–

reply-parameters (success):

  • request identifier: matches the identifier from the request, obviously ๐Ÿซถ
  • policy rule lifetime: the remaining lifetime the middlebox actually granted โณ

failure reason:

  • agent not authorized for this transaction
  • agent not authorized to change lifetime of this policy rule
  • no such policy rule
  • lifetime cannot be extended

notification message type: Policy Rule Event Notification (REN)

semantics:

okay so the agent can use this to ask for three things: making the lifetime longer, making it shorter, or ending the rule entirely. โœจ To end a rule, you suggest a new lifetime of zero. Iconic behaviour, no cap. ๐Ÿ’€

Here's the vibe check the middlebox runs. First it checks that the policy rule exists and that the agent is allowed to access it. If either check fails, it sends back the matching failure reply. If the requested lifetime is longer than the current one, it also checks whether the rule is even allowed to be extended, and if it isn't, it sends a failure message. ๐Ÿ™ˆ

A failure reply means the new lifetime was NOT accepted and the rule stays exactly as it was. A success reply goes out whenever the rule's lifetime got changed in any way. ๐ŸŽ€

The success reply carries the new lifetime. The middlebox picks a value that's greater than zero and less than or equal to the smaller of two things: what the agent asked for, and the maximum lifetime the middlebox set at session startup. Basically:

0 <= lt_granted <= MINIMUM(lt_requested, lt_maximum)

where

  • lt_granted is the lifetime actually granted by the middlebox
  • lt_requested is the lifetime the agent requested
  • lt_maximum is the maximum lifetime specified at session setup

Wait, the bit that's lowkey dramatic: after the middlebox sends a success reply with a lifetime of zero, it treats the policy rule as non-existent. Any transaction on that rule after that gets a negative reply saying the rule doesn't exist anymore. Gone. Ghosted. ๐Ÿ‘ป๐ŸŒˆ

Also, the policy rule lifetime can get changed by the Group Lifetime Change (GLC) transaction too, as long as the rule is a member of that group. Multiple ways to make the change, bestie. ๐Ÿงš

Last part: once the remaining lifetime has been successfully changed and the reply has gone back to the requesting agent, the middlebox checks whether any other authenticated agents in open sessions can access the rule. If it finds any, it sends each of them a REN message reporting the new remaining lifetime. Everyone stays in the loop ๐Ÿ’œ


2.3.11. Policy Rule List (PRL) ๐ŸŒธ

transaction-name: policy rule list

transaction-type: monitoring

transaction-compliance: mandatory

This one is a monitoring transaction, and it's basically the "show me everything I can see" button. ๐Ÿ‘€

request-parameters:

  • request identifier: an agent-unique identifier for matching corresponding request and reply at the agent ๐ŸŽ€

reply-parameters (success):

  • request identifier: matches the identifier of the request ๐Ÿซถ
  • policy list: the list of policy rule identifiers for every policy rule the agent can access ๐Ÿ“‹

failure reason:

  • transaction not supported
  • agent not authorized for this transaction

semantics:

okay so the agent can use this to list every policy it's allowed to access. Usually the agent already knows this stuff, but in special situations, like after an agent fail-over, or for special agents like an administrating agent that can access all policies, this transaction is a total lifesaver. ๐Ÿงšโœจ

The middlebox checks whether the agent is authorized to request this first. If that check fails, it sends back a failure reply. Otherwise you get a list of all the policies the agent can access, and each entry shows the policy's identifier and its owner. ๐Ÿ’–

And the tea: this transaction does NOT change the policy rule state at all. It's purely a look-don't-touch situation. ๐Ÿ™ˆ


2.3.12. Policy Rule Status (PRS) ๐Ÿ’…

transaction-name: policy rule status

transaction-type: monitoring

transaction-compliance: mandatory

Another monitoring transaction, but this one is the deep-dive. It's giving "tell me EVERYTHING about this one rule." ๐Ÿ”๐Ÿฆ‹

request-parameters:

  • request identifier: an agent-unique identifier for matching corresponding request and reply at the agent ๐ŸŽ€
  • policy rule identifier: the middlebox-unique identifier for the policy rule ๐ŸŒธ

reply-parameters (success):

  • request identifier: matches the identifier of the request ๐Ÿซถ
  • policy rule owner: an identifier of the agent that owns this policy rule ๐Ÿ‘‘
  • group identifier: a reference to the group the policy rule belongs to ๐Ÿงบ
  • policy rule action: this has either the value 'reserve' or the value 'enable' ๐Ÿ”ฅ
  • transport protocol: identifies the protocol a reservation is requested for; see section 2.3.5 ๐ŸŒˆ
  • port range: the number of consecutive port numbers; see section 2.3.5 ๐ŸŒธ
  • direction: the direction of the communication the middlebox enables. This only applies to policy enable rules โžก๏ธ
  • internal IP address version: the version of the internal IP address (IP version of A0 in Figure 3) ๐ŸŒ
  • external IP address version: the version of the external IP address (IP version of A3 in Figure 3) ๐ŸŒ
  • internal IP address: the IP address of the internal communication endpoint (A0 in Figure 3); see section 2.3.5 ๐Ÿ 
  • internal port number: the port number of the internal communication endpoint (A0 in Figure 3); see section 2.3.5 ๐Ÿšช
  • external IP address: the IP address of the external communication endpoint (A3 in Figure 3); see section 2.3.5 ๐ŸŒ
  • external port number: the port number of the external communication endpoint (A3 in Figure 3); see section 2.3.5 ๐Ÿšช
  • inside interface (optional): the inside interface at the middlebox; see section 2.3.7 ๐Ÿ”Œ
  • inside IP address: the internal IP address provided at the inside of the NAT (A1 in Figure 3); see section 2.3.5 ๐Ÿก
  • inside port number: the internal port number provided at the inside of the NAT (A1 in Figure 3); see section 2.3.5 ๐ŸŽŸ๏ธ
  • outside interface (optional): the outside interface at the middlebox; see section 2.3.7 ๐Ÿ”Œ
  • outside IP address: the external IP address provided at the outside of the NAT (A2 in Figure 3); see section 2.3.5 ๐ŸŒค๏ธ
  • outside port number: the external port number provided at the outside of the NAT (A2 in Figure 3); see section 2.3.5 ๐ŸŽซ
  • port parity: the parity of the allocated ports โš–๏ธ
  • service: the selected service in the case of a mixed traditional and twice-NAT middlebox (see section 2.3.8) ๐Ÿ“
  • policy rule lifetime: the remaining lifetime of the policy rule โณ

failure reason:

  • transaction not supported
  • agent not authorized for this transaction
  • no such policy rule
  • agent not authorized to access this policy rule

semantics:

okay so the agent can use this to list all the properties of a policy rule. Same deal as the PRL: usually the agent already has this info, but after an agent fail-over, or for special agents like an administrating agent that can access all policy rules, this transaction is super helpful. ๐Ÿงš

The middlebox first checks that the specified policy rule exists and that the agent is authorized to access this group. ๐Ÿ™ˆ If either check fails, you get an appropriate failure reply. Otherwise, all the properties of the rule come back to the agent. Some of those returned parameters might be irrelevant, depending on the policy rule action ('reserve' or 'enable') and on other parameters, like the protocol identifier. Not every field is always the main character. ๐ŸŽญ

Again, this transaction does NOT affect the policy rule state. Look all you want, babe. ๐Ÿ‘€๐Ÿ’œ


2.3.13. Asynchronous Policy Rule Event (ARE) ๐Ÿ””

transaction-name: asynchronous policy rule event

transaction-type: asynchronous

transaction-compliance: mandatory

notification message type: Policy Rule Event Notification (REN)

semantics:

okay so this is the one where the middlebox just... decides on its own to do something. ๐Ÿ˜ญ At any point in time, it can choose to terminate a policy rule. The most common reason is lifetime expiration, but other events can trigger it too, like changes in the policy rule decision point. Plot twist, no warning needed. ๐ŸŒช๏ธ

When that happens, the middlebox sends a REN message to every agent that's in an open session with it and is authorized to access the rule. The notification goes out BEFORE the middlebox changes the rule's lifetime. ๐Ÿ”” Any other authorized agent can also trigger a lifetime change, and that change can be a shortening (lt_new < lt_existing), an extension (lt_new > lt_existing), or a termination of the policy rule (lt_new = 0). Lots of drama, all the time. ๐ŸŽฌโœจ

The ARE transaction handles REN messages the same way section 2.3.4 describes, just for multiple agents at once. Everyone gets the update, everyone stays in the loop ๐Ÿซถ๐ŸŒˆ

2.3.14. Policy Rule State Machine โœจ

okay so the state machine for policy rule transactions is shown in Figure 4 with every possible state transition ๐Ÿฆ‹ the transaction abbreviations live in the headings of each transaction section, so just look there ๐Ÿ’…

                     PRR/success   +---------------+
                 +-----------------+  PRID UNUSED  |<-+
       +----+    |                 +---------------+  |
       |    |    |                   ^   |            |
       |    v    v                   |   |            |
       |  +-------------+    ARE     |   | PER/       | ARE
       |  |   RESERVED  +------------+   | success    | RLC(lt=0)/
       |  +-+----+------+  RLC(lt=0)/    |            |  success
       |    |    |          success      |            |
       +----+    |                       v            |
     RLC(lt>0)/  | PER/success     +---------------+  |
      success    +---------------->|    ENABLED    +--+
                                   +-+-------------+
                                     |           ^
         lt = lifetime               +-----------+
                                   RLC(lt>0)/success

               Figure 4: Policy Rule State Machine

this state machine exists per policy rule identifier (PRID) ๐ŸŒธ every policy rule starts out in state PRID UNUSED, which basically means the policy rule doesn't exist or isn't active ๐Ÿ™ˆ once you're back in PRID UNUSED, that policy rule identifier is no longer tied to an existing policy rule and the middlebox is allowed to reuse it ๐Ÿ”

a successful PRR transaction moves you from the starting state PRID UNUSED to RESERVED, where an address reservation gets set up ๐ŸŽ€ from RESERVED you can get into ENABLED with a PER transaction ๐Ÿ’– PER can also take you straight from PRID UNUSED to ENABLED with no reservation at all, which is so efficient, bestie โœจ and in ENABLED, the requested communication between the internal and the external endpoint is turned on ๐Ÿฆ‹

RESERVED and ENABLED can both be kept alive by successful RLC transactions that ask for a lifetime greater than 0 ๐Ÿซถ going back to PRID UNUSED from either of these states can happen through an ARE transaction, or through a successful RLC transaction with a lifetime parameter of 0 ๐Ÿ’€

a failed request transaction does NOT change state at the middlebox ๐Ÿ˜ญ wait, sorry, let me be precise: it does not change state at the middlebox, full stop ๐Ÿ’…

and note that transitions kicked off by RLC transactions can also be kicked off by GLC transactions ๐ŸŒˆ


2.4. Policy Rule Group Transactions ๐Ÿ‘‘

this section covers the semantics for transactions on groups of policy rules ๐Ÿงš the group transactions are:

  • Group Lifetime Change (GLC)
  • Group List (GL)
  • Group Status (GS)

all of them are request transactions started by the agent ๐Ÿซถ GLC is a configuration transaction, while GL and GS are monitoring transactions that don't have any effect on the group state machine ๐Ÿ”ฅ

2.4.1. Overview ๐ŸŒธ

okay so a policy rule group has only one attribute: its list of members ๐Ÿ’œ every member policy of a single group has to be owned by the same authenticated agent, so a group's owner is an implicit property too, and it's just the owner of its member policy rules ๐Ÿ‘‘

a group gets implicitly created when its first member policy rule is established ๐Ÿฆ‹ and it gets implicitly terminated when the last remaining member policy rule is terminated ๐Ÿ’€ which means the lifetime of a group is the maximum of the lifetimes of all its member policy rules, no cap ๐ŸŽ€

every group has a middlebox-unique identifier ๐Ÿ”‘

policy rule group transactions are declared as 'optional' by their respective compliance entry in section 3 ๐Ÿ™ˆ but they still give you some really nice functionality, like letting the agent send one request instead of several, which you can't get if only the mandatory transactions are available ๐Ÿ’…

the Group Lifetime Change (GLC) transaction is basically the same as running Policy Rule Lifetime Change (RLC) transactions on every member of the group at the same time โญ a successful GLC leaves all member policy rules with the same lifetime ๐ŸŒˆ just like RLC, you can use GLC to delete all member policy rules by asking for a lifetime of zero ๐Ÿ’–

the monitoring transactions Group List (GL) and Group Status (GS) let the agent explore the state of the middlebox and check its access rights ๐Ÿ‘€ GL lists all groups the agent may access, including groups owned by other agents ๐Ÿงš GS reports the status of one individual group and lists all its policy rules by their policy rule identifiers ๐Ÿ“ then the agent can dig into each individual policy rule by using those identifiers in a policy rule status (PRS) transaction (see section 2.3.12) โœจ

GL and GS are especially helpful after an agent fail-over ๐Ÿซถ the agent taking over for a failed one can use them to retrieve whichever policies were established by the failed agent, which is such a lifesaver ๐Ÿฆ‹

notifications on group events are generated the same way policy rule events are ๐Ÿ”” to tell agents about group events, the Policy Rule Group Event Notification (GEN) message type is used ๐Ÿ’œ GEN messages contain an agent-unique notification identifier, the policy rule group identifier, and the remaining lifetime of the group ๐ŸŽ€

2.4.2. Group Lifetime Change (GLC) ๐Ÿ’–

  • transaction-name: group lifetime change
  • transaction-type: configuration
  • transaction-compliance: optional
  • request-parameters:
    • request identifier: An agent-unique identifier for matching corresponding request and reply at the agent.
    • group identifier: A reference to the group for which the lifetime is requested to be changed.
    • group lifetime: The new lifetime proposal for the group.
  • reply-parameters (success):
    • request identifier: An identifier matching the identifier of the request.
    • group lifetime: The group lifetime granted by the middlebox.
  • failure reason:
    • transaction not supported
    • agent not authorized for this transaction
    • agent not authorized to change lifetime of this group
    • no such group
    • lifetime cannot be extended
  • notification message type: Policy Rule Group Event Notification (GEN)

semantics ๐Ÿง 

okay so the agent can use this transaction to ask for an extension of the lifetime of all members of a policy rule group ๐ŸŒท or to ask for shortening everyone's lifetime ๐Ÿซง or to request termination of all member policies, which also means the group is gone ๐Ÿ’€ termination is requested by suggesting a new group lifetime of zero ๐Ÿ”ฅ

the middlebox first checks whether the specified group exists and whether the agent is authorized to access it ๐Ÿ” if one of those checks fails, an appropriate failure reply is generated ๐Ÿ˜ญ if the requested lifetime is longer than the current one, the middlebox also checks whether the group's lifetime may be extended, and it generates an appropriate failure message if it may not ๐Ÿ™…โ€โ™€๏ธ

a failure reply means the lifetime of the group stays exactly the same ๐Ÿซถ a success reply is generated by the middlebox if the lifetime of the group was changed in any way โœจ

the success reply contains the new common lifetime of all member policy rules of the group ๐ŸŽ€ the middlebox picks a new lifetime that is less than or equal to the minimum of the requested lifetime and the maximum lifetime the middlebox specified at session setup along with its other capabilities, so:

   0 <= lt_granted <= MINIMUM(lt_requested, lt_maximum)

where:

  • lt_granted is the lifetime actually granted by the middlebox
  • lt_requested is the lifetime the agent requested
  • lt_maximum is the maximum lifetime specified at session setup

after sending a success reply with a lifetime of zero, the middlebox will terminate the member policy rules without any further notification to the agent ๐Ÿ’” it then considers the group and all of its members non-existent ๐Ÿซฅ any further transaction on this policy rule group or on any of its members gets a negative reply, saying that this group or policy rule (respectively) doesn't exist anymore ๐Ÿ™ƒ

after the remaining policy rule group lifetime is successfully changed and the reply has been sent to the requesting agent, the middlebox checks whether there are other authenticated agents in open sessions that can access the policy rule group ๐Ÿ‘€ if it finds one or more, it sends a GEN message reporting the new remaining policy rule group lifetime to each of them ๐Ÿ“ฃ

2.4.3. Group List (GL) ๐Ÿงš

  • transaction-name: group list
  • transaction-type: monitoring
  • transaction-compliance: optional
  • request-parameters:
    • request identifier: An agent-unique identifier for matching corresponding request and reply at the agent.
  • reply-parameters (success):
    • request identifier: An identifier matching the identifier of the request.
    • group list: List of all groups that the agent can access. For each listed group, the identifier and the owner are indicated.
  • failure reason:
    • transaction not supported
    • agent not authorized for this transaction

semantics ๐ŸŒˆ

the agent can use this transaction type to list all groups it can access ๐Ÿ’œ usually the agent already has this info, but in special cases (like after an agent fail-over) or for special agents (like an administrating agent that can access all groups), this transaction is super helpful ๐Ÿซถ

the middlebox first checks whether the agent is authorized to request this transaction ๐Ÿ” if the check fails, an appropriate failure reply is generated ๐Ÿ˜ฌ otherwise, a list of all groups the agent can access is returned, showing the identifier and the owner of each group ๐ŸŽ€

this transaction does not have any effect on the group state ๐Ÿฆ‹

2.4.4. Group Status (GS) ๐Ÿ”

okay bestie, this one is GS, and it's basically the "wait, what's actually in this group??" transaction ๐Ÿ‘€

transaction-name: group status
transaction-type: monitoring
transaction-compliance: optional

Request parameters:

  • request identifier: an agent-unique ID so the agent can match the request to its reply ๐ŸŽ€
  • group identifier: points at the group you want the status of ๐Ÿงš

Reply parameters (success):

  • request identifier: matches the ID from the request, obviously ๐Ÿ’…
  • group owner: the ID of the agent that owns this policy rule group ๐Ÿ‘‘
  • group lifetime: how much lifetime the group has left. It's the maximum of the remaining lifetimes of all the members' policy rules, so it's the longest-living member that wins โณ
  • member list: every policy rule that's a member of the group, each one named by its middlebox-unique policy rule identifier ๐Ÿ“‹

Failure reasons:

  • transaction not supported
  • agent not authorized for this transaction
  • no such group
  • agent not authorized to list members of this group

Semantics:

The agent can use this transaction to list all the member policy rules of a group. Usually the agent already knows this stuff, but sometimes it doesn't, like after an agent fail-over, or for special agents like an administrating agent that can access every group. That's when GS is a total lifesaver ๐Ÿ™Œ

The middlebox checks two things first: does the group exist, and is the agent allowed to access it? If either check fails, it sends back an appropriate failure reply ๐Ÿ’€ Otherwise it returns the full list of group members, with the identifier of each one.

This transaction does not have any effect on the group state. It's a read-only glow-up, no changes made ๐Ÿฆ‹


3. Conformance Statements โœจ

okay so, a protocol definition complies with the semantics in section 2 if the protocol specification includes all the specified transactions with all of their mandatory parameters. BUT it's not required that an actual implementation of a middlebox supports every single one of these transactions ๐Ÿซถ And which transactions are required for compliance is different for agents and middleboxes, so don't mix them up ๐Ÿ˜ญ

This section has the conformance statements for MIDCOM protocol implementations as they relate to the semantics. Conformance looks different for agents and for middleboxes. A concrete protocol specification will probably extend these statements, but any extension is expected to extend them in a way that keeps all of them still holding ๐Ÿ’…

Here's the transaction-compliance property for every transaction from the previous section:

- Session Control Transactions
    - Session Establishment (SE)                 mandatory
    - Session Termination (ST)                   mandatory
    - Asynchronous Session Termination (AST)     mandatory

- Policy Rule Transactions
    - Policy Reserve Rule (PRR)                  mandatory
    - Policy Enable Rule (PER)                   mandatory
    - Policy Rule Lifetime Change (RLC)          mandatory
    - Policy Rule List  (PRL)                    mandatory
    - Policy Rule Status (PRS)                   mandatory
    - Asynchronous Policy Rule Event (ARE)       mandatory

- Policy Rule Group Transactions
    - Group Lifetime Change (GLC)                optional
    - Group List (GL)                            optional
    - Group Status (GS)                          optional

3.1. General Implementation Conformance ๐ŸŒธ

A compliant implementation of a MIDCOM protocol MUST support all mandatory transactions. Non-negotiable, no cap ๐Ÿ™…โ€โ™€๏ธ

A compliant implementation of a MIDCOM protocol MAY support none, one, or more of the following transactions: GLC, GL, GS. So the group ones are totally up to you ๐Ÿ’œ

A compliant implementation MAY extend the protocol semantics by further transactions. Main character energy, you can add more stuff โœจ

A compliant implementation of a MIDCOM protocol MUST support all mandatory parameters of each transaction concerning the information contained. The set of parameters can be redefined per transaction as long as the contained information is maintained. So you can rearrange the parameters, as long as the actual information survives the glow-up ๐Ÿฆ‹

A compliant implementation of a MIDCOM protocol MAY support the use of interface-specific policy rules. If you do support them, then either both or neither of the optional inside and outside interface parameters in PRR, PER, and PRS MUST be included. No half-and-half situations ๐Ÿ™ˆ

A compliant implementation MAY extend the list of parameters of transactions. More params, more fun ๐Ÿ“

A compliant implementation MAY replace a single transaction by a set of more fine-grained transactions. If you do that, it MUST be ensured that requirement 2.1.4 (deterministic behavior) and requirement 2.1.5 (known and stable state) of [MDC-REQ] are still met. When one transaction gets split into a set of smaller ones, that set MUST be equivalent to the single transaction. And this set of transactions MUST further meet the atomicity requirement stated in section 2.1.4. Very important, bestie, don't skip this ๐Ÿ˜ค

3.2. Middlebox Conformance ๐Ÿงš

A middlebox implementation of a MIDCOM protocol supports a request transaction if it can receive and process all possible correct message instances of that request transaction, and if it generates a correct reply for any correct request it gets ๐ŸŽ€

A middlebox implementation of a MIDCOM protocol supports an asynchronous transaction if it can generate the corresponding notification message properly ๐Ÿ””

A compliant middlebox implementation of a MIDCOM protocol must inform the agent about the list of supported transactions within the SE transaction. So the middlebox has to spill its supported transactions during SE, no secrets ๐Ÿคซ

3.3. Agent Conformance ๐Ÿซง

An agent implementation of a MIDCOM protocol supports a request transaction if it can generate the corresponding request message properly, and if it can receive and process all possible correct replies to that request ๐Ÿ’–

An agent implementation of a MIDCOM protocol supports an asynchronous transaction if it can receive and process all possible correct message instances of that transaction ๐ŸŒˆ

A compliant agent implementation of a MIDCOM protocol must not use any optional transaction that the middlebox doesn't support. The middlebox tells the agent which transactions it supports within the SE transaction, so the agent knows what's off the table ๐Ÿ™ƒ


4. Transaction Usage Examples ๐ŸŽ€

this section gives two usage examples of the transactions from section 2. The first one shows how an agent can explore all the policy rules and policy rule groups it's allowed to access at a middlebox ๐Ÿ” The second example shows how a middlebox gets configured alongside setting up a voice over IP session with the Session Initiation Protocol (SIP) [RFC3261]. It's giving real-world vibes ๐Ÿ“žโœจ

4.1. Exploring Policy Rules and Policy Rule Groups ๐Ÿ”

okay so this example assumes you already have an established session ๐Ÿ’– here's what an agent can figure out:

  • which groups it may access and who owns these groups,
  • the status and member list of all accessible groups, and
  • the status and properties of all accessible policy rules.

if there's just a single session, none of this is needed ๐Ÿ™ˆ the middlebox tells the agent about every state transition of any policy rule or policy rule group. BUT after the session gets disrupted or after an intentional session termination, the agent might want to re-establish the session and check which of the groups and policy rules it set up are still in place โœจ

also, an agent system might fail and another one takes over ๐Ÿ˜ญ then the new agent system needs to find out what the failing system already configured and what still needs to be done. main character energy for the recovery arc ๐ŸŽ€

a third situation where exploring policy rules and groups is useful is an agent with 'administrator' authorization ๐Ÿ‘‘ this agent may access and modify any policy rule or group created by any other agent. iconic power move ngl ๐Ÿ’…

all agents will probably start their exploration with the Group List (GL) transaction, as shown in Figure 5 ๐Ÿฆ‹ on this request, the middlebox returns a list of pairs, each containing an agent identifier and a group identifier (GID). so the agent learns which of its own groups it can access, and which other agents' groups it can access too ๐ŸŒธ

         agent                                     middlebox
          |                      GL                       |
          |**********************************************>|
          |<**********************************************|
          |   (agent1,GID1) (agent1,GID2) (agent2,GID3)   |
          |                                               |
          |                   GS GID2                     |
          |**********************************************>|
          |<**********************************************|
          |    agent1  lifetime  PID1  PID2  PID3  PID4   |
          |                                               |

Figure 5: Using the GL and the GS Transactions

in Figure 5, three groups are accessible to the agent, and it grabs info about the second group using the Group Status (GS) transaction ๐Ÿงš it gets back the owner of the group, the remaining lifetime, and the list of member policy rules. in this case that's four policy rule identifiers (PIDs) ๐Ÿ“

next up, the agent explores these four policy rules โœจ the example assumes the middlebox is a traditional NAPT. Figure 6 shows the exploration of the first policy rule. in reply to a Policy Rule Status (PRS) transaction, the middlebox always returns this list of parameters:

  • policy rule owner
  • group identifier
  • policy rule action (reserve or enable)
  • protocol type
  • port range
  • direction
  • internal IP address
  • internal port number
  • external address
  • external port number
  • middlebox inside IP address
  • middlebox inside port number
  • middlebox outside IP address
  • middlebox outside port number
  • IP address versions (not printed)
  • middlebox service (not printed)
  • inside and outside interface (optional, not printed)
         agent                                     middlebox
          |                   PRS PID1                    |
          |**********************************************>|
          |<**********************************************|
          |  agent1    GID2    RESERVE    UDP    1   ""   |
          | ANY         ANY         ANY         ANY       |
          | ANY         ANY         IPADR_OUT   PORT_OUT1 |
          |                                               |

Figure 6: Status Report for an Outside Reservation

the 'ANY' parameter in Figure 6 is just a placeholder in policy rule status replies for policy reserve rules ๐Ÿซถ the policy rule with PID1 is a policy reserve rule for UDP traffic at the outside of the middlebox. since it's a reserve rule, direction is empty. there's no internal or external address involved yet, so those four fields are wildcarded in the reply. same deal for the inside middlebox address and port number. the only address info in the reply is the reserved outside IP address of the middlebox (IPADR_OUT) and the matching port number (PORT_OUT1). note that IPADR_OUT and PORT_OUT1 may not be wildcarded, because the reserve action doesn't support that ๐Ÿ™ˆ

applying PRS to PID2 (Figure 7) shows the second policy rule is a policy enable rule for inbound UDP packets ๐ŸŒˆ the internal destination is fixed when it comes to IP address, protocol, and port number, but for the external source, the port number is wildcarded. the outside IP address and port number of the middlebox are what the external sender needs to use as destination in the original packet it sends. at the middlebox, the destination address gets replaced with the internal address of the final receiver. during address translation, the source IP address and source port numbers of the packets stay unchanged. you can tell from the inside address, which is identical to the external address ๐Ÿฆ‹

         agent                                     middlebox
          |                   PRS PID2                    |
          |**********************************************>|
          |<**********************************************|
          |       agent1  GID2  ENABLE  UDP  1  IN        |
          | IPADR_INT   PORT_INT1   IPADR_EXT   ANY       |
          | IPADR_EXT   ANY         IPADR_OUT   PORT_OUT2 |
          |                                               |

Figure 7: Status Report for Enabled Inbound Packets

for traditional NATs, the inside IP address and port number always match the external IP address and port number (A1=A3 in Figure 3) ๐Ÿ’œ for a pure firewall, the outside IP address and port number are always identical with the internal IP address and port number (A0=A2 in Figure 3).

         agent                                     middlebox
          |                   PRS PID3                    |
          |**********************************************>|
          |<**********************************************|
          |       agent1  GID2  ENABLE  UDP  1  OUT       |
          | IPADR_INT   PORT_INT2   IPADR_EXT   PORT_EXT1 |
          | IPADR_EXT   PORT_EXT1   IPADR_OUT   PORT_OUT3 |
          |                                               |

Figure 8: Status Report for Enabled Outbound Packets

Figure 8 shows enabled outbound UDP communication between the same host ๐ŸŽ€ here all port numbers are known. since A1=A3 again, the internal sender uses the external IP address and port number as destination in the original packets. at the firewall, the internal source IP address and port number get replaced by the shown outside IP address and port number of the middlebox โœจ

         agent                                     middlebox
          |                   PRS PID4                    |
          |**********************************************>|
          |<**********************************************|
          |       agent1  GID2  ENABLE  TCP  1  BI        |
          |  IPADR_INT   PORT_INT3  IPADR_EXT   PORT_EXT2 |
          |  IPADR_EXT   PORT_EXT2  IPADR_OUT   PORT_OUT4 |
          |                                               |

Figure 9: Status Report for Bidirectional TCP Traffic

finally, Figure 9 shows the status report for enabled bidirectional TCP traffic ๐Ÿ”ฅ note that A1=A3 still holds. for outbound packets, only the source IP address and port number get replaced at the middlebox, and for inbound packets, only the destination IP address and port number get replaced.

4.2. Enabling a SIP-Signaled Call ๐Ÿ“ž

this elaborated transaction usage example shows the interaction between a back-to-back user agent (B2BUA) and a middlebox ๐Ÿ’– the middlebox itself is a traditional Network Address and Port Translator (NAPT), and two SIP user agents talk to each other through the B2BUA and a NAPT, as shown in Figure 10 ๐Ÿฆ‹ the MIDCOM agent is co-located with the B2BUA, and the MIDCOM server is at the middlebox. so the MIDCOM protocol runs between the B2BUA and the middlebox ๐Ÿงš

               +-------------+
               | B2BUA       |
               | for domain  ++++
               | example.com |  +
               +-------------+  +
                    ^   ^       +
        Private     |   |       +     Public Network
        Network     |   |       +
      +----------+  |   |  +----+------+         +----------------+
      | SIP User |<-+   +->| Middlebox |<------->| SIP User Agent |
      | Agent A  |<#######>|   NAPT    |<#######>| B@example.org  |
      +----------+         +-----------+         +----------------+


      <--> SIP signaling
      <##> RTP traffic
      ++++ MIDCOM protocol

Figure 10: Example of a SIP Scenario

for the sequence charts below, we're making these assumptions ๐ŸŒธ

  • The NAPT is statically configured to forward SIP signaling from the outside to the B2BUA -- i.e., traffic to the NAPT's external IP address and port 5060 is forwarded to the internal B2BUA.
  • The SIP user agent A, located inside the private network, is registered at the B2BUA with its private IP address.
  • User A knows the general SIP URL of user B. The URL is B@example.org. However, the concrete URL of the SIP user agent B, which user B currently uses, is not known.
  • The RTP paths are configured, but not the RTP Control Protocol (RTCP) paths.
  • The middlebox and the B2BUA share an established MIDCOM session.
  • Some parameters are omitted, such as the request identifier (RID).

and here are the abbreviations we'll be using ๐Ÿ“

  • IP_AI: Internal IP address of user agent A
  • P_AI: Internal port number of user agent A to receive RTP data
  • P_AE: External mapped port number of user agent A
  • IP_AE: External IP address of the middlebox
  • IP_B: IP address of user agent B
  • P_B: Port number of user agent B to receive RTP data
  • GID: Group identifier
  • PID: Policy rule identifier

the abbreviations of the MIDCOM transactions can be found in the particular section headings โœจ

in our example, user A tries to call user B ๐Ÿ“ž the user agent A sends an INVITE SIP message to the B2BUA (see Figure 10). the SDP part of that SIP message that matters for the middlebox configuration is shown in the sequence chart like this:

SDP: m=..P_AI..
     c=IP_AI

where the m tag is the media tag that contains the receiving UDP port number, and the c tag contains the IP address of the terminal receiving the media stream ๐Ÿซถ

the INVITE message forwarded to user agent B must contain a public IP address and a port number that user agent B can send its RTP media stream to. the B2BUA requests a policy enable rule at the middlebox with a PER request, using the wildcarded IP address and port number of user agent B ๐Ÿ™ˆ since neither the IP address nor the port numbers of user agent B are known at this point, the address of user agent B must be wildcarded. the wildcarded IP address and port number enable the 'early media' capability, but this comes with some insecurity, because any outside host can reach user agent A on the enabled port number through the middlebox ๐Ÿ˜ญ

Okay, Figure 11 is where it gets spicy ๐ŸŒถ๏ธ

   User Agent      B2BUA                       Middlebox   User Agent
    A                                             NAPT             B
    |                |                              |              |
    | INVITE         |                              |              |
    | B@example.org  |                              |              |
    | SDP:m=..P_AI.. |                              |              |
    |     c=IP_AI    |                              |              |
    |--------------->|                              |              |
    |                |                              |              |
    |                |  PER PID1 UDP 1 EVEN IN      |              |
    |                |   IP_AI P_AI ANY ANY 300s    |              |
    |                |*****************************>|              |
    |                |<*****************************|              |
    |                |    PER OK GID1 PID1 ANY ANY  |              |
    |                |       IP_AE P_AE1 300s       |              |

Figure 11: PER with Wildcard Address and Port Number

So a successful PER reply, like the one in Figure 11, creates a NAT binding at the middlebox ๐Ÿฆ‹. That binding lets UDP traffic from any host outside user agent A's private network reach user agent A ๐Ÿ˜ณ. User agent B could start sending traffic the second it gets the INVITE, and so could literally any other host, even ones that aren't supposed to be in the call, like a malicious host ๐Ÿ’€. Not it! ๐Ÿ™…

If the middlebox doesn't support or doesn't permit IP address wildcarding for security reasons, the PER request gets rejected with an appropriate failure reason, like 'IP wildcarding not supported' ๐Ÿฅฒ. Even so, the B2BUA still needs an outside IP address and port number at the middlebox (the NAPT) so it can forward the SIP INVITE message โœจ.

If user agent B's IP address is still unknown (B sends it in the SIP reply) and wildcarding isn't permitted, the B2BUA goes with the PRR transaction ๐Ÿงš.

   User Agent      B2BUA                       Middlebox   User Agent
    A                                             NAPT             B
    |                |                              |              |
       ...PER in Figure 11 has failed, continuing with PRR ...
    |                |                              |              |
    |                |PRR tw v4 v4 A UDP 1 EVEN 300s|              |
    |                |*****************************>|              |
    |                |<*****************************|              |
    |                | PRR OK PID1 GID1 EMPTY       |              |
    |                |  IP_AE/P_AE 300s             |              |
    |                |                              |              |
    |                | INVITE B@example.org SDP:m=..P_AE.. c=IP_AE |
    |                |-------------------------------------------->|
    |                |<--------------------------------------------|
    |                |       200 OK  SDP:m=..P_B.. c=IP_B          |

Figure 12: Address Reservation with PRR Transaction

With a PRR request, the B2BUA asks for an outside IP address and port number (see Figure 12) without setting up a NAT binding or pin hole ๐ŸŒธ. The PRR request carries the service parameter tw, which means the MIDCOM agent picks the default value ๐Ÿ’…. In this setup (NAPT, no twice-NAT), only an outside address gets reserved. Then the B2BUA swaps user agent A's IP address and port in the SDP payload of the INVITE for the reserved IP address and port from the PRR reply, and forwards the INVITE to user agent B with that modified SDP body. So user agent B knows exactly where to send its RTP media stream ๐ŸŽ€.

That SIP 200 OK reply tells us the IP address and port where user agent B will receive a media stream ๐Ÿซถ. The IP address is assumed to be the same one user agent B will send its media stream from ๐Ÿ‘€.

Now the B2BUA has everything it needs to set up the full NAT binding with a policy enable rule (PER) transaction, so UDP/RTP data can flow from user agent B to user agent A ๐Ÿ”ฅ. This PER transaction points to the reservation by passing the PID of the PRR, which is PID1.

The other direction, UDP/RTP from A to B, needs enabling too ๐Ÿ™ˆ. That's a second PER transaction with all the necessary parameters (see Figure 13). This request carries the group identifier GID1 that the middlebox assigned in the first PER transaction, so both policy rules end up in the same group ๐Ÿ‘‘. Once both UDP/RTP streams are enabled, the B2BUA forwards the 200 OK SIP message to user agent A to say the call can start ๐Ÿ“žโœจ.

   User Agent      B2BUA                       Middlebox   User Agent
    A                                             NAPT             B
    |                |                              |              |
    |                |  PER PID1 UDP 1 SAME IN      |              |
    |                |   IP_AI P_AI IP_B ANY 300s   |              |
    |                |*****************************>|              |
    |                |<*****************************|              |
    |                |    PER OK GID1 PID1 IP_B ANY |              |
    |                |       IP_AE P_AE1 300s       |              |
    |                |                              |              |
            ...media stream from user agent B to A enabled...
    |                |                              |              |
    |                |  PER GID1 UDP 1 SAME OUT     |              |
    |                |    IP_AI ANY IP_B P_B 300s   |              |
    |                |*****************************>|              |
    |                |<*****************************|              |
    |                |   PER OK GID1 PID2 IP_B P_B  |              |
    |                |       IP_AE P_AE2 300s       |              |
    |                |                              |              |
             ...media streams from both directions enabled...
    |                |                              |              |
    |    200 OK      |                              |              |
    |<---------------|                              |              |
    | SDP:m=..P_B..  |                              |              |
    |     c=IP_B     |                              |              |

Figure 13: Policy Rule Establishment for UDP Flows

User agent B decides to end the call and sends its BYE SIP message to user agent A ๐Ÿ˜ญ. The B2BUA forwards all SIP messages and then terminates the group using a group lifetime change (GLC) transaction with a requested remaining lifetime of 0 seconds (see Figure 14) ๐Ÿ’€. Terminating the group also terminates all member policy rules ๐Ÿงน.

   User Agent      B2BUA                       Middlebox   User Agent
    A                                             NAPT             B
    |                |                              |              |
    |     BYE        |                     BYE                     |
    |<---------------|<--------------------------------------------|
    |                |                              |              |
    |    200 OK      |                   200 OK                    |
    |--------------->|-------------------------------------------->|
    |                |                              |              |
    |                |         GLC GID1 0s          |              |
    |                |*****************************>|              |
    |                |<*****************************|              |
    |                |         GLC OK 0s            |              |
    |                |                              |              |
       ...both NAT bindings for the media streams are removed...

Figure 14: Termination of Policy Rule Groups

5. Compliance with MIDCOM Requirements โœจ

This section explains how the specified semantics comply with the MIDCOM requirements ๐Ÿ“‹. It's structured according to [MDC-REQ]:

  • Compliance with Protocol Machinery Requirements (section 5.1)
  • Compliance with Protocol Semantics Requirements (section 5.2)
  • Compliance with Security Requirements (section 5.3)

The requirements are referred to with the number of the section in which they are defined: "requirement x.y.z" refers to the requirement specified in section x.y.z of [MDC-REQ] ๐Ÿง .

5.1. Protocol Machinery Requirements ๐Ÿ”ง

5.1.1. Authorized Association ๐Ÿ”

The specified semantics lets a MIDCOM agent set up an authorized association between itself and the middlebox ๐Ÿค. The agent identifies itself using the authentication mechanism of the Session Establishment transaction described in section 2.2.1. Based on that authentication, the middlebox can figure out whether or not the agent is allowed to request a service. So requirement 2.1.1 is met โœ….

5.1.2. Agent Connects to Multiple Middleboxes ๐ŸŒ

As specified in section 2.2, the MIDCOM protocol lets the agent talk to more than one middlebox at the same time ๐Ÿ™Œ. How the different sessions get separated is left to the concrete protocol definition. It must provide a clear mapping of protocol messages to open sessions. Then requirement 2.1.2 is met ๐Ÿ’–.

5.1.3. Multiple Agents Connect to Same Middlebox ๐Ÿ‘ฏ

As specified in section 2.2, the MIDCOM protocol lets the middlebox talk to more than one agent at the same time ๐Ÿ™Œ. Again, how the sessions get separated is left to the concrete protocol definition. It must provide a clear mapping of protocol messages to open sessions. Then requirement 2.1.3 is met ๐ŸŽ‰.

5.1.4. Deterministic Behavior ๐ŸŽฒ

Section 2.1.2 says that the processing of an agent's request may not be interrupted by any request of the same or another agent ๐Ÿ›‘. This gives atomicity among request transactions and avoids race conditions that would cause unpredictable behavior by the middlebox ๐Ÿงฑ.

The middlebox's behavior can only be predictable in the view of its administrators ๐Ÿ‘ฉโ€๐Ÿ’ผ. From an agent's point of view, the middlebox behavior is unpredictable, because the administrator can, for example, change the agent's authorization at any time without the agent being able to see that change ๐Ÿ˜ตโ€๐Ÿ’ซ. So the middlebox behavior is not necessarily deterministic from the point of view of any agent.

Since predictability of the middlebox behavior is given for its administrator, requirement 2.1.4 is met ๐Ÿฅณ.

5.1.5. Known and Stable State โœจ

okay so section 2.1 says request transactions are atomic with respect to each other and from the point of view of an agent ๐Ÿซถ every transaction is clearly defined as a state transition that either leaves the current stable, well-defined state and enters a new stable, well-defined one, or stays put in the current stable, well-defined state. section 2.1 also clearly demands that intermediate states are not stable and are not reported to any agent. no in-between drama, bestie ๐Ÿ’…

for each state transition, a message gets sent to the matching agent, either a reply or a notification. the agent can uniquely map each reply to one of the requests it sent to the middlebox, because agent-unique request identifiers are used for exactly this purpose ๐Ÿ”ฅ and notifications are self-explanatory by their definition ๐Ÿ’–

the Group List transaction (section 2.4.3), the Group Status transaction (section 2.4.4), the Policy Rule List transaction (section 2.3.11), and the Policy Rule Status transaction (section 2.3.12) let the agent check in at any time during a session to retrieve information about:

  • all policy rule groups it may access,
  • the status and member policy rules of all accessible groups,
  • all policy rules it may access, and
  • the status of all accessible policy rules.

so the agent is precisely informed about the state of the middlebox (as far as the services requested by the agent are affected) ๐Ÿ‘‘ which means requirement 2.1.5 is met โœจ

5.1.6. Status Report ๐ŸŽ€

as argued in the previous section, the middlebox unambiguously informs the agent about every state transition related to any of the services the agent requested ๐Ÿฆ‹ and at any time the agent can retrieve full status information about all accessible policy rules and policy rule groups. no mysteries, no ghosting ๐Ÿ™ˆ so requirement 2.1.6 is met ๐Ÿ’…

5.1.7. Unsolicited Messages (Asynchronous Notifications) ๐Ÿ””

the semantics includes asynchronous notification messages from the middlebox to the agent, including the Session Termination Notification (STN) message, the Policy Rule Event Notification (REN) message, and the Group Event Notification (GEN) message (see section 2.1.2) ๐Ÿ’œ these notifications report every change of state of policy rules or policy rule groups that the agent did not explicitly ask for. thus, requirement 2.1.7 is met by the semantics specified above ๐ŸŒธ

5.1.8. Mutual Authentication ๐Ÿ”

as specified in section 2.2.1, the semantics requires mutual authentication of agent and middlebox, either by using two subsequent Session Establishment transactions or by mutual authentication provided on a lower protocol layer ๐Ÿซถ so requirement 2.1.8 is met, iconic behaviour ๐Ÿ‘‘

5.1.9. Session Termination by Any Party ๐Ÿšช

the semantics specification states in section 2.2.2 that the agent may request session termination by generating the Session Termination request, and that the middlebox may not reject this request ๐Ÿ’… in turn, section 2.2.3 states that the middlebox may send the Asynchronous Session Termination notification at any time and then terminate the session. either side can end it, which means requirement 2.1.9 is met โœจ

5.1.10. Request Result ๐Ÿ“ฌ

section 2.1 states that each request from an agent is followed by a reply from the middlebox indicating either success or failure. so requirement 2.2.10 is met ๐Ÿ“

5.1.11. Version Interworking ๐Ÿงš

section 2.2.1 says the agent needs to specify the protocol version number it will use during the session. the middlebox may accept this and act according to that protocol version, or it may reject the session if it does not support that version ๐ŸŒˆ if the session setup gets rejected, the agent may try again with another version. thus, requirement 2.2.11 is met ๐Ÿ’–

5.1.12. Deterministic Handling of Overlapping Rules ๐Ÿ”ฎ

the only policy rule actions specified are 'reserve' and 'enable' ๐Ÿฆ‹ for firewalls, overlapping enable actions or reserve actions do not create any conflict, so a firewall will always accept overlapping rules as specified in section 2.3.2 (assuming the required authorization is given) ๐Ÿ”ฅ

for NATs, reserve and enable may conflict ๐Ÿ™ˆ if a conflicting request arrives, it is rejected, as stated in section 2.3.2. if an overlapping request arrives that does not conflict with the ones it overlaps, it is accepted (assuming the required authorization is given) โœจ

so the behaviour of the middlebox in the presence of overlapping rules can be predicted deterministically, and requirement 2.1.12 is met ๐Ÿ‘‘


5.2. Protocol Semantics Requirements ๐Ÿ’œ

5.2.1. Extensible Syntax and Semantics ๐Ÿงฉ

requirement 2.2.1 explicitly asks for extensibility of protocol syntax ๐ŸŒธ this needs to be addressed by the concrete protocol definition. the semantics specification is extensible anyway, because new transactions may be added ๐Ÿซถ

5.2.2. Policy Rules for Different Types of Middleboxes ๐Ÿ›ก๏ธ

section 2.3 explains that the semantics uses identical transactions for all middlebox types, and that the same policy rule can be applied to all of them ๐Ÿ’… thus, requirement 2.2.2 is met โœจ

5.2.3. Ruleset Groups ๐Ÿ—‚๏ธ

the semantics explicitly supports grouping of policy rules, and transactions on policy rule groups, as described in section 2.4 ๐ŸŽ€ the group transactions can be used for lifetime extension and termination of all policy rules that are members of the particular group. thus, requirement 2.2.3 is met ๐Ÿ‘‘

5.2.4. Policy Rule Lifetime Extension โณ

the semantics includes a transaction for explicit lifetime extension of policy rules, as described in section 2.3.3 ๐Ÿฆ‹ so requirement 2.2.4 is met ๐Ÿ’–

5.2.5. Robust Failure Modes ๐Ÿ›Ÿ

the state transitions at the middlebox are clearly specified and communicated to the agent ๐Ÿ’… there is no intermediate state reached by a partial processing of a request. all requests are always processed completely, either successfully or unsuccessfully ๐Ÿ”ฅ all request transactions include a list of failure reasons, and these failure reasons cover indication of invalid parameters where applicable. in case of failure, one of the specified reasons is returned from the middlebox to the agent. thus, requirement 2.2.5 is met โœจ

5.2.6. Failure Reasons ๐Ÿ™…โ€โ™€๏ธ

the semantics includes a failure reason parameter in each failure reply. thus, requirement 2.2.6 is met ๐ŸŒˆ

5.2.7. Multiple Agents Manipulating Same Policy Rule ๐Ÿ‘ฏโ€โ™€๏ธ

as specified in sections 2.3 and 2.4, each installed policy rule and policy rule group has an owner, which is the authenticated agent that created the policy rule or group, respectively ๐Ÿ’œ the authenticated identity is the input used to authorize access to policy rules and groups.

if the middlebox is sufficiently configurable, its administrator can set it up so that one authenticated agent is authorized to access and modify policy rules and groups owned by another agent ๐Ÿซถ because the specified semantics does not preclude this, it meets requirement 2.2.7 ๐ŸŽ€

5.2.8. Carrying Filtering Rules ๐Ÿงบ

the Policy Enable Rule transaction specified in section 2.3.8 can carry 5-tuple filtering rules ๐Ÿ”ฅ this meets requirement 2.2.8 ๐Ÿ’…

5.2.9. Parity of Port Numbers ๐Ÿฆ„

as specified in section 2.3.6, the agent is able to request keeping the port parity when reserving port numbers with the PRR transaction (see section 2.3.8), and when establishing address bindings with the PER transaction (see section 2.3.9) โœจ thus, requirement 2.2.9 is met ๐Ÿ“

5.2.10. Consecutive Range of Port Numbers ๐Ÿ”ข

as specified in section 2.3.6, the agent is able to request a consecutive range of port numbers when reserving port numbers with the PRR transaction (see section 2.3.8), and when establishing address bindings or pinholes with the PER transaction (see section 2.3.9) ๐Ÿ’– thus, requirement 2.2.10 is met ๐Ÿ‘‘

5.2.11. Contradicting Overlapping Policy Rules ๐Ÿ™ƒ

requirement 2.2.11 is based on the assumption that contradictory policy rule actions, such as 'enable'/'allow' and 'disable'/'disallow', are supported ๐Ÿง in conformance with decisions the working group made after finalizing the requirements document, this requirement is not met by the semantics, because no 'disable'/'disallow' action is supported ๐Ÿ’€


5.3. Security Requirements ๐Ÿ”

5.3.1. Authentication, Confidentiality, Integrity ๐Ÿ›ก๏ธ

the semantics definition supports mutual authentication of agent and middlebox in the Session Establishment transaction (section 2.2.1) ๐Ÿ’œ the use of an underlying protocol such as TLS or IPsec is mandatory. thus, requirement 2.3.1 is met ๐Ÿ”’โœจ

5.3.2. Optional Confidentiality of Control Messages ๐Ÿคซ

the use of IPsec or TLS allows agent and middlebox to use an encryption method, including no encryption ๐Ÿซถ thus, requirement 2.3.2 is met ๐ŸŒธ

5.3.3. Operation across Untrusted Domains ๐ŸŒ

operation across untrusted domains is supported by mutual authentication and by the use of TLS or IPsec protection ๐Ÿฆ‹ thus, requirement 2.3.3 is met ๐Ÿ’…

5.3.4. Mitigate Replay Attacks ๐Ÿ”

the specified semantics mitigates replay attacks and meets requirement 2.3.4 by requiring mutual authentication of agent and middlebox, and by mandating the use of TLS or IPsec protection ๐Ÿ”ฅ

further mitigation can be provided as part of a concrete MIDCOM protocol definition -- for example, by requiring consecutively increasing numbers for request identifiers ๐Ÿ”ขโœจ

6. Security Considerations ๐Ÿ”โœจ

Okay bestie, security is where things get SERIOUS ๐Ÿซถ The agent and middlebox talking to each other is a super sensitive spot, because it kinda feels like it goes against what a middlebox even is. Like, getting policy rules from something outside the middlebox? Iykyk ๐Ÿ’€ So effective means have to be used to ensure all of these:

  • mutual authentication between agent and middlebox,
  • authorization,
  • message integrity, and
  • message confidentiality.

The semantics has a mechanism for mutual authentication between agent and middlebox (see section 2.2.1). Once authentication is in place, the middlebox can decide whether an agent is authorized to request an action at the middlebox ๐Ÿ‘‘ For integrity and confidentiality of the transferred data between both entities, the semantics relies on underlying protocols, such as TLS or IPsec.

For the TLS and IPsec use, both sides must use securely configured credentials for authentication and authorization ๐Ÿ”’

Wildcarding IP addresses and port numbers in policy rules comes with some risks, like accidentally opening overly wildcarded policy rules ๐Ÿ˜ฌ An excessively wildcarded policy rule would be A0 and A3 with the IP address set to 'any' IP address, for instance. That kind of pinhole makes the middlebox useless from a security point of view, because any packet could traverse it without further checking. The local policy of the middlebox should reject such policy rule enable requests.

A reasonable default for wildcarding would be that only one port number may be wildcarded and all IP addresses must be set without wildcarding โœจ That said, sometimes security has to be balanced with functionality.

The example in section 4.2 shows how SIP-signaled calls can be served securely without wildcarding IP addresses ๐ŸŽ€ But some SIP-signaled applications make use of early media (see section 5.5 of [RFC3398]). To receive early media, the middleboxes need to be configured before the second participant in a session is known. Since that isn't known yet, the IP address of the second participant needs to be wildcarded ๐Ÿ™ˆ

In cases like this and several similar ones, the middlebox operator has a security policy decision to make ๐Ÿ’… The operator can configure the middlebox to support more functionality, for example by allowing wildcarded IP addresses. Or they can make network operation more secure, for example by disallowing wildcarded IP addresses.


7. IAB Considerations on UNSAF ๐Ÿฆ‹

UNilateral Self-Address Fixing (UNSAF) is described in [RFC3424] as a process at originating endpoints that attempt to determine or fix the address (and port) by which they are known to another endpoint. UNSAF proposals, such as Simple Traversal of the UDP Protocol through NAT (STUN) [RFC3489], are considered a general class of workarounds for NAT traversal, and as solutions for scenarios with no middlebox communication (MIDCOM).

This document describes the protocol semantics for such a middlebox communication (MIDCOM) solution. MIDCOM is not intended as a short-term workaround, but more as a long-term solution for middlebox communication ๐ŸŒธ In MIDCOM, endpoints are not involved in allocating, maintaining, and deleting addresses and ports at the middlebox. The full control of addresses and ports at the middlebox is located at the MIDCOM server.

Therefore, this document addresses the UNSAF considerations in [RFC3424] by proposing a long-term alternative solution ๐Ÿงš

8. Acknowledgements ๐Ÿ’œ

We would like to thank all the people contributing to the semantics discussion on the mailing list for a lot of valuable comments ๐Ÿซถ

9. References ๐Ÿ“š

9.1. Normative References

  • [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

9.2. Informative References

  • [MDC-FRM] Srisuresh, P., Kuthan, J., Rosenberg, J., Molitor, A., and A. Rayhan, "Middlebox communication architecture and framework", RFC 3303, August 2002.
  • [MDC-REQ] Swale, R., Mart, P., Sijben, P., Brim, S., and M. Shore, "Middlebox Communications (midcom) Protocol Requirements", RFC 3304, August 2002.
  • [MDC-SEM] Stiemerling, M., Quittek, J., and T. Taylor, "Middlebox Communications (MIDCOM) Protocol Semantics", RFC 3989, February 2005.
  • [NAT-TERM] Srisuresh, P. and M. Holdrege, "IP Network Address Translator (NAT) Terminology and Considerations", RFC 2663, August 1999.
  • [NAT-TRAD] Srisuresh, P. and K. Egevang, "Traditional IP Network Address Translator (Traditional NAT)", RFC 3022, January 2001.
  • [RFC4346] Dierks, T. and E. Rescorla, "The Transport Layer Security (TLS) Protocol Version 1.1", RFC 4346, April 2006.
  • [RFC4302] Kent, S., "IP Authentication Header", RFC 4302, December 2005.
  • [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", RFC 4303, December 2005.
  • [RFC3198] Westerinen, A., Schnizlein, J., Strassner, J., Scherling, M., Quinn, B., Herzog, S., Huynh, A., Carlson, M., Perry, J., and S. Waldbusser, "Terminology for Policy-Based Management", RFC 3198, November 2001.
  • [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, A., Peterson, J., Sparks, R., Handley, M., and E. Schooler, "SIP: Session Initiation Protocol", RFC 3261, June 2002.
  • [RFC3398] Camarillo, G., Roach, A., Peterson, J., and L. Ong, "Integrated Services Digital Network (ISDN) User Part (ISUP) to Session Initiation Protocol (SIP) Mapping", RFC 3398, December 2002.
  • [RFC3424] Daigle, L. and IAB, "IAB Considerations for UNilateral Self-Address Fixing (UNSAF) Across Network Address Translation", RFC 3424, November 2002.
  • [RFC3489] Rosenberg, J., Weinberger, J., Huitema, C., and R. Mahy, "STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)", RFC 3489, March 2003.

Appendix A. Changes from RFC 3989 โœจ

  1. The example in section 4.2 used a SIP proxy server modifying the body of a SIP message. This was a violation of RFC 3261. This has been fixed by replacing the SIP proxy server with a back-to-back user agent.
  2. Clarifications concerning the used set of transaction types have been added.
  3. Section 3.1, "General Implementation Conformance", now uses key words from RFC 2119.
  4. Minor editorial changes have been made and references have been updated.

Authors' Addresses ๐Ÿ’Œ

Martin Stiemerling
NEC Europe Ltd.
Kurfuersten-Anlage 36
69115 Heidelberg
Germany

Phone: +49 6221 4342-113
EMail: stiemerling@nw.neclab.eu


Juergen Quittek
NEC Europe Ltd.
Kurfuersten-Anlage 36
69115 Heidelberg
Germany

Phone: +49 6221 4342-115
EMail: quittek@nw.neclab.eu


Tom Taylor
Nortel
1852 Lorraine Ave.
Ottawa, Ontario
Canada  K1H 6Z8

Phone: +1 613 763 1496
EMail: tom.taylor@rogers.com

Copyright (C) The IETF Trust (2008).

This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights.

This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

Intellectual Property ๐ŸŒˆ

The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79.

Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr.

The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf-ipr@ietf.org.

๐Ÿ“ฆ where this page comes from