Ethenet connection between two mbed processors...

02 Nov 2010 . Edited: 02 Nov 2010

Hi

I would like to connect two or more mbed processors via Ethernet. That should not be a problem.., but I also want the get the internet time. I looked into the programs HTTPClientExample, HTTPServerExample, NTPClientExamble and EthernetTesterGood.

I was able to integrate HTTPClient, HTTPServer and NTPClient into one program. The Ethernet connection comes up, get an IP address, gets the time from a server around the world and wait for input.

I also looked into EthernetTesterGood and it works fine, but somehow I cannot integrate NTP into the code..

But how can I scan for other mbed processors? How can I talk to other mbed processors? It would be nice if the system can scan by IP address so I can scan the range of my intranet given by my router ( e.g. 192.168.1.x ). I assume I have to use a different port then 80. I think 666 will be nice...

Does anyone can help me with the communication, using EthernetNetIf, between two or more mbed controllers?

 

Ben

03 Nov 2010

Either hard code the IPs or have them read the local and remote IPs from a configuration file.

03 Nov 2010

And if you don't know what they are in advance to have a preconfigured setup like Mike described then you'll need to implement LLDP or something similar

04 Nov 2010

Just a thought:

If you use broadcasting then you can have the host send out a "magic-message" throughout your network.

On reception of this magic message by a slave, a reply can be send back to the host, this way the host can 'find' the other nodes in your network.

If you implement this using UDP you have the advantage of not having any timeouts

05 Nov 2010

erm "magic message" ?? What's LLDP then if it's not "magic with a defined protocol"

06 Nov 2010

LLDP = Link Layer Discovery Protocol

It is indeed a "magic message" with a defined protocol, but that protocol is specifically designed to find other devices on the network and return lots of useful information about them.

There's probably a lot offeatures of LLDP that you don't need, so fully implementing it may be a waste of time and memory.

Broadcasting a Magic message can just be a single UDP packet that does the equivalent of saying "are there any mbeds out there?". Then you code an mbed to listen for that message.

If you look up IP Broadcasting, it's a way of sending a message to every machine on the local lan by only sending one packet. the destination address you use is the last address in the subnet, so for the classic LAN subnet of 192.168.0.0/24 the broadcast address is 192.168.0.255. You'll also need to make sure you sent it to a broadcast mac address to tell any network switches to send the packet out of all ports. IIRC the broadcast mac address is all 1's

Matt

07 Nov 2010

Matthew gets the idea!

Just send out a message requesting response from any other connected mbeds. Actual contents of this message doesn't really care, as long as all mbeds speak the same language. Preventing false responses can then be easlily prevented by using a simple check on the replied message e.g. some math on a number that was send out by the host.

Of course, if this functionality is available within LLDP and available, then for sure use it, but keep it simple and clean, no need to implement functionality that eventually doesn't bring you anything.

Good luck with it!

Frank

 

07 Nov 2010

You're all missing the point here. You don't have to implement a full LLDP implementation, just what you need. The advanatge is if you make your "magic message" use the LLDP broadcast packet format, in like you say it's minimalist form, then all that LLDP code on computers everywhere that listen for LLDP packets can consume then. I'll bet at some point someone will say "that's great! can we just plug in this PC and list all those Mbed devices now please?" If your "magic packet" is LLDP then you won't have to then write a "special PC program" for a PC, Mac or Linux box to do that.

You don't have to write a full LLDP system, just use it's defined network protocol (which is *very* simple btw) to make your broadcast packet. If you then published your "mini LLDP" code others may build on it and extend it's functionality and add "goodness" to your start. If you don't use LLDP you'll always be alone, no one will extend a "homed network packet protocol".

08 Nov 2010

Ok, seems LLDP is the direction I will look into. The big challlange will be writing the mini LLDP. With no experience with ethernet software I have a lot to learn.

 

Ben

08 Nov 2010

Take a look here: http://en.wikipedia.org/wiki/Link_Layer_Discovery_Protocol It describes the packet format and as you will see it's pretty basic and easy to construct. The Wikipedia also has lots of external links that describe it in more detail.

08 Nov 2010

Thank you Andy, I allready went there...

As I stated... I am not that well known with embedded. I'm more the hardware guy...

But I will do mij best :)

08 Nov 2010

Ben, just so you know, I'm looking at making a "thin LLDP" library. I'm a hardware guy too but I have a lot of experience with networking software and device drivers. When I have something I'll come back here and follow up and if it's of use you can plunder it for your own use :)

08 Nov 2010

Well, I couldn't resist, so I had a play.....

08 Nov 2010

damn...ok.

Looks nice but doesn't help me to implement it yet ;)

I have to finish another project first ( vhdl ) before I move on in this project. But I appreciate your work and thoughts.

In the meanwhile I will read more about lldp.

 

Ben

23 Nov 2010

I have tried to look at your code but I get it yet... I think...

 

But, I do have something working now. Donatien Garnier posted UDPSocketExample and someone ask a question abot this program.

I downloaded and modified the code a bit and it seems to work... They can see eachother and can communicate

 

Next step is still looking into lldp.

24 Nov 2010

user Ben Schueler wrote:

I have tried to look at your code but I get it yet... I think...

 

But, I do have something working now. Donatien Garnier posted UDPSocketExample and someone ask a question abot this program.

I downloaded and modified the code a bit and it seems to work... They can see eachother and can communicate

 

Next step is still looking into lldp.

can you publish your code? I would also like to find other mbed but not sure how to implement it.

24 Nov 2010

No problem. Let me clean up the code first.

Will try to do it this evening.

24 Nov 2010

This should work.... http://mbed.org/users/Schueler/programs/UDPSocket_Node/lidkv7

As Simon Ford mentioned in a other topic, it probably only works on the LPC1768... Next version will include the new upd lib.

24 Nov 2010 . Edited: 24 Nov 2010

I am trying to figure out what you did here but have little to no knowledge of UDP or internet protocols. Can you brief describe the process the program goes through? Also, what is the button5 is suppose to be?

edit: do you know how I would get the 2nd mbed to respond back with its ip address?

24 Nov 2010

Well, I don't have any knowledge about udp or Ethernet protocols to but... I just justed the example file and changed it to my needs. the description is now somewhat better, I think. But as I mentioned, it is still a test. I will build a parser and a function to find mbed modules on the Ethernet automatically.

Comment on your edit, yes you can respond with the ip address of the host in your message.