---
title: "W5100s Socket WrapAround"
url: "https://maker.wiznet.io/forum/13395"
markdown_url: "https://maker.wiznet.io/forum/13395/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "grama"
created: "2019-07-15T19:06:02+09:00"
last_activity: "2019-07-16T14:46:35+09:00"
language: "en"
views: 543
replies: 5
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5100s Socket WrapAround

## Question

Asked by grama on 2019-07-15 in Ethernet Chips.

I only have one socket opened. The RMSR is initialized to 0x55.
However, when I wrote 1950 bytes, then 100 bytes.
I expected this to cause a wrap around. However, I see the Rx write pointer is at 0x802 (2002d).

Is this expected behavior?
Thanks.
Giri

## Replies

### Reply 1 by Eugeny, 2019-07-16

RX_RD is rather 16-bit counter than pointer. You get pointer to the data according to the datasheet by masking with buffer size and adding buffer base address. Thus counter us 0x802, buffer size is 0x800 then relative data location in the buffer is 0x002.

### Reply 2 by grama, 2019-07-16 (in reply to reply 1)

That doesn’t make sense.

If each Socket Receive pointers do a wrap around, then when I get data > RX Buffer size it should start back at the start of buffer.

What you define is NOT wrap around, if the counter continues to increment PAST the buffer size.

The RX_RD has to be a 16-bit pointer as the buffer/socket would be > 256bytes.

So a Wrap around definition to me is (ignoring the base offset), then the buffer (of 2KB will go from 0000 to x0800. Then when I get the next byte the RX_RD has
to have a value of 0x001 (and not 0x0801).

If not, the SN0 Rx data would be overwriting the data in Sn1 Rx buffer.

Giri

### Reply 3 by Eugeny, 2019-07-16

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> That doesn’t make sense.

What exactly does not make sense?

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> when I get data > RX Buffer size it should start back at the start of buffer.

This is true. And you **can not** get more data than RX buffer size. By definition. Extra data will wait at another end (TCP) or will be discarded (UDP/RAW).

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> What you define is NOT wrap around

I did not say these words - “wrap around”, and did not define this term. It seems you want to see wraparound here.

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> The RX_RD has to be a 16-bit pointer

It is.

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> So a Wrap around definition to me

You can see definition of wraparound [here](https://en.wikipedia.org/wiki/Wraparound):

> **Wraparound** , **wrap around** , or **wrap-around** is anything that [wraps](https://en.wiktionary.org/wiki/wrap) [around](https://en.wiktionary.org/wiki/around) something.

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> the buffer (of 2KB will go from 0000 to x0800. Then when I get the next byte the RX_RD has to have a value of 0x001 (and not 0x0801).

Did you read the [datasheet](https://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5100s:w5100s_ds_v100e.pdf), sepecially chapter 4? It clearly says how to use RX_RD register, and how to obtain address to the data from it.

![](https://avatars.discourse-cdn.com/v4/letter/g/7cd45c/48.png) grama:

> the SN0 Rx data would be overwriting the data in Sn1 Rx buffer.

It will if you do not follow datasheet guidelines and do not mask the RX_RD value with the RX buffer size.

### Reply 4 by grama, 2019-07-16

You are right. I wanted the Rx_Rd to behave a certain way, and didn’t fully understand the datasheet.
I apologize for my response.
Giri

### Reply 5 by Eugeny, 2019-07-16 (in reply to reply 4)

No problem. There’re some uncertainties even in datasheets, thus if you have questions come here and ask.

---

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