network

[network] 혼자 공부하는 네트워크 03-1 ARP(Address Resolution Protocol) (240807)

hail2y 2024. 8. 7. 19:25

통신을 올바르게 주고받으려면 내가 정보를 주고받고자 하는 호스트의 IP 주소와 MAC 주소를 모두 알아야 한다.

하지만, 상대방의 IP 주소는 알지만 MAC 주소를 모를 때는?

→ 이 상황을 해결하기 위한 프로토콜이 바로, ARP(Adress Resolution Protocol)!

 

 The reason why we need ARP is because computers need to know both the IP address and the MAC address of a destination before they can start network communication.

[출처: https://nexgent.com/what-is-arp-address-resolution-protocol/]

 

The purpose of ARP is to allow hosts to communicate with other devices on the same network by converting between Logical addresses and Physical addresses.

[출처: https://www.comphacks.com/reading-and-interpreting-arp-tables/]

ARP (Address Resolution Protocol)

  • IP 주소를 통해 MAC 주소를 알아내는 프로토콜
  • 동일 네트워크 내에 있는 송수신 대상의 IP 주소를 통해 MAC 주소를 알아낼 수 있음
  • ARP 동작 과정
    ① ARP 요청 (ARP Request)
    ② ARP 응답 (ARP Reply)
    ③ ARP 테이블 갱신: ARP 프로토콜을 사용하는 호스트마다 ARP 테이블 유지, network interface마다 테이블 유지 
    (Every device that has an IP address maintains such a table. - https://www.practicalnetworking.net/series/arp/traditional-arp/)

ARP 요청 (ARP Request): 브로드캐스트 메시지

  • Host A: 브로드캐스트 메시지 전송
  • 이 브로드캐스트 메시지 = 'ARP 요청'이라는 ARP 패킷
  • Target MAC 주소는 모르기 때문에 모두 0으로 세팅
  • ARP Request's destination은 브로드캐스트 MAC 주소로(모두 1; ffff.ffff.ffff) 세팅

② ARP 응답 (ARP Reply): 유니캐스트 메시지

  • Host B: 자신의 MAC 주소를 담은 유니캐스트 메시지를 A에게 전송
  • 이 유니캐스트 메시지 = 'ARP 응답'이라는 ARP 패킷
  • 그 결과, 이 메시지를 수신한 A는 B의 MAC 주소를 알게 됨 

https://www.practicalnetworking.net/series/arp/traditional-arp/

* ARP 패킷

  • ARP 요청, ARP 응답 과정에서 송수신되는 패킷
    - 오퍼레이션 코드(Opcode; Operation Code): ARP 요청의 경우 1, ARP 응답의 경우 2
    - 송신지 하드웨어 주소(Sender Hardware Address)와 수신지 하드웨어 주소(Target Hardware Address): MAC 주소
    - 송신지 프로토콜 주소(Sender Protocol Address)와 수신지 프로토콜 주소(Target Protocol Address): IP 주소

The ARP packet is inside an Ethernet frame.

아래는 패킷 형식이 조금 다르긴 한데 https://hail2y.tistory.com/80 글에서 본 이더넷 프레임이라고 보면 된다. 앞에 이더넷 헤더(송수신지 주소, 타입)와 패킷 끝의 CRC, 그리고 그 사이에 ARP 요청 혹은 응답이 있기 때문이다. 강의에서도 2계층에서 배웠던 이더넷 프레임과 같은 그림을 썼다. 

 

The ARP Request is an ARP payload carried within the appropriate L2 frame for the medium in use. 

[출처: https://www.practicalnetworking.net/series/arp/traditional-arp/]

https://www.slideshare.net/slideshow/arp-36193303/36193303

ARP 테이블 갱신 (= ARP cache table)

  • ARP 테이블(ARP Table): ARP 요청-응답을 통해 알게 된 IP 주소와 MAC 주소의 연관 관계
  • 해당 IP 주소와 연관된 MAC 주소를 기록해 둔다
  • ARP 테이블 항목은 일정 시간이 지나면 삭제, 임의 삭제도 가능
  • ARP 테이블에 등록된 호스트에 대해서는 ARP 요청을 보낼 필요 없음
  • ARP 테이블 확인 명령어: arp -a

https://www.comphacks.com/reading-and-interpreting-arp-tables/

 

Note: The ARP table should be distinguished from other addressing maps such as MAC Address tables found on switches, and concepts like DHCP (Dynamic Host Configuration Protocol) and DNS (Domain Name System).

 

강의 보면서 스위치에서 배웠던 MAC 주소 테이블이랑 헷갈렸는데 위 참고사항을 보면 ARP 테이블이랑 다른 주소 매핑 테이블이랑 확실히 구별되어야 된다고 한다. MAC 주소 테이블은 아래 내용과 같다.

  • MAC 주소 테이블(MAC address table): 스위치 포트와 연결된 호스트의 MAC 주소간의 연관 관계를 나타내는 정보
  • 스위치는 데이터 링크 계층의 대표 장비

 

cf. https://ceon.tistory.com/29