socket发dhcp java,【原】关于DHCPServer发包方式的疑难问题解析

博客详细探讨了DHCP协议在动态分配IP地址过程中的不同步骤,特别是DHCP服务器如何向客户端发送DHCPOFFER、DHCPACK消息。RFC2131文档并未明确规定这些步骤必须使用广播或单播,而是建议服务器尝试直接使用单播,但在某些情况下,客户端可能需要通过设置BROADCAST位来提示服务器使用广播。微软和思科在实现中分别采用广播和单播策略,这两种方法都符合RFC标准。
摘要由CSDN通过智能技术生成

在DHCP-Server 向DHCP-Client 动态提供IP地址的四步过程中(DHCPDISCOVER、DHCPOFFER、DHCPREQUEST和DHCPACK),第一、三步(DHCP-Client 至DHCP-Server)通常都采用广播方式进行包发送,但第二、四步(DHCP-Server 至DHCP-Client)却因不同的厂商存在两种不同的实现方法,比如微软采用广播发送而思科采用单播发送,下来我们详细介绍:

首先我们来看看RFC 2131 文档中的相关介绍:

//

MessageUse

-------         ---

DHCPDISCOVER - Client broadcast to locate available servers.

DHCPOFFER    - Server to client in response to DHCPDISCOVER with

offer of configuration parameters.

DHCPREQUEST - Client message to servers either (a) requesting

offered parameters from one server and implicitly

declining offers from all others, (b) confirming

correctness of previously allocated address after,

e.g., system reboot, or (c) extending the lease on a

particular network address.

DHCPACK      - Server to client with configuration parameters,

including committed network address.

//

由此可见,在RFC文档中只对第一步明确做了说明是使用广播发送方式,而后的三步并没有定义采用广播还是单播方式,但对此做了如下解释:

Normally, DHCP servers and BOOTP relay agents attempt to deliver

DHCPOFFER, DHCPACK and DHCPNAK messages directly to the client using

uicast delivery. The IP destination address (in the IP header) is

set to the DHCP 'yiaddr' address and the link-layer destination

address is set to the DHCP 'chaddr' address. Unfortunately, some

client implementations are unable to receive such unicast IP

datagrams until the implementation has been configured with a valid

IP address (leading to a deadlock in which the client's IP address

cannot be delivered until the client has been configured with an IP

address).

A client that cannot receive unicast IP datagrams until its protocol

software has been configured with an IP address SHOULD set the

BROADCAST bit in the 'flags' field to 1 in any DHCPDISCOVER or

DHCPREQUEST messages that client sends. The BROADCAST bit will

provide a hint to the DHCP server and BOOTP relay agent to broadcast

any messages to the client on the client's subnet. A client that can

receive unicast IP datagrams before its protocol software has been

configured SHOULD clear the BROADCAST bit to 0. The BOOTP

clarifications document discusses the ramifications of the use of the

BROADCAST bit [21].

由此可见,RFC中对于DHCP-Server 至DHCP-Client的数据包发送方式也做了两种说明。

下来我们看看微软官方文档中的说明:

最后我们看看思科官方文档中的说明:

8ee849b4fc0b3b01a2495ba65eb9a1c0.png

因此,微软和思科在实现DHCP时采用了不同的包发送方式,所以在学习的过程中我们可能遇到两种不同的关于DHCP 实现过程中包发送机制,而这两种机制均符合RFC 文档的要求的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值