Home UC3M
Home IT

RFC 2131 implementation: Dynamic Host Configuration Protocol (DHCP)

 INTRODUCTION

Note: key modifications for September 2009 highlighted in red.

The objective of this practical assignment is to develop a reduced implementation of RFC 2131: Dynamic Host Configuration Protocol (DHCP), which enables networked devices (clients) to obtain the parameters necessary for operation in an Internet Protocol network. DHCP is a bootstrap protocol as well as an autoconfiguration protocol. It is a bootstrap protocol because it can get the parameters needed for a computer to start (for example, it makes possible to find an OS image for later download via TFTP). Also, it is an autoconfiguration protocol, because it defines the mechanisms for obtaining IP addresses and other parameters.

DHCP emerged as a standard protocol in October 1993 as defined in RFC 1531, succeeding the BOOTP protocol. The next update, RFC 2131 released in 1997 is the current DHCP definition. The latest proposed standard for DHCP over IPv6 (DHCPv6) can be found in RFC 3315. This practical assignment is focused exclusively on RFC 2131.


 OBJECTIVES


The objectives of this practical assignment are:

  1. To face the implementation of a real application-level protocol, starting from its original specification and understanding the RFC.
  2. To acquire knowledgement about bootstrap and autoconfiguration protocols, like DHCP, BOOTP y RARP. BOOTP (BOOTstrap Protocol) is an standard that precedes DHCP and it is very similar to it (in fact, they both use the same message format). BOOTP is defined in RFC 1542 and its main inconvenient is that dynamic allocation of IP addresses is not allowed (supported). RARP (Reverse Address Resolution Protocol) is is a Link layer protocol used to obtain an IP address for a given link-layer address.
  3. To go deeper into the protocols studied in the theory classes.
  4. To acquire knowledgement about programming with UDP sockets, raw sockets and Broadcast messages.

 INSTRUCTIONS


The practical assignment must be developed in C programming language over Linux OS and your implementation must work on the Telemática lab computers, where the assessment will take place. Please, refer to details below on machines available and how to connect remotely.

It is mandatory the use of the gcc parameter -Wall in every compilation. The code must compile without warnings or errors. Also, the code must not have memory leaks (valgrind will be used to check this). The submission instructions will be published during the course. Basically, the source code (.c and .h files), a Makefile file to compile it, and a README file with some data (name, email address and group) have to be submitted. Practical assignments which do no meet these requirements will not be assessed, i.e., implementations containing memory leaks, compilation warnings or compilation errors, will not be assessed.

The practical assignment consists of a simplified version of the RFC. Simplifications are listed below. The complete RFC specification can be found in the following link: RFC 2131. The RFC 2131 standard defines both the client and the server requirements for obtaining bootstrap and configuration parameters. However, in this practical assignment only the client implementation is required. Due to the fact that it is neccesary to be root in order to carry out the developement, a test environment will be provided, with all the software installed, including a basic DHCP server.

  • Basic operation:

    Next, the operation of the DHCP protocol will be briefly explained. A deeper explanation of the protocol is out of the scope of this document; it is the student, who should read the complete RFC and understand all the details required for a correct implementation.

    DHCP protocol deals with different kinds of packets DHCP, of which is mandatory to implement/recognize the following: DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, DHCPACK, DHCPNACK, DHCPRELEASE and DHCPDECLINE.

    DHCP works only with UDP, and it is one of the few protocols that use static port numbers not only for servers (port 67), but also for clients (port 68). DHCP allows to obtain different parameters, such us IP address, subnetwork mask, boot file, DNS, printer server, etc... As an example, in order to obtain those parameters, the client and server mush exchange the following packets (see figure):

    • DHCPDISCOVER, sent by the client. It is an UDP multicast message which is received by DHCP servers.
    • DHCPOFFER, where IP addresses are offered by one or several servers. Client should choose one.
    • DHCPREQUEST, sent by the client. It is an UDP message (unicast or multicast) to request an specific address.
    • DHCPACK, sent by the server to confirm an IP.

    There are some messages, like DHCPNACK, DHCPRELEASE and DHCPDECLINE, which are not shown in the previous image but whose implementation/support is mandatory. DHCPDECLINE is sent by the client to reject an offered IP address from the server (for example, if it is already in use).

    So, it is mandatory to implement a DHCP client taking the considerations of the following paragraphs into account:

  • Executable and parameters: refer to the dhcpcl man page for details.


  • Examples and input/output format: refer to the dhcpcl man page for details.


  • Traces: refer to the dhcpcl man page for details.


  • Notes:
    • Every message must be shown by the standard output, except error messages, which must be shown by the error standard output.
    • Once the parameters from the server are received, the client, after checking the IP address is not in use by any other machine, will only have to configure the IP address, the subnetwork mask and the gateway (router) address. Remaining data coming from the DHCP server can be ignored by the client.

  • Mandatory changes for September:
    • It is mandatory to implement both REBINDING and RENEWING states. Therefore, the use of the T1 and T2 timers (see RFC's Figure 5) is mandatory. According to the RFC, once the client is in BOUND state, there are three timers (T1 < T2 < leasetime) that start and lead to the transition to other states and the sending of some messages.
      • If T1 expires, the client enters in RENEWING state and sends unicast DHCPREQUEST asking for an extension of the leasetime.
      • If T2 expires without receiving DHCPACK, the client enters in REBINDING state and sends broadcast DHCPREQUEST.
    • When in BOUND, REBINDING or RENEWING states, the program will finish once SIGUSR2 signal is received.
    • It is mandatory that the client checks whether the obtained IP address is available by means of ARP.
    • No scripts of any type will be allowed during the assessment.
    • It is mandatory a compilation without warnings or errors, including the usage of -Wall with gcc
    • Valgrind will be used to detect memory leaks on a basic execution with a server and by ending the execution with SIGUSR2 or with SIGINT (Ctrl+C). It is mandatory to use -q and --leak-check=full options.

  • Simplifications to the RFC:
    • It is not necessary to implement DHCPINFORM messages.
    • It is not necessary any implementation related to multi-homed hosts.
    • The only mandatory link level is Ethernet.
    • If the client receives more than one answer from the present servers, it has to choose one of them. How it is selected, is left to the implementors decision.
    • Everything that appears in the RFC as MAY or SHOULD is optional. Everything that appears as MUST is mandatory for the assignment.

  • Considerations about timers and timeouts: the values will always be those marked as RECOMMENDED in the RFC.


  • Considerations about sockets: it is mandatory to use UDP sockets whenever is possible (e.g. DHCPRELEASE, DHCPDECLINE). When not possible (DHCPDISCOVER, DHCPREQUEST, ARP) raw or packet sockets will be used. In short, the client implementation must make use of both socket types.


  • How to access remotely to the lab machines:
    • From home, you need to connect to any of the machines at labs 7.0.J02, 7.0.J03, 4.1B01, 1.1A16, whose FQDN are the following:
      • jbit101.lab.it.uc3m.es - jbit156.lab.it.uc3m.es
      • it001.lab.it.uc3m.es - it020.lab.it.uc3m.es
      • lm001.lab.it.uc3m.es - lm010.lab.it.uc3m.es
      • ctel001.lab.it.uc3m.es - ctel018.lab.it.uc3m.es
    • Those machines are only available during working days (no weekends) and are switched off every day at 23:00.
    • You need to use ssh (with -X option). Since access outside the university is filtered, you need to connect first to one of the foolowing machines below, and then open another connection to the lab machines above:
      • monitor01.lab.it.uc3m.es
      • monitor02.lab.it.uc3m.es
      • monitor03.lab.it.uc3m.es
    • RSA fingerprint for many of the lab machines is: dc:a9:3e:f6:51:98:54:dc:56:61:0e:96:c6:7a:70:a5 (if not, please check with the lab technicians).
    • Please, note that it is not recommended to use monitor0x for testing, since some of them still run a preemptive kernel. To check if a kernel is preemptive, you can use uname -a:
        Linux monitor02 2.6.26 #3 SMP PREEMPT Fri Jul 18 12:07:07 CEST 2008 i686 GNU/Linux

    A manual page has been created for the proposed implementation of dhcpcl, that resumes the information about input, output and traces formats. It can also be downloaded in HTML format, PDF format, or TXT format,.



 ASSESSMENT

The assessment of this practical assignment will be in-class and the mark will be pondered as the 40% of the final mark of the course. In order to be included in it, the mark of the assignment must be 5 or over:

Important dates:

  • For those students allow to make the practical assessment in June:
    • May 15th, 2009, at 23.59 (to be confirmed): Submission through Aula Global (June assessment only)
    • May 22nd, 2009 (to be confirmed): In-class assessment in the laboratory.

  • September dates:
    • August 25th, 2009, at 23.59: Submission through Aula Global (September assessment only)
    • September 1st, 2009: In-class assessment in the laboratory.

 LINKS

Practical assignment

RFC

  • RFC 2131 (obsoletes 1541) "Dynamic Host Configuration Protocol". R. Droms, Bucknell University, March 1997
  • RFC 2132 "DHCP Options and BOOTP Vendor Extensions". S. Alexander, R. Droms, March 1997

Books

  • W. R. Stevens: "Unix network programming".Volume 1.Networking APIs-Sockets and XTI (L/S 004.451.9 UNIX STE )

Information about sockets





start | contact