Author Topic: MAC address  (Read 5147 times)

Offline twoerner

  • Newbie
  • *
  • Posts: 16
    • View Profile
MAC address
« on: July 20, 2007, 05:45:24 PM »
Hi Mark,

Just out of curiosity, looking at the uTasker demo project, the ethernet's MAC address is hard-coded into the application to an initial value of all zeros and can subsequently be changed by the user. Don't ethernet chipsets have a MAC address stored in them from the manufacturer? Do we have access to this value?

It would be nice if, by default, the MAC address of my board were already set to something expected to be unique (i.e. the value stored in the hardware). Otherwise I'm guessing I can't have two devices on the same network running the uTasker code at the same time (until someone comes along and changes at least one of them)!

Best regards,
    Trevor Woerner

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2905
    • View Profile
    • uTasker
Re: MAC address
« Reply #1 on: July 20, 2007, 08:21:58 PM »
Hi Trevor

There are a few chips which are supplied with a predefined unique MAC address. These MACs belong to the chip manufacturer and you pay a small fee (included in the chip price) for them. But this is very much the exception and, although I did look at one a while back, I can't think of one to reference at this moment.

I have copied a small extract below about the MAC (from the uTasker tutorial) which is a quick overview about the 'rules' and how people can use them for hobby projects without having to purchase anything.

The way that it works in the uTasker project is that the MAC is set to all zeros by default and the web page allows it to be changed once! This is because it is generally necessary to set a unique MAC address for each piece of equipment and then not generally allow it to be changed (since the value needs to be managed by the owner of a block of MAC addresses which has been bought from IEEE). The value with all zeros is easily recognisable as a device which has not have its production MAC address set yet. It works in a network so it allows setting the 'real' MAC via Ethernet. One possible exception is when people set the device up to obtain an IP from a DHCP server because some DHCP servers don't like MAC 0:0:0:0:0:0 and won't give an IP address to it. This is probably not defined anywhere because others have no problem with assigning an IP address to MAC 0 - it seems however to be about 50:50 since it is often a question I get as to why DHCP is not working!

All of the chips supported by the uTasker project have no pre-defined MAC address so they have to be loaded during initialisation (the MAC is passed as a parameter when the Ethernet interface is opened).
The AT91SAM7X can have up to 3 MAC addresses programmed at the same time! This can sometimes be interesting. For example I use it in a project with TCP/IP as maintenance, control and software up-load protocol so that it can operate in an office environment. At the same time a second unrelated Ethernet based protocol runs communicating on a different MAC address. This is practial because the second protocol doesn't need any IP infrastructure or settings. It is proprietory (actually the uNetwork protocol which is a part of the uTasker project - see uNetwork.c) and so can run without needing ARP and is optimised for fast resonse times. A device with only one MAC address needs to share it between this and IP, which can have some disadvantages.
The STR91XF - also supported by the uTasker - has a one-time programmable section of FLASH (about 20 bytes). These can be programmed once (and never deleted or changed - ever again) and the last 6 bytes are defined to be the MAC address of the device. They are even loaded automatically at reset from these addresses to the MAC controller register. But only when the user has set them with the MAC address which it will then always have.

You are also correct that it is not a good idea to have more than 1 device on the network with the same MAC address (they should always be set up to at least be different). Very strange things can happen when this is not respected and sometimes it takes quite a long time to realise just why the strange things are happening - so best avoid.


Quote
Some notes about MAC addresses
If you are using your own device behind a router and it is not visible to the 'outside world' you can in fact program any MAC address that you like because it is in a private area. It just has to be unique in this private area. (This is also valid for a device sitting in a Demiliterized Zone- DMZ)
If however you are selling a product or the device is sitting directly on the Internet then it must have a world wide unique MAC address which has to be purchased from IEEE. It is purchased either as a block (IAB) of 4k MAC addresses at a cost of about $500, or if you are going to produce a large number of pieces of equipment you can purchase a unique company ID (OUI) of 16Million for about $1'600 (plus $2'000 if you don't want the OUI to be registered on the public listing).

It is then your responsibility to manage the assignment of these addresses in your own products.

The registration page is at: http://standards.ieee.org/regauth/index.html
For any one just wanting to make one or two pieces of equipment for hobby use it is a bit much to pay $500 for a bunch of MAC addresses and use just one or two of them. Unfortunately it is no allowed to sell the rest on to people in similar situation because a block must always remain with the individual or organisation purchasing it.

One trick which is often used is to find out what the MAC address is in an old NIC from an old PC which is being scrapped. This MAC address is then used in your own piece of equipment and the old NIC destroyed. You can then be sure that the MAC address is unique and can not disturb when used for any imaginable application.


Regards

Mark