<commit_before># QoS policies

Unlike other middlewares, e.g. [DDS used in ROS 2](https://docs.ros.org/en/galactic/Concepts/About-Quality-of-Service-Settings.html),
iceoryx keeps things simple and offers basic Quality of Service (QoS) settings. The QoS
settings are called options and can be used to optimize and tailor the communication.

## `PublisherOptions` and `SubscriberOptions`

The three most important settings are:

| Option                              | Explanation                                                                                                                    |
|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `PublisherOptions::historyCapacity` | This enables late-joining subscribers to request the n last samples                                                            |
| `SubscriberOptions::queueCapacity`  | Size of the subscriber queue where samples are stored before they are passed to the user                                       |
| `SubscriberOptions::historyRequest` | The number of samples a late-joining subscriber will request from a publisher, must be equal or smaller than `historyCapacity` |

For more information about the options see the corresponding example [`iceoptions`](../getting-started/examples/iceoptions.md).

## Publisher subscriber matching criteria

Two criteria have to be fulfilled in order for a publisher and a subscriber to be connected.

 1. Same `capro::ServiceDescription`
 2. Matching `SubscriberTooSlowPolicy` and `QueueFullPolicy` in `PublisherOptions` and `SubscriberOptions`

### Compatible policies

| `SubscriberTooSlowPolicy` | `QueueFullPolicy`     | Behavior                                  | Connection            |
|---------------------------|-----------------------|-------------------------------------------|-----------------------|
| `WAIT_FOR_SUBSCRIBER`     | `BLOCK_PUBLISHER`     | Publisher blocks and waits for subscriber | :white_check_mark:    |
| `WAIT_FOR_SUBSCRIBER`     | `DISCARD_OLDEST_DATA` | Non-blocking publisher                    | :white_check_mark:    |
| `DISCARD_OLDEST_DATA`     | `DISCARD_OLDEST_DATA` | Non-blocking publisher                    | :white_check_mark:    |
| `DISCARD_OLDEST_DATA`     | `BLOCK_PUBLISHER`     | Not compatible, no connection established | :x:                   |<commit_msg>iox-#743 Clarify relationship between historyCapacity and historyRequest in docs<commit_after># QoS policies

Unlike other middlewares, e.g. [DDS used in ROS 2](https://docs.ros.org/en/galactic/Concepts/About-Quality-of-Service-Settings.html),
iceoryx keeps things simple and offers basic Quality of Service (QoS) settings. The QoS
settings are called options and can be used to optimize and tailor the communication.

## `PublisherOptions` and `SubscriberOptions`

The three most important settings are:

| Option                              | Explanation                                                                                                                                       |
|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `PublisherOptions::historyCapacity` | This enables late-joining subscribers to request the n last samples                                                                               |
| `SubscriberOptions::queueCapacity`  | Size of the subscriber queue where samples are stored before they are passed to the user                                                          |
| `SubscriberOptions::historyRequest` | The number of samples a late-joining subscriber will request from a publisher, should be equal or smaller than `historyCapacity` otherwise capped |

For more information about the options see the corresponding example [`iceoptions`](../getting-started/examples/iceoptions.md).

## Publisher subscriber matching criteria

Two criteria have to be fulfilled in order for a publisher and a subscriber to be connected.

 1. Same `capro::ServiceDescription`
 2. Matching `SubscriberTooSlowPolicy` and `QueueFullPolicy` in `PublisherOptions` and `SubscriberOptions`

### Compatible policies

| `SubscriberTooSlowPolicy` | `QueueFullPolicy`     | Behavior                                  | Connection            |
|---------------------------|-----------------------|-------------------------------------------|-----------------------|
| `WAIT_FOR_SUBSCRIBER`     | `BLOCK_PUBLISHER`     | Publisher blocks and waits for subscriber | :white_check_mark:    |
| `WAIT_FOR_SUBSCRIBER`     | `DISCARD_OLDEST_DATA` | Non-blocking publisher                    | :white_check_mark:    |
| `DISCARD_OLDEST_DATA`     | `DISCARD_OLDEST_DATA` | Non-blocking publisher                    | :white_check_mark:    |
| `DISCARD_OLDEST_DATA`     | `BLOCK_PUBLISHER`     | Not compatible, no connection established | :x:                   |
{'fraction_non_alphanumeric': 0.1798262929332807, 'fraction_numerical': 0.0017765495459928938, 'mean_word_length': 1.6253886010362695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 23, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1769174', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1060, 'n_words': 362}