Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

NicheStack TCP Client not working with some servers

I've been trying to talk to an Arecont IP camera via a TCP socket client on a BeMicro Nios2 app.

The connection to the camera always failed to establish, although it was ok if I substituted the camera for a TCP server on a Windows PC.

After lots of debug, I noted that the ARP reply from the camera did not have the correct Target Protocol (IP) Address (TPA); it actually contained the camera's IP address. It should have the originating client IP address.

Investigation revealed that the NicheStack ARP receiver code filters the ARP messages using the Target IP Address (TPA).

The code is as follows:

{bsp}/iniche/src/ip/et_arp.c

int

arprcv(PACKET pkt)

{

...

/* check ARP's target IP against our net's: */

#ifdef IP_MULTICAST

if ((arphdr->ar_tpa != pkt->net->n_ipaddr) && /* if it's not for me.... */

(!IN_MULTICAST(ntohl(arphdr->ar_tpa))))

#else

if (arphdr->ar_tpa != pkt->net->n_ipaddr)

#endif/* IP_MULTICAST */

{

LOCK_NET_RESOURCE(FREEQ_RESID);

pk_free(pkt); /* not for us, dump & ret (proxy here later?) */

UNLOCK_NET_RESOURCE(FREEQ_RESID);

return (ENP_NOT_MINE);

}

As the Target IP Address does not match the client IP address, ARP discards the camera response. A connection timeout results.

Whilst the code to filter the ARP responses can be commented out, it exposes the stack to much higher traffic and buffer errors can result.

Question? Is the camera in error by not setting the ARP reply Target IP Address (TPA) correctly or is the NicheStack in error by filtering on it?

13 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can always use another camera ;)

    But as I said, the MAC already filters packets that don't have the correct MAC destination address in the Ethernet header, so in theory the only ARP packets that should arrive to this function are broadcasts and the replies specifically destined to you. So I don't think you'll have an increase in processed ARP packets if you do this. But I agree you shouldn't have to modify your TCP/IP stack to cope with bad equipment...
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The camera people, Arecont Vision in this case, excepted the problem was with their firmware and issued us a fix within 2 weeks. We checked out the fix and all is ok - the ARP response is formatted correctly. How's that for service!:)