CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

18f4620 tcpip server multiple devices on an intranet

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pingpong



Joined: 26 Nov 2012
Posts: 8

View user's profile Send private message

18f4620 tcpip server multiple devices on an intranet
PostPosted: Mon Nov 26, 2012 8:28 am     Reply with quote

I have made a Datalogger made from 18f4620 with tcpip using enc28j60. The device works well and communicates the data collected from an instrument to the PC based application.
A single device connected in an intranet works OK.
The problem is when I want to have multiple such devices communicating readings from different instruments on either the same or multiple PC's all connected in the same intranet. Since the instruments are different, their PC programs are also different.
At present, I am keeping the port address of 1000 for all the devices and assigning different IP address to each device. I am able to connect to only one device. I want to communicate on all devices on the same intranet.
Can someone help please.

Jimmy.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Nov 26, 2012 12:20 pm     Reply with quote

A lot more information would help on this...
Are you doing TCP or UDP? Are the connections persistent or created/released as needed?




Anyway, the first thing that comes to mind is this:

Did you see the number of sockets definition in the PIC tcpip stack? This limits the number of simultaneous connections the PIC will allow.

What is that number of sockets currently set at?
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
pingpong



Joined: 26 Nov 2012
Posts: 8

View user's profile Send private message

PostPosted: Mon Nov 26, 2012 12:38 pm     Reply with quote

Thanks bkamen

I am implementing Tcp. My software is a client and the 18f is server. I connect to my 18f before starting and that connection remains on all through out.

At present the max sockets is 5. But I am going to change that to 1 tomorrow as I don't want my device to be accessible to multiple PC simultaneously.

As soon as a reading is received, my device sends the reading to the pc software.
dorinm



Joined: 07 Jan 2006
Posts: 38

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 5:10 am     Reply with quote

are your MAC#s different?
pingpong



Joined: 26 Nov 2012
Posts: 8

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 6:44 am     Reply with quote

No The Mac's are the same.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Dec 02, 2012 8:33 am     Reply with quote

pingpong wrote:
No The Mac's are the same.


MACs in theory should be globally unique. In practice you can have duplicate MAC addresses provided these addresses do not occur on the same network segment.

If you have multiple devices on the same network segment (broadcast domain) then you will break the network layer and chaos will reign. LAN switches will thrash their tables as they learn the same MAC address in the same VLAN on different ports. IP forwarding for devices sharing the same MAC address will break, Devices will intermittently become unreachable.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
pingpong



Joined: 26 Nov 2012
Posts: 8

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 9:10 am     Reply with quote

OK I tried with different MAC Addresses and the thing worked.

Thanks all of you.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 10:02 am     Reply with quote

I forget just where I saw it, but someone suggested having one of the digital temperature sensors on your board. Not only does it provide temperature, it also has a unique serial number which can then be used to build the MAC address for your board. The end result is you don't have to customize the code for each board to define the unique MAC address, it ends up with a unique address due to the unique serial number of the sensor. Struck me at the time as a clever idea that would solve the problem easily.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 10:51 am     Reply with quote

gpsmikey wrote:
I forget just where I saw it, but someone suggested having one of the digital temperature sensors on your board. Not only does it provide temperature, it also has a unique serial number which can then be used to build the MAC address for your board.


For Dallas One-Wire devices, that's true, but Dallas makes those numbers up themselves and to my knowledge, those devices are not registered in the official MAC address block database.

So while it might work fine, technically, that device could bump into MAC addresses that are truly assigned in the big MAC database...

That's not a solution I would release into the wild in mass quantities.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D


Last edited by bkamen on Sun Dec 02, 2012 9:07 pm; edited 1 time in total
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Sun Dec 02, 2012 10:52 am     Reply with quote

Something useful about MAC addresses is that bit 1 in the first byte marks the address as "locally administered". You will (er, should) never see a "real" MAC address with that bit set, so if you're making up your own addresses, setting that bit should guarantee no collisions. i.e. 02:XX:XX:XX:XX:XX.

Something I also noticed the other day was that Microchip have added MAC addresses into a selection of their RTC chips (in addition to the range of EEPROMs with MAC addresses). It's becoming ever easier to get proper MAC addresses into a design.
_________________
Andrew
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 9:00 pm     Reply with quote

Good points Ben - I am used to my local network here where I am not likely to run into a problem, but you are correct about it not being a good plan to release into the "wild" (we all know how Murphy lurks around the corners). I did hear about 10 years back (when I was taking a Cisco class) that some vendors were starting to re-use some of their old MAC addresses figuring that the original hardware they had created was very unlikely to exist any more.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 9:08 pm     Reply with quote

gpsmikey wrote:
Good points Ben - I am used to my local network here where I am not likely to run into a problem, but you are correct about it not being a good plan to release into the "wild" (we all know how Murphy lurks around the corners). I did hear about 10 years back (when I was taking a Cisco class) that some vendors were starting to re-use some of their old MAC addresses figuring that the original hardware they had created was very unlikely to exist any more.



Yep! And not that it's unacceptable for in the lab use..

I have a stack of old ethernet cards that have been destroyed (recycled) and I kept the MAC addresses around...

but that whole release into the wild -- just mentioning it so people don't think it's a free pass.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Dec 02, 2012 9:09 pm     Reply with quote

andrewg wrote:
Something useful about MAC addresses is that bit 1 in the first byte marks the address as "locally administered". You will (er, should) never see a "real" MAC address with that bit set, so if you're making up your own addresses, setting that bit should guarantee no collisions. i.e. 02:XX:XX:XX:XX:XX.



until you put such a device out in mass quantities in the real world and it runs into someone else doing the same thing. hahah. that would suck.

As for the rest about microchip selling so many other single use MAC on an EEPROM or what -- it just makes it soooo easy.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group