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:
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:

If you use 8 or less sockets, you just use “TCP” socket mode, don’t need to use “MACRAW” mode.
I’m not sure you’ve already known about the TCP/IP protocols, TCP is a connection based communication. So, before data transmission, connection process should be completed between W5200 and App1,2,3…
For example,

  1. Assume that W5200 socket 0 is a server.(listen socket)
  2. Assume that W5200 socket 1 is a server.(listen socket)
  3. App1(IP1,Port1) is a client.(connect)
  4. App5(IP3,Port1) is a client.(connect)
  5. App1(IP1,Port1) try to connect to W5200 socket 0 and accept the connection (connection established)
  6. App5(IP3,Port1) try to connect to W5200 socket 1 and accept the connection (connection established)
  7. in case of App1(IP1,Port1), you can send/recv data through W5200 socket 0.
  8. in case of App5(IP3,Port1), you can send/recv data through W5200 socket 1.

1 TCP connection supports one peer socket(IP, Port).
If you want to change peer ( ex) Peer1->Peer2 ),

  1. you must disconnect the exist connection from current peer(Peer1).
  2. you need a new connect process between W5200 and another peer(Peer2).

If you need more detail information for TCP/IP and socket programming, I think, you’d better search another simple & good materials from Internet world (google it :wink: )

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

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?


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).

Because of technical support. W5200 continues to produce for existing projects, but for new projects, it’s difficult to provide technical support.
if you still use W5200 “MACRAW” mode, please refer to errata#3 from https://www.wiznet.io/wp-content/uploads/wiznethome/Chip/W5200/Documents/W5200_ES_V106E.pdf

I tried but:

No, you don’t need to use 1~7 socket, Just use “MACRAW” socket 0 for all connections.(but you need to port S/W TCP/IP stack)
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?

No, No, when you use “MACRAW”, W5200 just check you MAC address.
All Broadcast packet and packets with having destination MAC address same as your setting on W5200 will be received.
W5200 don’t see any port number & IP address. just look for MAC.
In case of “MACRAW” mode, S/W stack should care for IP, Port filter and processing.

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?

As I understand,
you can read this data from W5200 and

  1. read 2 byte for Packet-Info (len of ethernet packet)
  2. read DATA packet from W5200 as “Packet-Info” len
  3. DATA packet includes “IP/port/TCP header, ARP packet, UDP packet”…

But, is it what you want? :cry:

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?

no, pc side same.
pls check MAC address on W5200. is it same when you used H/W stack?
Just for your reference, our team member upload very old reference source code with MACRAW. I hope, it could be more help.

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

This code is very old and you have to compile using the AVR tool. just see the codes
W5200_Macraw.zip (218.4 KB)

It’s strange, if you set the MAC address, there is no problem to get packet.
I don’t know exactly why there is no receiving data.
Could you try it without any switch? Direct connect btw PC & W5200 board.

PS) Sorry, I will check this issue on Monday again. please leave the result & any feedback.

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 (19.0 KB)

Thanks for the help.

Good news~ I think, it looks correct. :smile:

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?

Then I should now do something like LwIP then with that incoming data or something like @irina_kim uploaded.

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

Max MTU size is 1500byte because generally Ethernet use. It means available data in TCP, IP or application layer excluding Ethernet header and trailer.
About the sub-divide, I think the lwip function is already built in.