---
title: "IPRAW vs MACRAW"
url: "https://maker.wiznet.io/forum/13440"
markdown_url: "https://maker.wiznet.io/forum/13440/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "aripod"
created: "2019-08-15T11:19:01+09:00"
last_activity: "2019-08-23T02:11:15+09:00"
language: "en"
views: 2062
replies: 13
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# IPRAW vs MACRAW

## Question

Asked by aripod on 2019-08-15 in Ethernet Chips.

Hello,

it is not quite clear to me which mode I should use. I want to have the w5200 with one entry point let’s say. To this, I want to be able to send and receive messages from different peers. Therefore, I believe I should use MACRAW so I can choose destination IP and port when I want to send and filter it (my self via software) from which IP and port the message comes from.
This is what I want to achieve:
![Untitled%20Diagram](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/9/92c72aeaa823b9e8e7ece82108b21d200681d0ca.jpeg)
As you can see, I would need more than 8 sockets to achieve having the w5200 receiving and sending messages to different applications from different peers. So, each peer will have a unique IP but can communicate to the w5200 through different ports to send, receive or send and receive. So, that is why there are multiple peers (=multiple ips) and multiple ports per IP. I can do this with the hardwired TCP/IP stack but I am limited to 8.
As it can be seen in the diagram, some applications can only send, others can only receive and some can send an receive.
Checking the documentation, I understood that this is what it is referred to “software TCP/IP stack”, but my problem to understand is that in MACRAW mode, I will have 6 bytes which refer to the mac.

1. How can I know the IP and port where a message comes from or how to tell the w5200 to which IP address and port send the message to?

2. There is a limitation of up to 1500 bytes. What if I need to send more than that? Would it be possible to send chunks of 1500 bytes but have on the receiving end like it was one send instead of multiple ones?

Thank you for the help.

EDIT: So the answer to question 1 is in the tcp header that I will receive by reading the raw data.
However, I opened the socket in MACRAW, tried to connect from a PC but the w5200 never answers. I want to send data over TCP/IP so I have a simple python code for this. I see on wireshark that only the packets going out of the PC to open the socket are present but there is no response from the w5200. Do I need to first have socket 1 to 7 in used before I can start with MACRAW?![:confused:](https://emoji.discourse-cdn.com/twitter/confused.png?v=12)

## Replies

### Reply 1 by aripod, 2019-08-16

![](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/48.png) Bong:

> If you use 8 or less sockets, **you just use “TCP” socket mode, don’t need to use “MACRAW” mode.**

That is the issue I am trying to circumvent, when I need more than 8. Now I have it working with all sockets, but I need to have more connections. That is what I wanted to say with the diagram and why I thought about the MACRAW mode.
I cannot disconnect an existing connection from a current peer as I need that connection later again.
Wouldn’t then be an option the MACRAW mode when I need more than 8 sockets?

![](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/48.png) Bong:

> - *) W5200, W5500, W6100 can support 8 sockets (8 TCP connections).*
>   *Please don’t use W5200 for your new design. please use W5500 or W6100.*

Why?

### Reply 2 by aripod, 2019-08-16

![](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/48.png) Bong:

> yes, you should use “MACRAW” mode if you need more than 8 sockets.
> In case, you should port S/W TCP/IP like LwIP on your firmware(software).

I tried but:

![](https://avatars.discourse-cdn.com/v4/letter/a/838e76/48.png) aripod:

> I opened the socket in MACRAW, tried to connect from a PC but the w5200 never answers. I want to send data over TCP/IP so I have a simple python code for this. I see on wireshark that only the packets going out of the PC to open the socket are present but there is no response from the w5200. Do I need to first have socket 1 to 7 in used before I can start with MACRAW?![:confused:](https://emoji.discourse-cdn.com/twitter/confused.png?v=12)

### Reply 3 by aripod, 2019-08-16

![](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/48.png) Bong:

> If you use only MACRAW mode, S/W TCP/IP stack could send response packets. Please check the software part.
> I recommend, test simple ARP send()/recv() function first with S/W stack.

Following the datasheet, from the w5200 side, setting the mode and opening the socket, shouldn’t I have been able to receive an ethernet package? From the sender part, I know the w5200 IP and I chose a port number from 0xc000 to 0xf00. Then I should be able to filter these when I receive the ethernet package only by opening the port…right?

### Reply 4 by aripod, 2019-08-16

Yes, I know…but from the pc I can send over tcp/ip by choosing ip and port which will be in the ethernet package that I will read in the w5200, or not? Or it means that from the PC as well, I cannot use standard tcp/ip socket functions?

### Reply 5 by aripod, 2019-08-16

Yes, that is exactly what I want.

But after I opened the socket on the w5200 I sent the same way I did before to receive with the hardwire tcp/ip stack but this time, I can see the package from the pc to the w5200 (to connect to) but when I check if I receive something, there are no new bytes on the w5200’s RX buffer. So the question is if I need to do something different then on the PC side as I do when I have a socket with the hardwire tcp/ip?

### Reply 6 by aripod, 2019-08-16

![](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/48.png) Bong:

> pls check MAC address on W5200. is it same when you used H/W stack?

Yes, it is the same MAC. I use the same function to initialize the w5200 (MAC, subnet, IP and gateway).

### Reply 7 by irina, 2019-08-16 (in reply to reply 5)

Hi~
This code is very old ~~and you have to compile using the AVR tool.~~ just see the codes
[W5200_Macraw.zip](https://maker.wiznet.io/forum/legacyFile.asp?path=mO5PnzqgwECurdY9a9wOCjg9p1v.zip) (218.4 KB)

### Reply 8 by aripod, 2019-08-19

So there is actually always something on the receiving buffer. I have a router where I connect the w5200 and the PC. The data is either something from the router or from the PC. I can see their MAC addresses.

I believe there is something to do with the protocol before being able to send and receive any information and that is what the hardwire tcp/ip stack takes care of before I can open a new socket. And that is all the data that I am seeing there. Please let me know if that is correct.

If it is, I would need to process all that by myself before I am able to open a new socket on the pc to send/receive information from/to the w5200.

Just in case, I attached a log file with data from the router and data from the pc. [macraw.hex](https://maker.wiznet.io/forum/legacyFile.asp?path=8JE0wU8cCZKlRRE8r9s429AX5Cs.hex) (19.0 KB)

Thanks for the help.

### Reply 9 by aripod, 2019-08-20

One thing that is not clear is that I have in the buffer, for example, 2009 bytes but the first 2 ones (byte size of DATA packet) is 0x00 0x3e = 63 bytes. Why is the difference so big between these two?

![](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/48.png) Bong:

> Good news~ I think, it looks correct. ![:smile:](https://emoji.discourse-cdn.com/twitter/smile.png?v=12)

Then I should now do something like LwIP then with that incoming data or something like [@irina_kim](https://maker.wiznet.io/u/irina_kim) uploaded.

### Reply 10 by aripod, 2019-08-20

and what about the size of data I can send? If it is limited to 1500 bytes…how is it possible to send bigger packages than that? Let’s say I have 5000 bytes to send. Then, it will be splitted in 3x1500 and 1x500 but will that represent that on the receiving peer it will be like receiving 4 different packages or it is possible to see it as one big 5000 bytes one?

EDIT: Given that case…it would be possible to subdivide the data to send and establish in the protocol header that the complete message will be sub-divided, right? So it is not up to the w5200 but how the protocol’s header is built

### Reply 11 by irina, 2019-08-21 (in reply to reply 10)

![](https://avatars.discourse-cdn.com/v4/letter/a/838e76/48.png) aripod:

> and what about the size of data I can send? If it is limited to 1500 bytes…how is it possible to send bigger packages than that? Let’s say I have 5000 bytes to send. Then, it will be splitted in 3x1500 and 1x500 but will that represent that on the receiving peer it will be like receiving 4 different packages or it is possible to see it as one big 5000 bytes one?

Max MTU size is 1500byte because generally Ethernet use. It means available data in TCP, IP or application layer excluding Ethernet header and trailer.
![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/f/ff63a22745e6fe0eb8488befefcf716a32df4882.png)
About the sub-divide, I think the lwip function is already built in.

### Reply 12 by aripod, 2019-08-22

irina_kim:

> About the sub-divide, I think the lwip function is already built in.

To avoid opening a new thread…Is it possible to subdivide also with the hardwire tcp/ip stack? In the case to send something larger that the 8kb buffer (considering using only one socket)

### Reply 13 by irina, 2019-08-23

I think it can’t send the data larger the 8K buffer at one time about one packet
The data tha can fit in a packet is less than 1500 bytes and I don’t know what it means to send 8 kbytes at a time.

Previously I said ,About the sub-divide, I think the lwip function is already built in…

---

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