Author Topic: Server has fixed IP and MAC address. Do I need ARP?  (Read 7288 times)

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Server has fixed IP and MAC address. Do I need ARP?
« on: March 07, 2008, 08:47:06 PM »
I have about 500 clients on a network with one server. The server's MAC address and IP address are  fixed and known. Is there a way to have this information permanently in the ARP cache or otherwise avoid the ARP messages? The clients never talk to each other.

Thanks,

Ewan.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Server has fixed IP and MAC address. Do I need ARP?
« Reply #1 on: March 07, 2008, 11:42:17 PM »
Ewan

You can do this as follows:

I have taken an example of the TIME SERVER connection in the demo code (application.c).

    if ((TIME_TCP_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnTimeListener)) >= 0) {
        fnTCP_Connect(TIME_TCP_socket, (unsigned char *)&ucTimeServers[ucTimeServerTry++], TIME_PORT, 0, 0);
    }


This is a connection to a server somewhere on the Internet and so will normally cause an ARP resolve to be sent the first time to find the local gateway and then the TCP connection will be established via the gateway. I can prime the IP / MAC of my gateway (router) as follows and so the TCP connection is established without first sending an ARP - it is a fixed entry and will not timeout.

    unsigned char server_ip[IPV4_LENGTH] = {192, 168, 0, 1};
    unsigned char server_mac[MAC_LENGTH] = {0x00, 0x0d, 0x88, 0xe7, 0x6a, 0x49};
    fnAddARP(server_ip, server_mac, ARP_FIXED_IP);
    if ((TIME_TCP_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY, TCP_DEFAULT_TIMEOUT, fnTimeListener)) >= 0) {
        fnTCP_Connect(TIME_TCP_socket, (unsigned char *)&ucTimeServers[ucTimeServerTry++], TIME_PORT, 0, 0);
    }


Here the values are fixed but it would be possible to make them configurable and save them to parameter FLASH so that all devices can be set up and then operate with the value until possibly reconfigured.

Note that fnDeleteArp() deletes all entries (including fixed ones) and so afterwards such fixed ones may have to be added again. If you find that you need to be able to selectively delete, or just delete all non-fixed entries, this can be quite easily made available.

Regards

Mark

« Last Edit: March 14, 2008, 02:53:08 PM by mark »

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: Server has fixed IP and MAC address. Do I need ARP?
« Reply #2 on: March 08, 2008, 12:17:30 AM »
Mark,

Perfect!

Thanks once again,

Ewan.