What protocol to use?

Hello everyone,

I am working on a hobby project that has got a little bit too serious.

I'm researching protocols to use, that can work with arduino over ethernet. I want to create a plug'n'play experience. So that the user only needs to plug the controller in a computer through ethernet and my software that is running on the computer automatically recognizes the controller and its functions.

I have four requirements:

  • Devices on the protocol need to have unique identifiers like: RELAYCONTROLLER-XYrd24Dx4 which can be set during the programming phase

  • A computer (running Windows) can scan the network and automatically recognizes that "XYrd24Dx4" is in the network and is a relaycontroller.

  • Computer and controller(arduino) can easily transfer small data like: Computer->"XYrd24Dx4-RELAY1-OPEN" and Arduino->"XYrd24Dx4-ANALOGVAL01:567"

  • Needs to be over ethernet or something as robust as ethernet.

I have researched Modbus TCP and it seems perfect, except it does not have something like a unique identifier. I can't seem to find a simple protocol that does this, in a kind of robust way.

I have some experience with other protocols but not enough to understand if this is possible, and which protocol would be suited for this.

So this may very well be a stupid question but I am unable to find information about this on Google.

Thank you in advance

Perhaps you could use MAC addresses?
If you know the MAC address of each device that you might connect then you could keep a table relating the address to the device that has that address.

ardly:
Perhaps you could use MAC addresses?
If you know the MAC address of each device that you might connect then you could keep a table relating the address to the device that has that address.

Thank you for your response Ardly.

MAC addresses could be a great way to do this. However, the software would need to know all the MAC addresses (table), to know which MAC address would correspond to the type of controller.

I need something that doesn't need a table or something. I need a controllertype + unique ID.
like: [controllerType]-[UniqueID]: RELAYCONTROLLER-XYrd24Dx4

This way, the software knows how to use the device (controllerType) and can send commands and receive commands from this device with the unique ID. And I do not need a table to keep track of hundreds of MAC adresses (that needs to be updated reguraly).

Ofcourse I could implement functions that return the ControllerType and Unique ID. And use something like

if (command.received.ID = controllertype + uniqueID)
{
  //listen to command
}
else
{
  //ignore
}

But I feel like this should be implemented in a protocol. And I thought their would be protocols that can do this.

Anybody got any suggestions?

Terick:
...
MAC addresses could be a great way to do this. However, the software would need to know all the MAC addresses (table), to know which MAC address would correspond to the type of controller.
....

Yes, the software needs to know what type of controller each MAC address corresponds to.

Terick:
....
I need something that doesn't need a table or something. I need a controllertype + unique ID.
like: [controllerType]-[UniqueID]: RELAYCONTROLLER-XYrd24Dx4
....

Perhaps you are not describing your problem well but basically what you are asking for is impossible. At the end of the day you need a table that matches an identifier to a controllerType. There is no way round that unless the devices you plug in are all customised by you - which seems a lot more work than just having a table.

Let's say you have a LAN. A new IP appears on the LAN what are you going to? If you know the MAC address of all the controllers that can be connected you simply look up its MAC and determine its controllerType (or that it is an unknown MAC). If you don't do that then you have to detect the new IP and attempt to talk to the device. The device will only reply to your custom protocol if you have actually modified the device. That seems like a bit of a non-starter if you are going to have lots of devices from different suppliers/people.

In the case of ethernet, the unique ID of the device corresponds to the DNS assigned IP address.

If you are trying to emulate the behavior of USB then every device needs to be able to respond to a query for the 'device type'.

Modbus is ancient technology. If you need to send long variable length messages then MQTT is easier to use.

Not sure how this scales to Arduino, but here is one such protocol: Service_Location_Protocol

In the case of ethernet, the unique ID of the device corresponds to the DNS assigned IP address.

The OP wants to recognise devices plugged into ethernet. The same IP address can be assigned to different devices at different times so you cannot rely on an IP address to tell you what has been plugged in.

MrMark:
Not sure how this scales to Arduino, but here is one such protocol: Service_Location_Protocol

Something like that could be used but each device is going to have to publish what it is. Providing the OP can configure all the devices he wants to use to do that then I suppose it is possible.

Hello guys, really thank you for your responses.

I decided to let it rest a few days and rethink my idea's.

ardly:
Perhaps you are not describing your problem well but basically what you are asking for is impossible. At the end of the day you need a table that matches an identifier to a controllerType. There is no way round that unless the devices you plug in are all customised by you - which seems a lot more work than just having a table.

All the devices that I use are indeed customized by me, so adding additional information isn't that much of a deal. However, just using the mac address of each device seems to be the easiest method.

MrMark:
Not sure how this scales to Arduino, but here is one such protocol: Service_Location_Protocol

This is exactly what I was searching for. It got everything I need, and I am currently testing to get OpenSLP working on one of my arduino's with ethernet shield.

I thought of three cases I going to try:

  1. Using a webbased "MAC Address" library(MACaddress, controllerType,iD, description). Each time the computer does startup, it will update the library (if it has a internet connection) and use this library to recognize what is connected to the computer.

  2. Getting OpenSLP working on a arduino (this won't be easy) and on my computer (easy).

  3. Creating my own SLP-like protocol and using that to quickly recognize the deviceType and ID from connected devices.

If you think while reading this, why would he try all these methodes?!
Well, I have too much time and I can see that this can be used in many other project ideas I had.

Thank you all for your responses, it did really help me!

mikb55:
In the case of ethernet, the unique ID of the device corresponds to the DNS assigned IP address.

Mixing up a lot of terms there.

At the Ethernet level, the unique ID is the MAC address.

DHCP assigns IP addresses, or they can be fixed.

DNS links IP addresses to device names such as 'MyPc' etc.

srnet:
Mixing up a lot of terms there.

At the Ethernet level, the unique ID is the MAC address.

DHCP assigns IP addresses, or they can be fixed.

DNS links IP addresses to device names such as 'MyPc' etc.

With unique ID I mean the ID I myself assigned like I told in the openning post (probably I was not clear enough).

Terick:
Devices on the protocol need to have unique identifiers like: RELAYCONTROLLER-XYrd24Dx4 which can be set during the programming phase

Also I do not feel like setting up a local DNS server on the computer where the devices are connected to. But indeed, this could help. Setting up a local DNS server for indentifying the controllerType and using the MAC Address as unique identifier.

...At the Ethernet level, the unique ID is the MAC address.

DHCP assigns IP addresses, or they can be fixed.
...

Quite often on a computer you can configure the machine to either have a static IP address or to have an IP address assigned by the DHCP server.

A problem with assigning static IP addresses at machines is that it is easy to lose track of what static IP addresses have been allocated particularly since, at any given time, all the machines might not be on the network.

A rather neat solution to this is to set all the computers to request IP addresses via DHCP but to configure the DHCP server to allocate specific IP addresses to machines with specific MAC addresses. The end effect is that some machines have static IP addresses even though they are being allocated via DHCP. The static IP allocation can be audited at the server without the need for all machines to be on the network.

Quite a neat solution.

ardly:
Quite often on a computer you can configure the machine to either have a static IP address or to have an IP
A rather neat solution to this is to set all the computers to request IP addresses via DHCP but to configure the DHCP server to allocate specific IP addresses to machines with specific MAC addresses.

Indeed, and quite often this can be done for security reasons, assuming 'users' do not have access to play with IP allocations on machines. Its the IP address that controls or restricts access thru firewalls and routers etc.