본문 바로가기

Networking

Address Resolution Protocol(ARP)

LAN Basic Communication Phase Brief Summary

  1. Destination PC의 IP 주소 확인
  2. Source PC의 Routing Table에서 목적지로 가기 위한 Interface와 Next Hop IP 확인
  3. Next Hop IP의 MAC Address를 Source PC의 ARP Table에서 확인
  4. ARP Table에 Next Hop IP의 MAC Address가 없다면, MAC Address를 획득하기 위해 ARP Request 메시지 전송
  5. Switch가 ARP Request 메시지를 수신하면, Source MAC Address를 확인하여, Source PC의 MAC Table Entry 생성(MAC Table Entry = Source MAC Address + 메시지가 수신된 Port 번호)
  6. Switch는 ARP Request 메시지를 모든 포트로 전송(Broadcast)
  7. ARP Request를 수신한 Destination PC는 ARP Table에 Source PC의 MAC Address와 IP를 등록
  8. Switch가 ARP Reply 메시지를 수신하면, Source MAC Address(Destination PC의 MAC Address)를 확인하여, MAC Table Entry 생성
  9. Source PC가 ARP Reply 메시지를 수신하면, Source PC는 ARP Table의 Destination PC의 MAC Address와 IP를 등록
  10. Source PC는 Destination PC에 전송될 Packet의 Destination MAC을 확인된 Destination PC의 MAC Address로 입력하여 전송
  11. Switch는 Source PC가 전송한 패킷의 Ethernet Frame을 확인하여, Destination MAC Address가 MAC Table에 존재하는지 확인
  12. Switch는 MAC Table에 Destination PC의 MAC Address가 전송되어 있으므로, Destination PC가 연결되어 있는 Switch의 포트로 패킷을 전송(Unicast)
  13. Destination PC는 수신한 패킷의 Ethernet Frame에 있는 Destination MAC Address가 자신의 MAC Address와 동일하기 때문에 해당 패킷을 IP Layer로 전달하고, Destination PC의 IP Layer는 IP Header에 있는 Destination IP가 자신의 IP와 동일하기 때문에 IP 패킷을 수신

ARP(Address Resolution Protocol) Table

LAN 통신을 하고자 하는 목적지의 IP나 MAC Address를 모를 때, ARP Request 패킷을 보내고 ARP Reply를 받아서 MAC Address를 획득한 후 목적지로 패킷을 보낼 수 있게 되는 방식

 

중요한 점은 ARP Request가 Broadcast 된다는 것

Broadcast되는 범위는 LAN으로 한정

즉, LAN의 정의는 ARP Request 패킷이 도달하는 범위

 

Physical NIC는 다음과 같은 상황에서 Ethernet Frame에서 IP 패킷을 IP Layer로 전달

  1. 수신된 Ethernet Frame의 Destination MAC Address가 자기 자신 MAC Address와 같은 경우
  2. 수신된 Ethernet Frame의 Destination MAC Address가 Broadcast MAC Address와 같은 경우
  3. 수신된 Ethernet Frame의 Destination MAC Address가 Multicast MAC Address와 같은 경우

 

  1. ARP Request 패킷이 IP Layer로 전달되면,  ARP Header에 있는 Target IP와 자기 자신의 IP를 비교
  2. 같으면 ARP Reply를 보내고
  3. 다른 경우에는 Sender IP, Sender MAC Address를 이용해서 ARP Table을 업데이트
  4. ARP Table에 이미 Entry가 있으면 Timer만 Refresh
  5. ARP Table에 Entry가 없으면, 신규 Entry 생성
  6. ARP Reply를 받은 쪽도 ARP Table에 Entry를 생성

ICMP 실행 과정

[구성 환경]
Source : 192.168.1.10, 00-15-5D-D2-9A-00

Destination 192.168.1.20, 00-15-5D-D2-9A-01

Source <-> L2 Switch <-> Destination

 

[확인 순서]
1. ARP Table 확인

Source Destination
C:\>arp -a

Interface: 192.168.1.10 --- 0x6
  Internet Address      Physical Address      Type
  224.0.0.22            01-00-5e-00-00-16     static
C:\>arp -a

Interface: 192.168.1.20 --- 0x4
  Internet Address      Physical Address      Type
  224.0.0.22            01-00-5e-00-00-16     static

2. Routing Table 확인

Source Destination
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
      192.168.1.0    255.255.255.0         On-link      192.168.1.10    271
     192.168.1.10  255.255.255.255         On-link      192.168.1.10    271
    192.168.1.255  255.255.255.255         On-link      192.168.1.10    271
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link      192.168.1.10    271
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link      192.168.1.10    271
===========================================================================
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
      192.168.1.0    255.255.255.0         On-link      192.168.1.20    271
     192.168.1.20  255.255.255.255         On-link      192.168.1.20    271
    192.168.1.255  255.255.255.255         On-link      192.168.1.20    271
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link      192.168.1.20    271
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link      192.168.1.20    271
===========================================================================

3. Source에서 Destination으로 ping을 하면, Source는 우선 자신의 Routing Table을 확인

4. Destination이 Source와 같은 LAN에 속한 것을 파악한 후 ARP Table 확인

5. Source는 ARP Table에 Entry가 없으므로 ARP Request 패킷 전송

Frame 1: 42 bytes on wire (336 bits), 42 bytes captured (336 bits) on interface \Device\NPF_{C3017C33-46BF-41EF-90A0-BB5A7AFB8C3E}, id 0
Ethernet II, Src: Microsof_d2:9a:00 (00:15:5d:d2:9a:00), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
    Destination: Broadcast (ff:ff:ff:ff:ff:ff)
        Address: Broadcast (ff:ff:ff:ff:ff:ff)
        .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
        .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
    Source: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
        Address: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: ARP (0x0806)
Address Resolution Protocol (request)
    Hardware type: Ethernet (1)
    Protocol type: IPv4 (0x0800)
    Hardware size: 6
    Protocol size: 4
    Opcode: request (1)
    Sender MAC address: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
    Sender IP address: 192.168.1.10
    Target MAC address: 00:00:00_00:00:00 (00:00:00:00:00:00)
    Target IP address: 192.168.1.20

6. Switch는 ARP Request 패킷을 받고, Source의 MAC Address를 Learning한 후 MAC Table에 Entry 등록
7. 이 후 Switch는 ARP Request 패킷을 수신한 포트 이외의 포트로 다시 Broadcast
Destination은 Broadcast된 ARP Request 패킷을 수신하고, Header에 있는 Source IP와 MAC Address를 ARP Table에 등록하고 Header에 있는 Target IP가 자기와 같으므로 ARP Reply를 전달

9. Destination은 Broadcast된 ARP Request 패킷을 수신하고, Header에 있는 Source IP와 MAC Address를 ARP Table에 등록하고 Header에 있는 Target IP가 자기와 같으므로 ARP Reply를 전달

(Destination외에 같은 LAN에 있는 다른 장비들은 Target IP가 자기와 같지 않으므로 ARP Table에 Source IP와 MAC Address Entry만 생성 or Entry를 생성하지 않을 수도 있음)

C:\>arp -a

Interface: 192.168.1.20 --- 0x4
  Internet Address      Physical Address      Type
  192.168.1.10          00-15-5d-d2-9a-00     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
Frame 2: 42 bytes on wire (336 bits), 42 bytes captured (336 bits) on interface \Device\NPF_{C3017C33-46BF-41EF-90A0-BB5A7AFB8C3E}, id 0
Ethernet II, Src: Microsof_d2:9a:01 (00:15:5d:d2:9a:01), Dst: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
    Destination: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
        Address: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: Microsof_d2:9a:01 (00:15:5d:d2:9a:01)
        Address: Microsof_d2:9a:01 (00:15:5d:d2:9a:01)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: ARP (0x0806)
Address Resolution Protocol (reply)
    Hardware type: Ethernet (1)
    Protocol type: IPv4 (0x0800)
    Hardware size: 6
    Protocol size: 4
    Opcode: reply (2)
    Sender MAC address: Microsof_d2:9a:01 (00:15:5d:d2:9a:01)
    Sender IP address: 192.168.1.20
    Target MAC address: Microsof_d2:9a:00 (00:15:5d:d2:9a:00)
    Target IP address: 192.168.1.10

10. ARP Reply 패킷을 수신한 Switch는 (기존)Destination의 MAC Address를 Learning한 후 MAC Table을 업데이트
11. ARP Reply 패킷은 Unicast이기 때문에 MAC Table에 등록된 (기존)Source의 MAC Address를 확인하여, 포트를 찾아서 ARP Reply 패킷을 Forwarding

12. ARP Reply 패킷을 받은 (기존)Source는 ARP Table에 ARP Reply 패킷 Header에 있는 IP와 MAC Address로 Entry를 생성하고 Ping 패킷을 전송

C:\>arp -a

Interface: 192.168.1.10 --- 0x6
  Internet Address      Physical Address      Type
  192.168.1.20          00-15-5d-d2-9a-01     dynamic
  192.168.1.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
Frame 3: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface \Device\NPF_{C3017C33-46BF-41EF-90A0-BB5A7AFB8C3E}, id 0
Ethernet II, Src: Microsof_d2:9a:00 (00:15:5d:d2:9a:00), Dst: Microsof_d2:9a:01 (00:15:5d:d2:9a:01)
Internet Protocol Version 4, Src: 192.168.1.10, Dst: 192.168.1.20
    0100 .... = Version: 4
    .... 0101 = Header Length: 20 bytes (5)
    Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
    Total Length: 60
    Identification: 0xa149 (41289)
    Flags: 0x00
    ...0 0000 0000 0000 = Fragment Offset: 0
    Time to Live: 128
    Protocol: ICMP (1)
    Header Checksum: 0x0000 [validation disabled]
    [Header checksum status: Unverified]
    Source Address: 192.168.1.10
    Destination Address: 192.168.1.20
Internet Control Message Protocol
    Type: 8 (Echo (ping) request)
    Code: 0
    Checksum: 0x4d59 [correct]
    [Checksum Status: Good]
    Identifier (BE): 1 (0x0001)
    Identifier (LE): 256 (0x0100)
    Sequence Number (BE): 2 (0x0002)
    Sequence Number (LE): 512 (0x0200)
    [Response frame: 4]
    Data (32 bytes)