2014年2月13日 星期四

Interesting DHCP offer packet. 有趣的 DHCP offer 封包


當我在研究DHCP協定時,我參考了wikipedia的DHCP頁面:
http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
其中我發現一件奇怪的事,DHCP Offer 封包的 Destination 竟然是 255.255.255.255 (Broadcast)
這一點Sense都沒有,因為在 Discover 的時候 Server 就知道 Client 的 MAC Address了,沒理由要Broadcast。

When I was studying dchp protocol, I look wikipedia's dhcp page for reference:
http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
And i found something weired, on wiki's description, the destination field in dhcp offer is 255.255.255.255. It makes no sence. Because on the first step DHCP discover, the server already knew client's MAC address, there is no reason to broadcast the packet.
wiki 中 dhcp offer 的描述 (2014/02/14)
the dhcp offer description on wiki page
根據wiki中的描述我們可以確定的是,在 offer 的封包中底層的欄位有填入 client 的 MAC,這表示在 Ethernet 是 unicast,ip 是 broadcast,那實際上他到底會跑 broadcast or unicast ? 這是一個很有趣的問題,我們來做實驗看看:

According to wiki's description, we can be sure, the lower layer's field filled by client's MAC, it means it's unicast on Ethernet layer, and broadcast on ip layer. So, which one will happened in reality? broadcast or unicast? Let's take a experiment.

實際用wireshark觀察的dhcp封包 (圖有點小 sorry)
actual dhcp packet captured by wireshark
在實際的實驗中,我們可以看到 destination 欄位並不是填255,而是填 server 分配的ip位置,這表示wiki寫錯了嗎?經過網路上的搜尋以及詢問專家之後,得到的答案是:
destination填255 or 分配的 ip 位置都是可行的,因為在實作上,會先看Ethernet的封包,所以說ip位置並不會影響(可不可以亂填我就不知道了),但是目前的做法很少會採用wiki那種填255的作法。

On the experiment, we can see the destination field is not 255.255.255.255, it's the ip address whcih server distributed to client. Dose it mean wiki is wrong? After I search through the internet and asking to experts, I got the answer: No matter the destination field is 255.255.255.255 or the distributed ip address by server is correct, because in the implementation, the Ethernet packet will be read first, so the ipaddress doesn't affect the packet's type.

沒有留言:

張貼留言