> For the complete documentation index, see [llms.txt](https://krjaeh0.gitbook.io/j-log/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krjaeh0.gitbook.io/j-log/network/protocols/datagram.md).

# Datagram

{% hint style="info" %}

## 데이터그램

비연결형(Connectionless) 네트워크에서 독립적으로 전송되는 패킷(Packet)을 의미한다.

즉, 수신자와 사전에 연결을 설정하지 않고, 각 패킷이 독립적으로 전송되는 방식이다.

UDP, IP, ICMP 등에 사용되며, 빠른 전송이 필요한 경우 적합하나 신뢰성이 떨어진다.

온라인 게임, VoIP, 스트리밍 서비스, DNS 등에 많이 사용된다.
{% endhint %}

#### 데이터그램의 특징

* 비연결형
* 비순차적 전송 가능
* 신뢰성이 낮음
* 빠른 전송 가능

#### 데이터그램을 사용하는 프로토콜

| 프로토콜 | 설명                                       |
| ---- | ---------------------------------------- |
| UDP  | 데이터그램 기반의 전송 프로토콜로 빠른 전송이 가능하지만 신뢰성이 낮다. |
| IP   | 인터넷에서 데이터를 패킷 단위(데이터그램)로 전송하는 기본 프로토콜    |
| ICMP | 네트워크 오류 메시지를 전송하는데 사용된다. (ping 명령어)      |

#### 데이터그램과 TCP의 차이

| -     | 데이터그램                  | TCP                  |
| ----- | ---------------------- | -------------------- |
| 연결방식  | 비연결성                   | 연결형                  |
| 신뢰성   | 낮음                     | 높음                   |
| 속도    | 빠름                     | 상대적으로 느림             |
| 패킷 순서 | 순서 보장 x                | 순서 보장 o              |
| 사용 사례 | 실시간 스트리밍, VoIP, 온라인 게임 | 웹사이트(HTTP), 이메일, FTP |

#### 데이터그램의 동작 방식

{% stepper %}
{% step %}

### 송신: 데이터그램 생성 및 전송

송신자는 데이터그램(패킷)을 생성하여 전송한다.
{% endstep %}

{% step %}

### 전송: 독립적 경로 이동

데이터그램은 최적의 경로를 찾아서 독립적으로 이동한다.
{% endstep %}

{% step %}

### 수신: 도착한 데이터그램 조립

수신자는 도착한 데이터그램을 조립하여 데이터를 완성한다.
{% endstep %}
{% endstepper %}

* 예: A가 B에 인터넷 전화를 걸 때, 데이터그램(UDP 패킷)이 사용된다.
* 네트워크 환경에 따라 일부 패킷이 유실될 수 있지만, 음성이 빠르게 전달되는 것이 더 중요하다.
* 따라서 TCP보다 UDP가 더 효과적이다.

#### 데이터그램의 활용 예시

* 온라인 게임
* VoIP
* 스트리밍 서비스
* DNS


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://krjaeh0.gitbook.io/j-log/network/protocols/datagram.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
