1 year ago

#152545

test-img

Elliott Goldstein

Sending Identical DHCP Parameter Requests in both the Discover and Request Messages

I am working with some code that constructs and sends the DHCP Discover and Request messages from a client, as well as parses the Offer and Ack messages that come back from the server. In both the option field of the Discover and Request messages, there is an included dhcpParamRequest that includes the following parameter requests:

Discover message:

    pDHCPMSG->OPT[k++] = dhcpParamRequest;
    pDHCPMSG->OPT[k++] = 0x06;  // length of request
    pDHCPMSG->OPT[k++] = subnetMask;
    pDHCPMSG->OPT[k++] = routersOnSubnet;
    pDHCPMSG->OPT[k++] = dns;
    pDHCPMSG->OPT[k++] = domainName;
    pDHCPMSG->OPT[k++] = dhcpT1value;
    pDHCPMSG->OPT[k++] = dhcpT2value;
    pDHCPMSG->OPT[k++] = endOption;

Upon receiving the Offer message back from the server, each of these values are succesfully returned by the server and parsed by the client.

Likewise, in the Request message, the option field again contains a dhcpParamRequest option that contains the following param requests:

    pDHCPMSG->OPT[k++] = dhcpParamRequest;
    pDHCPMSG->OPT[k++] = 0x08;
    pDHCPMSG->OPT[k++] = subnetMask;
    pDHCPMSG->OPT[k++] = routersOnSubnet;
    pDHCPMSG->OPT[k++] = dns;
    pDHCPMSG->OPT[k++] = domainName;
    pDHCPMSG->OPT[k++] = dhcpT1value;
    pDHCPMSG->OPT[k++] = dhcpT2value;
    pDHCPMSG->OPT[k++] = performRouterDiscovery;
    pDHCPMSG->OPT[k++] = staticRoute;
    pDHCPMSG->OPT[k++] = endOption;

As you can see, there's a lot of repeated parameter requests as there were in the Discover message, values that were already returned by the server in the Offer message. Removing the redundant parameters and keeping only performRouterDiscovery and staticRoute do not alter the code at all (all the requested parameters are just filled once by the Offer message) so I'm not quite sure what the point of repeating requests for parameters already provided by the server previously.

However, I am not that experienced with DHCP-is it convention to repeat the same dhcpParamRequests in both the Discover and Request messages? The only possible edge case I could think that could cause it is somehow if all the info provided by a server on the network in the Offer message somehow entirely changed in the ACK message.

c

networking

client-server

dhcp

0 Answers

Your Answer

Accepted video resources