cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Participant
Participant
3,561 Views
Registered: ‎04-28-2017

UDP and TCP

Hi,

 

I want to know if it is possible to send both TCP and UDP at the same time on different ports, for a Picozed 7030 FMC carrier card v2? I am currently sending out packets via udp from the board with a UDP listener on the PC, works fine. I tried to send a message via TCP from the PC and have it echoed back (as a test) at the same time on a different port, and i got the error that the board is actively refusing it.

 

Is it possible to have them both for the Picozed 7030, if so any guidance would be greatly appreciated!

 

Thank you in advance,

Mageo17

0 Kudos
7 Replies
Highlighted
Scholar
Scholar
3,545 Views
Registered: ‎03-22-2016

@mageo17

Of course you can. Both are IP packets. 

However UDP is connection-less and TCP needs a 3-way handshake to form the connection before packets are accepted.

If you are using Linux, the kernel will discard your packet if it does not match any live connection in the box.

http://www.omnisecu.com/tcpip/tcp-three-way-handshake.php

 

TCP also needs other packets to be sent along the payload for flow control. That is why we use LWIP for standalone development.

 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Highlighted
Explorer
Explorer
3,522 Views
Registered: ‎08-21-2013

Does it work if you just do TCP? Presumably, you have a TCP socket listening on that port?

 

I'm not sure what you mean by a message that it is "actively refusing it".

 

You can certainly have TCP and UDP sending packets and the ports do not have to be different. Of course, they are not sent at exactly the same time. There can only be one packet in each direction at a time, but the stack should handle interleaving them. You don't say what OS and stack you are using.

0 Kudos
Highlighted
Voyager
Voyager
3,517 Views
Registered: ‎06-24-2013

Hey @mageo17

 

As @hbucher already explained, TCP requires a connection while UDP is connection less.

If you, for example, try to connect to a TCP port where nothing is listening (e.g. with telnet), then you will get a message telling you that the connection was refused, like this:

 

$ telnet 192.168.0.1 666
Trying 192.168.0.1...
telnet: connect to address 192.168.0.1: Connection refused

But this doesn't mean that the other side is blocking you, it just means that there is nothing there listening on that port and the handshake to establish a TCP connection failed.

 

There could be other reason that a connection fails like firewalls or services actively rejecting your connection, so it would help to know your test setup and the actual error message you are getting.

 

Hope this helps,

Herbert

-------------- Yes, I do this for fun!
Highlighted
Teacher
Teacher
3,429 Views
Registered: ‎03-31-2012

@mageo17 do you have the proper TCP listening server running ? 

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Highlighted
Participant
Participant
3,396 Views
Registered: ‎04-28-2017

@corestar & @muzaffer I am able to do just the TCP, using the LWIP Echo example. Using Python on the PC end as the listening server for that port.

 

My first test consisted of pushing data from the board via UDP with a listener port in C# on the PC side, this works fine and is continuously running reading in the data. My goal is to send a command from the PC to the board via a separate TCP port or if that doesn't work on a separate UDP port.


Can you have two different protocols running on different ports on the Picozed? If so is there a user guide or tutorial/blog you could direct me to, haven't found anything on this topic yet.

 

Also if I try to use the same protocol but on different ports work instead and would it be better than using the TCP?

 

Thank you!

Mageo17

0 Kudos
Highlighted
Participant
Participant
3,390 Views
Registered: ‎04-28-2017

I found this thread in the forums, that is helpful, still working on a solution. Any pointers is greatly appreciated, thank you.

 

https://forums.xilinx.com/t5/Embedded-Development-Tools/Are-Multiple-UDP-ports-possible-in-uecho-or-echo-test-XAPP1026/td-p/16864

0 Kudos
Highlighted
Explorer
Explorer
3,369 Views
Registered: ‎08-21-2013

Well, if they both work separately but not when you put them together, the question is how are you coordinating the two? But it sounds like you are sending a TCP command from the PC to the board to tell it to send data back. Why not just read it back on the same TCP connection?

 

If that does not make sense, and you're using UDP to send the data, I assume you don't mind losing some of it?

 

Are you using multiple threads? If so, are the priorities such that both will actually run? Also, unless something has changed (and I have not kept up with it), lwip is not thread safe:

 

http://lwip.wikia.com/wiki/LwIP_and_multithreading

 

 

 

 

 

0 Kudos