---
title: "Problem with Gratuitous ARP when trying to send UDP"
url: "https://maker.wiznet.io/forum/9867"
markdown_url: "https://maker.wiznet.io/forum/9867/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "kevinweiss"
created: "2014-01-24T21:05:34+09:00"
last_activity: "2017-05-04T08:31:22+09:00"
language: "en"
views: 1031
replies: 4
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Problem with Gratuitous ARP when trying to send UDP

## Question

Asked by kevinweiss on 2014-01-24 in Ethernet Chips.

First, I am using the W5200 with a PIC24FJ256GB210 and the HW TCPIP Library Driver ver.1.2 with the microchip_solutions_v2013-06-15. I am trying the setup a class one EIP connection which requires opening and closing a UDP socket at port 2222. I am getting Gratuitous ARPs whenever my device tries to send a UDP message. From what I have read, the UDP needs to send out an ARP to know where it is going, I don’t believe this is happening correctly. I was able to get it working by inputing the MAC of my computer directly into the registers then using the MAC_SEND version. However, since I can’t hardcode the desination MAC for other computers this is not a viable solution. I cannot find where the W5200_UDP.c version assembles the header information compared to the Microchip stack version in UDP.c UDPFlush(). The W5200 version of UDPFlush() only puts them in the Sn_DIPR0 reg, it doesn’t add it to the TX buffer.

I will attach the wireshark trace to help clarify.

Thanks in advance for your help.

Kevin Weiss
Firmware Engineer for Powell Industries
[EIPARPProblem.rar](https://maker.wiznet.io/uploads/short-url/dUZKeKmt2gihkebKtfQRG7GryY4) (1.18 KB)

## Replies

### Reply 1 by kevinweiss, 2014-01-27

My device is connected directly into my CPU via ethernet cable. My device IP is 169.254.1.1 and my CPU is 128.1.1.25. I will look into deeper in the stack, maybe the MACRAW mode isn’t being implemented correctly. If anyone has gotten these stacks to work together let me know (and the versions).

### Reply 2 by kevinweiss, 2014-01-28

The subnet Mask is 255.255.0.0. The results are the same through a router or not. The TCP is working fine. The program with the CPU claims an address (the LAN 128.1.1.25 in this case) for transmission.

### Reply 3 by kevinweiss, 2014-02-01

I have managed to get everything working and have a few notes for anyone interested.

The HW TCPIP Library Driver ver.1.2 that was used did not allow UDP to work with my microchip product

The SW TCPIP Library Driver ver.1.4 had a fault (the orginal reason I switch to the HW TCPIP library) which would cause an occasional packet to be improperly sent… This caused a unpreventable timeout in my software.

The reason for this timeout was in

SW TCPIP Library Driver ver.1.4
W5200.c
void MACPutArray()

if( RealTXPAddress.Val + len > TXEND ){

that line should be;
if( RealTXPAddress.Val + len >= TXEND ){

The problem would truncate the length of the sent packet only if RealTXPAddress.Val + len == TXEND
Since my packets are around 100 bytes and my buffer size was 4k

there is a 1 in about (100*4k) 400000 chance of getting this error.

Hopefully this helps other people, also please update stack to fix this. This cost a lot of unnessasary time.

Kevin Weiss

### Reply 4 by markqnorman, 2014-02-12

Hi Kevin
I am currently developing an EIP layer using a PIC24 too. I would be interested in what you are using for the EIP layer? Is it bought or is it your own? If it is third party I would be very interested in details. If it is a working home brew I would be also interested in a code share.
Mark

---

Source: https://maker.wiznet.io/forum/9867
