# Packet Switching Fabric

## Overall Design

This implementation relies upon a packet-switching fabric that applies business logic to each packet in order to ensure that packets meet various preconditions and can be properly routed. At a high level, this fabric looks like this:

![Packets enter the switching fabric on an inbound link, are processed, and then forwarded out on an outbound link. Responses traverse the fabric in the opposite direction.](/files/-Llbm2gG_Cf-SCZA44lC)

### Packet Filters

A packet filter applies business logic to a particular ILPv4 Prepare packet. The contract allows the filter to modify an in-flight packet, forward it onward to the next filter, or reject the packet outright. Read more about the contract [here](https://github.com/sappenin/java-ilpv4-connector/blob/aa84b650426817d9db322f9d0889ab80505f3c90/ilpv4-connector-service-api/src/main/java/com/sappenin/interledger/ilpv4/connector/packetswitch/filters/PacketSwitchFilter.java).&#x20;

### Packet Filter Chain

Packet filters are assembled together into a filter chain that is applied to every incoming packet. This implementation has a filter chain that looks like this:

![Each incoming ILPv4 packet is "filtered" according to the business logic of each Packet Filter.](/files/-LlbnPzjU7MCKAoTFNc9)

### Link Filters

A Link Filter is similar to a Packet Filter in that it applies business logic to a particular ILPv4 Prepare packet. However, these filters are only engaged before sending packets into an Outbound Link.

Like Packet Filters, the contract allows the filter to modify an in-flight packet, forward it onward, or reject the packet outright without sending it into the Outbound link. Read more about the contract [here](https://github.com/sappenin/java-ilpv4-connector/blob/aa84b650426817d9db322f9d0889ab80505f3c90/ilpv4-connector-service-api/src/main/java/com/sappenin/interledger/ilpv4/connector/links/filters/LinkFilter.java).&#x20;

### Link Filter Chain

Link filters are assembled together into a filter chain that is applied to every outgoing packet. This implementation has a filter chain that looks like this:

![Each outgoing ILPv4 packet is "filtered" according to the business logic of each Link Filter.](/files/-LlboM4uzV8_dXsIs-kh)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://connector.interledger4j.dev/concepts/packet-switching-fabric.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
