# P2P Delivery (Experiment)

OvenMediaEngine은 엣지(Edge) 트래픽을 플레이어로 분산시킬 수 있는 P2P 전송(P2P Delivery) 기능을 제공합니다. 이 기능은 현재 프리뷰(Preview) 버전이며, 사용하려면 반드시 OvenPlayer를 사용해야 합니다. 또한, 저희는 다양한 실제 환경에서 더 많은 실험을 수행한 후 OvenMediaEngine의 정식 버전으로 업그레이드할 계획입니다.

우선 규칙이 있습니다. P2P 네트워크에서 트래픽을 보내는 피어(peer)를 호스트 피어(Host Peer)라고 하고, 호스트 피어로부터 트래픽을 받는 피어를 클라이언트 피어(Client Peer)라고 부릅니다. 또한, OvenMediaEngine의 P2P 전송은 클라이언트 피어를 다시 호스트 피어로 지정하지 않습니다. 즉, 1 Depth(1단계)로만 작동합니다.

## P2P 전송을 사용하면 어떤 이점이 있습니까?

지금까지의 실험 결과에 따르면, P2P 전송은 플레이어 간의 연결에 1 Depth를 사용하고 하나의 플레이어에 최대 두 개의 플레이어를 연결할 때 최고의 성능과 안정성을 제공합니다.

즉, P2P 전송이 기존 트래픽의 3분의 2를 분산시켰습니다. 이는 엣지 네트워크의 용량(Capacity)을 3배 확장하고 트래픽 비용을 3분의 2로 줄일 수 있음을 의미합니다.

<figure><img src="/files/6JFsdzTVT8Q2qRbFMvTP" alt=""><figcaption></figcaption></figure>

## 어떻게 작동합니까?

다음 설정과 같이 `<P2P>` 엘리먼트를 추가하여 OvenMediaEngine의 P2P 기능을 사용할 수 있습니다:

{% code title="Server.xml" %}

```markup
<Server version="...">
	...
	<P2P>
		<MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
	</P2P>
	...
</Server>
```

{% endcode %}

또한, OvenMediaEngine이 오리진-엣지 클러스터 모드(Origin-Edge Cluster-Mode)로 실행 중일 때 P2P 전송을 사용하려면 이 설정을 모든 엣지에 적용해야 합니다. OvenPlayer를 사용하여 P2P 전송을 즉시 테스트해 볼 수 있습니다.

* `<MaxClientPeersPerHostPeer>`는 하나의 호스트 피어에 연결되는 클라이언트 피어의 수를 설정합니다.

## 피어는 어떻게 분류합니까?

OvenMediaEngine은 새로운 플레이어로부터 WebRTC 연결 요청을 받으면 다음 규칙에 따라 호스트 피어 또는 클라이언트 피어로 결정합니다:

| Qualification for Host Peer                                                                                                             | Qualification for Client Peer                                                        |
| --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| <ul><li>기기가 모바일이 아닐 것</li><li>OS가 리눅스가 아닐 것</li><li>브라우저가 MS Edge 브라우저가 아닐 것</li><li>브라우저가 알 수 없는 브라우저(Unknown Browser)가 아닐 것</li></ul> | <ul><li>호스트 피어 중 하나가 동일한 종류의 브라우저를 사용할 것</li><li>호스트 피어에 빈자리(vacant)가 있을 것</li></ul> |

{% hint style="info" %}
호스트 피어의 연결이 끊어지면 OvenMediaEngine은 이 상황을 감지하고, 안정성을 보장하기 위해 해당 호스트 피어에 연결되어 있던 클라이언트 피어를 즉시 엣지에 다시 연결합니다.

또한 저희는 사용자 위치, 플랫폼 성능, 그리고 네트워크 통계 정보를 기반으로 호스트 피어와 클라이언트 피어를 분류하는 더 스마트한 알고리즘을 준비하고 있습니다.
{% endhint %}

더 좋은 아이디어가 있으시다면 저희 코드를 개선하여 프로젝트에 기여해 주시기 바랍니다. [OvenMediaEngine GitHub](https://github.com/AirenSoft/OvenMediaEngine)를 방문해 주십시오.

{% embed url="<https://github.com/AirenSoft/OvenMediaEngine/blob/master/src/projects/modules/rtc_signalling/p2p>" %}


---

# 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://ovenmediaengine-enterprise.gitbook.io/guide/ko-kr/features/workflow-integration-and-external-system-connectivity/p2p-delivery-experiment.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.
