wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Bodgitt & Scarper 2.2.3 (Identifying the Client using MAC Address). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Bodgitt & Scarper 2.2.3 (Identifying the Client using MAC Address)." Watch "Bodgitt & Scarper 2.2.3 (Identifying the Client using MAC Address)." New topic
Author

Bodgitt & Scarper 2.2.3 (Identifying the Client using MAC Address).

satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi,

I have a question about identifying the client. Is there any good solution for identifying the client in unique way? I came across some solutions which were employed the following techniques
  • Thread ID
  • New Data Instance
  • Milliseconds and Random number combination
  • etc.

    I just thought MAC Address will be helpful for identifying the client in unique way. I would like to know the consequences of this strategy. Please post your comments & views on this.


    sat
    Roberto Perillo
    Bartender

    Joined: Dec 28, 2007
    Posts: 2266
        
        3

    Howdy, partner!

    Champion, one question: does the lock method of the interface that was provided to you return a long value? If so, then you'll have to generate this value on the server side and return to the client to perform an update or delete operation. If it doesn't return any value, then you can get the client's Mac Address and send it to the server when locking a record. Then you can use it to perform update or delete operations.

    If the lock method returns a long value, then you won't be able to use the client's Mac Address, unless you ignore it, send the client's Mac Address on each request to the server and use it when performing update or delete operations.


    Cheers, Bob "John Lennon" Perillo
    SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
    Kah Tang
    Ranch Hand

    Joined: Sep 10, 2007
    Posts: 58
    I wouldn't use the MAC address. One of the requirements is that it should be able to work standalone without any networking.
    Roberto Perillo
    Bartender

    Joined: Dec 28, 2007
    Posts: 2266
        
        3

    Kah Tang wrote:I wouldn't use the MAC address. One of the requirements is that it should be able to work standalone without any networking.


    But this should be only when working on networked mode. And even though the locking mechanism only makes sense when running the application concurrently, it must also be used when running the application in standalone mode.
    satishkumar janakiraman
    Ranch Hand

    Joined: May 03, 2004
    Posts: 334
    Hi Roberto,

    I have a cookie requirement. I have implemented my cookie generation in the server using the technique current time & random number . I will send this cookie to the client and use before adding, updating, deleting the records.

    I just wanted to know other different approaches for the client identification rather than using current time & random number. I thought using MAC address instead of the conventional way (random number & current time). Attach some unique key with the MAC Address of the server and then send to the client and then use that value for subsequent client calls


    sat
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11477
        
      94

    What happens if someone starts 2 networked clients on the same computer and you are using MAC address?


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    satishkumar janakiraman
    Ranch Hand

    Joined: May 03, 2004
    Posts: 334
    Hello Andrew,

    If you send only the MAC address, you could not differentiate the two clients who were started in the same machine. But we can easily differentiate the clients by attaching some unique number (probably a system time in milliseconds) with the MAC Address before sending.
    What do you think about this solution?

    sat
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5398
        
      13

    Hi sat,

    I think you are putting way too much time and effort in this. I simply used

    to do the job and argumented in my choices.txt that in a next release of the application the algorithm to generate unique client identification cookie could be enhanced if necessary.

    And because you won't get extra credit for your algorithm, my advice would be: KISS (not the band of course, but the principle ). So you can use your valuable time to do other (more important) stuff.

    Kind regards,
    Roel


    SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    http://www.javaroe.be/
    Roberto Perillo
    Bartender

    Joined: Dec 28, 2007
    Posts: 2266
        
        3

    Roel De Nijs wrote:(not the band of course, but the principle )


    But the band would be cool too; after all, God gave rock'n'roll to you!
    satishkumar janakiraman
    Ranch Hand

    Joined: May 03, 2004
    Posts: 334
    Hi Roel,

    I have used the traditional client identification technique using the combination of System time in milliseconds and random number. I just wanted to know other efficient techniques than this. I thought that MAC Address will be more efficient

    sat
    Jarek Losice
    Greenhorn

    Joined: Nov 07, 2008
    Posts: 25
    Howdy All!

    I think that the simplest approach here is to use a synchronized counter:



    then, if the class ABC instance is kept singleton then we are sure, that there's no 2 different clients with the same cookie.
    This is simple yet it conforms to the assignment instructions.
    What do you think?


    Sun Certified Java Programmer for Java 6
    Sun Certified Java Developer
    Jarek Losice
    Greenhorn

    Joined: Nov 07, 2008
    Posts: 25
    Some thoughts about the MAC Address:

    as far as I know MACs are specific to Ethernet and Token Ring networks, and RMI/Sockets are specific to TCP/IP protocol. TCP/IP protocol can possibly be implemented over some other lower level networking protocol (transport for IP protocol) than the Ethernet and Token Ring, so in result there can be no such thing as MAC available.
    In such a situation approach to use MAC would fail.
    MAC is lower level protocol implementation specific artifact. It's something we cannot rely on, in my opinion.
    What do you think?

    Jarek.
    Stefan Bruhns
    Greenhorn

    Joined: Jun 22, 2009
    Posts: 1
    What do you think about using a UUID (java.util.UUID) to identify clients?


    SCJP, SCJD, SCWCD (EE5), SCBCD (EE5), SCDJWS (EE5)
    Roel De Nijs
    Bartender

    Joined: Jul 19, 2004
    Posts: 5398
        
      13

    Hi Stefan,

    Welcome to the JavaRanch!

    It depends on the interface you've got. If you have Sun's interface with the lockCookie you can't use it, because a long-value is expected. You can use it for your identifying mechanism, but I simply used System.nanoTime() and explained in choices.txt that this value is more than unique enough for a 1st release and that it could be made more unique in next releases.

    Kind regards,
    Roel
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Bodgitt & Scarper 2.2.3 (Identifying the Client using MAC Address).