본문으로 이동

CoAP

위키백과, 우리 모두의 백과사전.

CoAP(Constrained Application Protocol, 코앱)은 제약이 있는(constrained) 장치들을 위한 특수한 인터넷 애플리케이션 프로토콜로서 RFC 7252에 정의되었다. "노드"(node)로 불리는 해당 제약 장치들이 비슷한 프로토콜을 사용하는 더 넓은 인터넷과 통신할 수 있게 한다. COAP은 제약이 있는 동일한 네트워크(예: 저전력, 손실 네트워크)의 장치들 간에, 장치와 인터넷 상의 일반 노드 간에, 또 인터넷을 통해 참여한, 제약이 있는 각기 다른 네트워크 상의 장치 간에 사용하기 위해 설계되었다. 또, CoAP은 모바일 통신망의 SMS와 같은 다른 구조를 통해 사용된다.

CoAP은 무선 센서 네트워크 노드처럼 자원에 제약이 있는 장치들에서 사용할 목적으로 고안된 서비스 계층 프로토콜이다. CoAP은 단순한 웹 연동을 위해 HTTP로 쉽게 변환되도록 설계되어 있으며 멀티캐스트 지원과 같은 특수한 요건을 충족하면서도 부하가 매우 낮으며 단순한 편이다.[1][2] 멀티캐스트, 낮은 부하, 단순성은 심도있게 임베디드되는 경향이 있고 전통적인 인터넷 장치보다 훨씬 더 적은 메모리와 전력 공급을 지니는 경향이 있는 사물인터넷(IoT) 및 사물통신(M2M) 장치에 매우 중요하다. 즉, 효율성이 매우 중요하다. CoAP은 UDP 또는 UDP 유사 프로토콜을 지원하는 대부분의 장치에서 구동할 수 있다.

메시지 포맷

[편집]

CoAP 요청/응답 코드

[편집]

요청 코드는 다음의 형태를 취한다:

바이트
0 1 2 3 4 5 6 7
CLASS CODE

문서 상에서는 보통 `<class>`.`<code>`와 같은 형태로 표현된다.

CoAP 등록 코드

[편집]

에서 CoAP의 최신 등록 코드를 볼 수 있다.

    1. Method: 0.XX
      1. EMPTY
      2. GET
      3. POST
      4. PUT
      5. DELETE
      6. FETCH
      7. PATCH
      8. iPATCH
    2. Success : 2.XX
      1. Created
      2. Deleted
      3. Valid
      4. Changed
      5. Content
      6. Continue
    1. Client Error : 4.XX
      1. Bad Request
      2. Unauthorized
      3. Bad Option
      4. Forbidden
      5. Not Found
      6. Method Not Allowed
      7. Not Acceptable
      8. Request Entity Incomplete
      9. Conflict
      10. Precondition Failed
      11. Request Entity Too Large
      12. Unsupported Content-Format
    1. Server Error : 5.XX
      1. Internal Server Error
      2. Not Implemented
      3. Bad Gateway
      4. Service Unavailable
      5. Gateway Timeout
      6. Proxying Not Supported
    2. Signaling Codes : 7.XX
      1. Unassigned
      2. CSM
      3. Ping
      4. Pong
      5. Release
      6. Abort

CoAP 메시지 구조

[편집]
CoAP 메시지 구조
바이트 바이트 바이트 바이트
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
VER TYPE TKL (토큰 길이: Token Length) CoAP 요청/응답 코드 메시지 ID
토큰 (TKL 바이트) (8바이트 최대)
옵션 (사용 가능한 경우)[3]
1 1 1 1 1 1 1 1 페이로드 (사용 가능한 경우)

CoAP 고정 헤더는 처음 4바이트이다. 이로써 토큰, 옵션, 페이로드를 생략할 경우 가장 작은 CoAP 메시지의 길이를 4바이트로 유지할 수 있게 한다.

이 매크로를 통해 C에서 고정 헤더의 정보를 쉽게 추출할 수 있다:

#define COAP_HEADER_VERSION(data)  ( (0xC0 & data[0])>>6    )
#define COAP_HEADER_TYPE(data)     ( (0x30 & data[0])>>4    )
#define COAP_HEADER_TKL(data)      ( (0x0F & data[0])>>0    )
#define COAP_HEADER_CLASS(data)    ( ((data[1]>>5)&0x07)    )
#define COAP_HEADER_CODE(data)     ( ((data[1]>>0)&0x1F)    )
#define COAP_HEADER_MID(data)      ( (data[2]<<8)|(data[3]) )

구현체

[편집]
이름프로그래밍 언어구현된 CoAP 버전클라이언트/서버구현된 CoAP 기능라이선스링크
aiocoapPython 3RFC 7252Client + ServerBlockwise Transfers, Observe (부분적)MIThttps://pypi.python.org/pypi/aiocoap
CaliforniumJavaRFC 7252Client + ServerObserve, Blockwise Transfers, DTLSEPL+EDLhttps://web.archive.org/web/20181207034534/http://www.eclipse.org/californium/
cantcoapC++/CRFC 7252Client + ServerBSDhttps://github.com/staropram/cantcoap
CanopusGoRFC 7252Client + ServerCoreApache License 2.0https://github.com/zubairhamed/canopus
CoAP implementation for GoGoRFC 7252Client + ServerCore + Draft SubscribeMIThttps://github.com/dustin/go-coap
CoAP.NETC#RFC 7252, coap-13, coap-08, coap-03Client + ServerCore, Observe, Blockwise Transfers3-clause BSDhttps://github.com/smeshlink/CoAP.NET
CoAPSharpC#, .NETRFC 7252Client + ServerCore, Observe, Block, RDLGPLhttp://www.coapsharp.com 보관됨 2018-02-22 - 웨이백 머신
CoAPthonPythonRFC 7252Client + Server + Forward Proxy + Reverse ProxyObserve, Multicast server discovery, CoRE Link Format parsing, Block-wiseMIThttps://github.com/Tanganelli/CoAPthon
CoAP ShellJavaRFC 7252ClientObserve, Blockwise Transfers, DTLSApache License 2.0https://github.com/tzolov/coap-shell
CopperJavaScript (Browser Plugin)RFC 7252ClientObserve, Blockwise Transfers3-clause BSDhttps://github.com/mkovatsc/Copper https://addons.mozilla.org/firefox/addon/copper-270430/[깨진 링크(과거 내용 찾기)]
eCoAPCRFC 7252Client + ServerCoreMIThttps://gitlab.com/jobol/ecoap
Erbium for ContikiCRFC 7252Client + ServerObserve, Blockwise Transfers3-clause BSDhttp://www.contiki-os.org/ (er-rest-example)
iCoAPObjective-CRFC 7252ClientCore, Observe, Blockwise TransfersMIThttps://github.com/stuffrabbit/iCoAP
jCoAPJavaRFC 7252Client + ServerObserve, Blockwise TransfersApache License 2.0https://code.google.com/p/jcoap/
libcoapCRFC 7252Client + ServerObserve, Blockwise Transfers, DTLSBSD/GPLhttps://github.com/obgm/libcoap
LibNyociCRFC 7252Client + ServerCore, Observe, Block, DTLSMIThttps://github.com/darconeous/libnyoci
lobaro-coapCRFC 7252Client + ServerObserve, Blockwise TransfersMIThttp://www.lobaro.com/lobaro-coap
microcoapCRFC 7252Client + ServerMIThttps://github.com/1248/microcoap
nCoapJavaRFC 7252Client + ServerObserve, Blockwise Transfers, CoRE Link Format, Endpoint-ID-DraftBSDhttps://github.com/okleine/nCoAP
node-coapJavascriptRFC 7252Client + ServerCore, Observe, BlockMIThttps://github.com/mcollina/node-coap
Ruby coapRubyRFC 7252Client + Server (david)Core, Observe, Block, RDMIT, GPLhttps://github.com/nning/coap
https://web.archive.org/web/20180611002224/https://github.com/nning/david
Sensinode C Device LibraryCRFC 7252Client + ServerCore, Observe, Block, RDCommercialhttps://silver.arm.com/browse/SEN00
Sensinode Java Device LibraryJava SERFC 7252Client + ServerCore, Observe, Block, RDCommercialhttps://silver.arm.com/browse/SEN00
Sensinode NanoService PlatformJava SERFC 7252Cloud ServerCore, Observe, Block, RDCommercialhttps://silver.arm.com/browse/SEN00
SwiftCoAPSwiftRFC 7252Client + ServerCore, Observe, Blockwise TransfersMIThttps://github.com/stuffrabbit/SwiftCoAP
TinyOS CoapBlipnesC/Ccoap-13Client + ServerObserve, Blockwise TransfersBSDhttps://web.archive.org/web/20130312140509/http://docs.tinyos.net/tinywiki/index.php/CoAP
txThingsPython (Twisted)RFC 7252Client + ServerBlockwise Transfers, Observe (partial)MIThttps://github.com/mwasilak/txThings/
FreeCoAPCRFC 7252Client + Server + HTTP/CoAP ProxyCore, DTLS, Blockwise TransfersBSDhttps://github.com/keith-cullen/FreeCoAP
coap-rsRustRFC 7252Client + ServerMIThttps://github.com/Covertness/coap-rs
YaCoAP C MIT https://github.com/RIOT-Makers/YaCoAP

프록시 구현

[편집]

보안 문제

[편집]

프로토콜 표준이 DDoS 증폭 공격의 위협을 완화하기 위한 대비책이 있지만[4], 이 대비책들은 실제로 구현되어 있지 않으므로[5], 주로 중국에 위치한 580,000개 이상이 표적이 되어 최대 320Gbps의 공격을 받고 있다[6].

같이 보기

[편집]

각주

[편집]