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