Wiki: iRules API


Historically, the BIG-IP full-proxy architecture has focused on flow-based processing, and this works very well for most protocols. However, some message based protocols aggregate distinct message streams in a single flow. Originally, iRules that needed to manage these protocols used the Message Based Load Balancing (MBLB) interface. This approach, while powerful, handled message flows but did not provide fine-grained control for directing messages to particular peers based on the contents, and also provided no built-in methods for message processing. It was all handled in iRules. In version 11.5, F5 introduced the Message Routing Framework (MRF) to BIG-IP. This framework allows the creation of sophisticated message and peer handling. It decouples peers, the transport used with peers, and both the forwarding and persistence of messages. Initially, a generic message handling interface was provided (see the GENERICMESSAGE methods for additional details). Starting with 11.6, SIP message handling was modified so that it uses MRF. In 12.0, Diameter was also modified to use MRF.

The iRule commands below are used to interact with the MRF message routers and peers.


  • MR::connection_instance - returns the connection instance and the number of connections
  • MR::connection_mode - returns the connection mode of the current connection
  • MR::equivalent_transport - gets or sets the transport that is usable as an equivalent transport
  • MR::flow_id - returns a unique identifier for the current connection
  • MR::ignore_peer_port - sets or resets the ignore_peer_port mode of the current connection
  • MR::instance - returns the name of the current mr_router instance
  • MR::max_retries - returns the number of retries allows for this router instance
  • MR::message - returns or sets details in the message routing table
  • MR::peer - defines a peer to use for routing a message to
  • MR::prime - establishes an outgoing connection to the specified host or hosts using the specified transport
  • MR::protocol - returns ‘generic, ‘sip’ or ‘diameter’
  • MR::restore - returns the stored variables to the current context tcl variable store
  • MR::retry - sends the current message to the router for routing
  • MR::store - stores a tcl variable with the mr_message object
  • MR::transport - returns the name and type (virtual or config) of the transport used to configure the current connection


  • MR_EGRESS - raised after the route has been selected and processed and the message is delivered to the mr_proxy
  • MR_INGRESS - raised when a message is received by the message proxy and before a route lookup occurs
  • MR_FAILED - raised when a message has been returned to the originating flow due to a routing failure