Pages: [1]   Go Down
Author Topic: Ethernet shield - basic intro to networking  (Read 1934 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I'm setting up an Wiznet W5100 ethernet shield & while i'm very conversant with the Arduino environment, PHP development, Apache server configurations, i get lost when it comes understanding network setup... To give a bit of background, i'm currently using OSx10.5 on a Mac not connected to a network/internet, only to the shield via a standard ethernet cable.

I've a couple of simple (i hope) questions:

A. How do I assign  an IP address to the shield in order to get the simple web server example working? & what is the easiest way to check if a network address is free.

B. How do I check if the shield has a unique mac address?

C. Subnet masks - hmmm this confuses me...

Cheers for any tips.
Tom:)
Logged

Liverpool, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hopefully some simple to understand answers then :-)  

One thing I'm not sure about, but which might cause problems (and I'm sure someone will be along soon with the right answer) is your ethernet cable.  If you aren't connecting through a hub or a switch, and just plugging the ethernet shield direct to your Mac then you might need a crossover cable rather than a standard ethernet cable.

Now to your questions:

A) Assigning the IP address to the shield is just a case of setting the right value in the sketch.  The examples have an array where you fill in the IP address you want to use.  If you're only connecting to your Mac then just make sure it's different to your Mac's IP address.  

Normally, I'd just find out the IP address of another computer on the network, and then change the last number at random and see if anything responds to that when you try to ping it.  For example, my laptop's IP address is 192.168.1.5, so I'd try typing "ping 192.168.1.205" in a terminal.  If I got a reply then that address is in use, so I'd try different ones until I didn't get a reply.  (It might be that a machine does exist with that address, but is turned off - if it starts behaving strangely in future I'd double-check)

B) I wouldn't worry about it too much, and use the one given in the examples.  You only need to change it if you start having more than one Arduino with an ethernet shield on the same network

C) Do you need to set that for the ethernet shield?  If so then just copy whatever your Mac is using - I'm not sure how you check on a Mac, but you might be able to type "ifconfig" in a terminal.  Or if you're using the 192.168.1.x private network, the standard netmask is 255.255.255.0.

Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
just plugging the ethernet shield direct to your Mac then you might need a crossover cable rather than a standard ethernet cable.
Both the Wiznet shield and the Mac should be auto-sensing so a cross-over cable should be unnecessary.

Quote
If you're only connecting to your Mac then just make sure it's different to your Mac's IP address.
If you configure your Mac's wired Ethernet port to use DHCP it will eventually get a "self assigned" address in the range 169.254.x.y, if you also give your Arduino an address in the same range you don't have to manually configure your Mac with a specific IP. (I could probably do to explain that better, I realise...)

Quote
C) Do you need to set that for the ethernet shield?
The netmask for the above suggestion would be: 255.255.0.0

--Phil.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK all helpful stuff - thankyou.

Setup is now:
Ethernet board plugged in with ethernet cable. Arduino plugged in with USB cable. Webserver sketch is uploaded. Shield "FullD", "100m" & "link" leds are all on. "Rx" light flashes every now & then.

SystemPreferences->Network->Ethernet
is set to configure Using DHCP. Ethernet is listed as having a self-assigned IP address "169.254.70.26". I'll leave subnet Masks out of it at the moment as its not a requirement for the webserver example.

In the WebServer sketch I've set:
byte ip[] = {169, 254, 70, 27 };

In terminal:
ping 169.254.70.27
Gets the following response:
From 192.168.1.41 icmp_seq=1 Destination Host Unreachable

I also tried:
byte ip[] = {192, 168, 1, 42};
ping 192.168.1.42
But got the same response:
192.168.1.42
From 192.168.1.41 icmp_seq=1 Destination Host Unreachable

Am I missing something?


« Last Edit: March 04, 2009, 02:56:27 am by tomski » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK I tried a slightly different setup where I plugged the shield into an ethernet port of my wireless router, then looked at the router config list of connected devices & it came up as:
      
Physical Address:      00:1f:f3:d7:09:4c
IP Address Assignment:      Static
IP Address:      192.168.1.70

I then set the sketch IP and re-uploaded:
byte ip[] = {192,168,1,70 };

Typed 192.168.1.70 in a browser and got the expected output:
analog input 0 is 463
analog input 1 is 424
analog input 2 is 418
analog input 3 is 409
analog input 4 is 434
analog input 5 is 362

Yet when I ping 192.168.1.70 I get:
From 192.168.1.41 icmp_seq=2 Destination Host Unreachable

How come? all feels like a dark art to me smiley-wink
Will have another go at a direct computer plugin as thats what I need to achieve...

*EDIT
With a direct computer->arduinoShield connection I tried:
byte ip[] = {169.254.70.27};
Then typed "http://169.254.70.27" in a browser & it worked!! smiley

Same question though - how come "ping 169.254.70.27" gets a "Destination Host Unreachable" response?





« Last Edit: March 04, 2009, 03:17:15 am by tomski » Logged

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
With a direct computer->arduinoShield connection I tried:
Code:
byte ip[] = {169.254.70.27};
That's not really what you had, is it? Those periods should be commas.

No idea why you get the difference in behaviour between ping and http. You could always try WireShark or something to see if you can notice what's different.

--Phil.
« Last Edit: March 08, 2009, 03:59:23 am by follower » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes had commas, the above was a copy/paste error;) will give wireShark a go thanks for the headsup on that....
« Last Edit: March 09, 2009, 05:01:39 am by tomski » Logged

Pages: [1]   Go Up
Jump to: