WIZnet Developer Forum

Basic questions about WIZnet/5100

I have several noob questions about UDP, please help answering them. While they look like easy, I can not find explicit answers to them.

  1. Can I use a socket for both receiving and sending, or only sending, and when send command completes, can initiate receive?
  2. when W5100 is going to receive packets - only after I issue RECV command? Can I send through same socket when in “receive” mode?
  3. if I do not issue RECV command, but remote server responds with UDP, is the packet from server being lost (not received)?

You can see my questions show misunderstanding of how it works in general. Unfortunately datasheet is full of technical details about the chip, but how it works in general is only depicted in the page 28 on nice low quality diagram, without any explanations. According to it, I can initialize socket in SOCK_UDP mode, and that’s all. Which operations, in which sequence can I perform on open socket, is not clear.
Thank you.

NOP

Thank you very much for the information. You talk about UDP in general. I need information about UDP in terms of implementation in W5100.

So:

  1. First question was if same socket in W5100 is able to receive and send at the same time. I assume the answer is YES but I can not find explicit statement about it in W5100 documentation.
  2. Second question was how to trigger W5100 receiving (or not receiving) packets on specific port set up for the socket. Do I need RECV command, and when? Imagine I open socket as UDP, set up port to 67 (yes, I am implementing DHCP), and what’s next? Will it automatically start receiving all packets to IP set up in SIPR and broadcast ones, or I need RECV command? Is RECV command persistent (e.g. when it “finishes” with 0 in command register, will W5100 still wait for UDP packets for port 67)? If it is persistent, how to cancel it so that socket would not listen to this port 67 any more?
  3. Third question was a subset of question 2 - when and why I need RECV command for UDP communication.

NOP

Thank you, but it does not answer questions I asked. I already studied these documents, and I think I have an idea how DHCP protocol works.
My questions are related to how to implement UDP communication using W5100 - protocol between W5100 and the computer bus it is connected to.

NOP

I am not sure I understand what you are talking about. Where are functions you are talking about? Previous document you have attached is description about DHCP in W5100. No functions are there.
In addition please note, that I write everything from scratch - I can not use C or PIC assembler, because I write for another platform and in different assembler, that’s why I need theory in addition to examples. And I can not derive theory of operation from examples I downloaded from the WIZnet site.

NOP

NOP

Thank you for your BASIC sources. As you an author of them you should have an answer to my questions, and let me ask differently.
In file W5100-RX, why function RecvFrom is having

[code] WriteReg(sock, rSx_CR, CR_RECV)

    While(ReadReg(sock, rSx_CR) = 1 )
    End While[/code]

at the end?

NOP

Thank you. When you write this command 0x40 first time during DHCP process?
Why you think it will be equal to 1 for some time after you write 0x40?

NOP

Thank you! If you write RECV command to socket control register, how many packets W5100 may receive?

NOP

I asked not which packet W5100 will receive, but how many packets it may receive after you write 0x40 to command register.
Let’s imagine there’re 10 DHCP servers on the LAN. Each sends DHCPOFFER packet, in total 10 packets on LAN with conditions matching DHCPDISCOVER.
So how many packets W5100 will have in its receive buffer?

NOP

Coccoliso, instructions

WriteReg(sock, rSx_CR, CR_RECV) While(ReadReg(sock, rSx_CR) = 1 ) End While
mean that you first write 0x40 into register, and then in loop check if it is 0x01, and exit if it is not 0x01.
Tell me where did you find this 0x01.
Datasheet just says
After performing the commands, the register value will be automatically cleared to 0x00.
but says nothing in which state CR register during processing of the command.
Would it be correct for you to have instead:

WriteReg(sock, rSx_CR, CR_RECV) While(ReadReg(sock, rSx_CR) <> 0 ) End While
having [color=#FF0000]<> 0[/color] ?
In case of your condition [color=#FF0000]=1[/color] it will loop ONLY while register is equal to 0x01, but who said the register has such value?

I answer with a quote from Galileo Galilei (1564-1642) … "and yet it moves!"
Let the jokes :smiley: … When I have the HW available change the source and try
I will let you know.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.