1. Definition
    1. a framework for passing configuration information to hosts on a TCP/IP network
    2. DHCP protocol communicates using UPD
    3. the data is broadcasted (not point to point) and can be picked up very easily
  2. Features
    1. After obtaining parameters via DHCP, a host should be able to exchange packets with any other host in the Internet
    2. lease
      1. the period over which a network addresss allocated to a client
    3. binding
      1. a collection of configuration parameters, including at least an IP address
      2. Bindings are managed by DHCP servers.
    4. The client may issue a message to release the address back to the server when the client no longer needs the address
    5. client may ask for a permanent assignment by asking for an infinite lease
  3. DHCP client
    1. an Internet host using DHCP to obtain configuration parameters such as a network address.
    2. One important tasks of DHCP clients is:
      1. test when a DHCP server offers them an IP address.
      2. This test pings the address to ensure it isn't already in use on the network.
      3. If the address is found to be in use, the client will decline the address it has been offered
  4. DHCP server
    1. an Internet host that returns configuration parameters to DHCP clients.
    2. installed on a local network
    3. listens on UDP port 67
    4. sends data to the clients using UDP on port 67
  5. DHCP Message
    1. Definition
      1. Configuration parameters and other control information are carried in tagged data items that are stored in this field
      2. Each message shall be identified as being unique with the MAC address and a Transaction ID
      3. On data exchange, the data is sent as a byte stream
      4. Transaction ID: a random number chosen by the client.
      5. based on the BOOTP message
        1. a transport mechanism for a collection of configuration information
    2. Contents
      1. Subnet Mask
      2. Router
        1. a list of IP addresses for routers on the client's subnet
      3. Name Server
        1. list of name servers available to the client
      4. Domain Name Server
        1. a list of Domain Name System name servers available to the client
      5. Host Name
      6. Domain Name
      7. Requested IP Address
        1. is used in a client request (DHCPDISCOVER) to allow the client to request that a particular IP address be assigned.
      8. IP Address Lease Time
        1. length of time the allocation is valid
        2. is used in a client request (DHCPDISCOVER or DHCPREQUEST) to allow the client to request a lease time for the IP address.
        3. In a server reply (DHCPOFFER), a DHCP server uses this option to specify the lease time it is willing to offer.
        4. The time is in units of seconds, and is specified as a 32-bit unsigned integer
        5. is used in DHCPOFFER and DHCPREQUEST messages.
        6. The default lease period is eight days
        7. it could be increased to three weeks.
          1. The advantage of that is less DHCP-related traffic will flow across your network.
          2. Lease renewals generate traffic
          3. a client has to request a renewal from the server
          4. the server must respond
          5. then the client must tell the server whether it has decided to accept the lease.
          6. reducing the number of times that clients must go through a lease renewal process
          7. increase the efficiency of network
          8. decrease the load placed on DHCP server.
    3. DHCP Message Type
      1. DHCPDISCOVER
        1. The client broadcasts a DHCPDISCOVER message on its local physical subnet.
        2. include suggest values for the network address and lease duration.
        3. BOOTP relay agents may pass the message on to DHCP servers
      2. DHCPOFFER
        1. Each server may respond with a DHCPOFFER message that includes an available network address
        2. client receives one or more DHCPOFFER messages from one or more servers
        3. client chooses one server from which to request configuration parameters, based on the configuration parameters offered in the DHCPOFFER messages
      3. DHCPREQUEST
        1. client broadcasts a DHCPREQUEST message
        2. include the 'server identifier' option to indicate which server it has selected
        3. include other options specifying desired configuration values.
        4. DHCPREQUEST message is broadcast and relayed through DHCP/BOOTP relay agents.
        5. Topic
        6. client times out and retransmits the DHCPDISCOVER message if the client receives no DHCPOFFER messages.
        7. The servers receive the DHCPREQUEST broadcast from the client.
      4. DHCPDECLINE
        1. If the client detects a problem with the parameters in the DHCPACK message, the client sends a DHCPDECLINE message to the server
        2. restarts the configuration process
      5. DHCPACK
        1. The server selected in the DHCPREQUEST responds with a DHCPACK message
        2. containing the configuration parameters for the requesting client.
      6. DHCPNAK
        1. If the selected server is unable to satisfy the DHCPREQUEST message the server respond with a DHCPNAK message.
      7. DHCPRELEASE
      8. DHCPINFORM
  6. DHCP Extensions
    1. Server Identifier
      1. Topic
      2. DHCPOFFER: allow the client to distinguish between lease offers (related to DHCP servers)
      3. DHCP clients use the contents of the 'server identifier' field as the destination address for any DHCP messages unicast to the DHCP server.
      4. DHCP clients indicate which of several lease offers is being accepted by including this option in a DHCPREQUEST message.
      5. The identifier is the IP address of the selected server
    2. Client-identifier
      1. is used by DHCP clients to specify their unique identifier.
      2. DHCP servers use this value to index their database of address bindings.
      3. This value is expected to be unique for all clients in an administrative domain.
  7. IP address allocation mechanisms
    1. automatic allocation
      1. DHCP assigns a permanent IP address to a host
    2. dynamic allocation
      1. DHCP assigns an IP address to a host for a limited period of tim
      2. allows automatic reuse of an address that is no longer needed by the host to which it was assigned
    3. manual allocation
      1. a host's IP address is assigned by the network administrator
      2. DHCP is used to convey the assigned address to the host
  8. Socket Programming
    1. Definition
      1. a way of talking to other comupters
      2. Socket class has methods for creating UDP servers and clients.
      3. can be used to send and receive UDP datagrams.
      4. are used in socket programming to hold information about the address.
    2. types
      1. Datagram Socket
        1. Definition
          1. UDP
          2. build a packet with the destination information an send it out.
          3. Connectionless
          4. listen for incoming Client requests
          5. a sending or receiving point for a packet delivery service
          6. Each packet sent or received on a datagram socket is individually addressed and routed.
          7. Multiple packets sent from one machine to another may be routed differently, and may arrive in any order.
          8. UDP broadcasts sends are always enabled on a DatagramSocket.
        2. Constructor
          1. DatagramSocket()
          2. Constructs a datagram socket and binds it to any available port on the local host machine.
          3. DatagramSocket(int port)
          4. Constructs a datagram socket and binds it to the specified port on the local host machine.
          5. DatagramSocket(int port, InetAddress laddr)
          6. Creates a datagram socket, bound to the specified local address.
        3. Methods
          1. bind(SocketAddress addr)
          2. Binds this DatagramSocket to a specific address & port
          3. connect(InetAddress address, int port)
          4. Connects the socket to a remote address for this socket
          5. close()
          6. Closes this datagram socket.
          7. getInetAddress()
          8. Returns the address to which this socket is connected.
          9. getPort()
          10. Returns the port for this socket.
          11. receive(DatagramPacket p)
          12. Receives a datagram packet from this socket.
          13. send(DatagramPacket p)
          14. Sends a datagram packet from this socket.
      2. Stream Socket
        1. TCP
        2. Connection oriented
        3. keeping order of sent item
      3. DatagramPacket
        1. constructor
          1. DatagramPacket(byte[] buf, int length)
          2. Constructs a DatagramPacket for receiving packets of length length
          3. DatagramPacket(byte[] buf, int length, InetAddress address, int port)
          4. Constructs a datagram packet for sending packets of length length to the specified port number on the specified host.
        2. Methods
          1. getAddress()
          2. Returns the IP address of the machine to which this datagram is being sent or from which the datagram was received.
          3. getData()
          4. Returns the data buffer.
          5. getLength()
          6. Returns the length of the data to be sent or the length of the data received.
          7. getPort()
          8. Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received.
          9. getSocketAddress()
          10. Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
          11. setAddress(InetAddress iaddr)
          12. Sets the IP address of the machine to which this datagram is being sent.
          13. setData(byte[] buf)
          14. Set the data buffer for this packet.
          15. setLength(int length)
          16. Set the length for this packet.
          17. setPort(int iport)
          18. Sets the port number on the remote host to which this datagram is being sent.
          19. setSocketAddress(SocketAddress address)
          20. Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.
        3. Definition
          1. implement a connectionless packet delivery servic
          2. Multiple packets sent from one machine to another might be routed differently, and might arrive in any order.
          3. Packet delivery is not guaranteed.