Go Back   Computer Forums > General Computing > Networking | DNS
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 04-29-2014, 03:15 AM   #1
Solid State Member
Join Date: Mar 2013
Location: Mauritius
Posts: 9
Default Need to create a DHCP server Client(TCP) simulation?

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

NiceBoy89 is offline   Reply With Quote
Old 04-29-2014, 10:19 AM   #2
Site Team
celegorm's Avatar
Join Date: Sep 2006
Posts: 10,674
Send a message via AIM to celegorm
Default Re: Need to create a DHCP server Client(TCP) simulation?

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?

"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Old 04-30-2014, 01:57 AM   #3
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 7,872
Default Re: Need to create a DHCP server Client(TCP) simulation?

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 on subnet 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 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
RFC 2131 - Dynamic Host Configuration Protocol
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 01:01 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0