Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 2271
    3
    Eclipse IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Kah Tang
    Ranch Hand
    Posts: 58
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 2271
    3
    Eclipse IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 334
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 11865
    194
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What happens if someone starts 2 networked clients on the same computer and you are using MAC address?
     
    satishkumar janakiraman
    Ranch Hand
    Posts: 334
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Sheriff
    Posts: 9929
    113
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    Roberto Perillo
    Bartender
    Posts: 2271
    3
    Eclipse IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 334
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 25
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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?

     
    Jarek Losice
    Greenhorn
    Posts: 25
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What do you think about using a UUID (java.util.UUID) to identify clients?
     
    Roel De Nijs
    Sheriff
    Posts: 9929
    113
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic