Need to create a DHCP server Client(TCP) simulation?

Adityaniceboy89

Solid State Member
Messages
10
Location
Mauritius
HI, I need to create a java program that will simulate a client connecting to a DHCP server. the Client will send its MAC Address and in return will receive an IP Address. the Server will maintain a list of IP Address allocated. IP Address are allocated for a lease time, which can be set on the server. When the lease time is over, the server will allocate another IP Address to the Client. The Ip Address is of class A and a subnet 12 is used.
Any help will be Appreciated. Thanks in advance
 
So what you're asking for is us to write your homework for you?

THe server-side should be simple to write, it's got a pool/array of IP adddress objects to dish out and needs to keep track of them. The client side is tricky as using JAVA to get that deep into the system isn't always simple (at least it wasn't in JAVA 6). Back when I did something similar I needed a third party library to take a look at the system's MAC address as well as to dive into the packets to decipher if packet type and status (ack, nack, OK ect).

Something to consider, most modern DHCP clients renew the lease about half-way through to try and ensure they have a constant connection. Also something to consider, if a client gives up it's IP address (think of a windows ipconfig /release) and then tries to get a new address, should your server give them the same thing (the lease is still valid afterall) or do you want to void the original lease and give them a new IP address?
 
do you have to make both the server and the client?

or are you creating a client to connect to an existing server?


it's reasonably simple if you're writing both, AND if this is a homework assignment, not a real product you;re making.

first you need to consider that the machine doesn't have an IP address, and doesn't know where the server is.

so it can't just say hey 10.0.0.1 on subnet 255.255.255.128 because it doesn't know if said subnets exist!

so your client has to use a broadcast message.

since it is not possible to send a broadcast message using TCP, you'll have to use UDP.

so that's the porotcol, and the address of the server sorted 255.255.255.255 and UDP.

if you're making a simple homework project server. then you can choose the port that you are using, if it's a "real deal" then ports 67 and 68 must used.

again if it's homework your client just needs to broadcast simple words address please?

and the server responds with an IP address, and a timeout value.

if you're making a real product, or something that MUST work as a real product then I suggest that you start here RFC 1533 - DHCP Options and BOOTP Vendor Extensions
and
RFC 2131 - Dynamic Host Configuration Protocol
 
Back
Top Bottom