Вопрос

Suppose an application sends a packet with TCP header to a server for a particular function, with its headers ethernet+IPv4+TCP. Is it possible to send the same packet with UDP header in which all data are the same? According to my knowledge, the receiver side will just de-multiplex the headers of the packet layer by layer so the data of the packet should be passed to the application layer of the server when the UDP header is de-multiplexed successfully. Is there any misconception?

Это было полезно?

Решение

If a server listens on a port no matter which protocol is in use, there sits some application logic on top, expecting certain data to arrive on this port.

As per your example if the server listens on two ports (A + B) it certainly expects a different kind of data on each of those two ports.

If the clinet now decides to switch ports, say send the data meant to go to port A to port B the server's application logic surely will get confused as it does not understand what it receives on port B and (if it's well designed software in the server) it will drop the connection on port B.

Such kind of scenario is completley independed of which kind of protocol is used.

It's the same as if you'd try to plug in the power cable of your pc into the network-socket but into the power-socket. Although both sockets are build into the PC you cannot simply use any socket for any kind of connection/transfer.

Другие советы

The receiver will not know which application to pass the data to, because no application is listening on the specified UDP port. The pacakge will be dropped.

Suppose an application sends a packet with TCP header to a server for a particular function, with its headers ethernet+IPv4+TCP.

I can't suppose that. Applications don't send TCP packets. Applications send data. TCP sends TCP packets.

Is it possible to send the same packet with UDP header in which all data are the same?

Yes, of course, just send it via a UDP socket instead of a TCP socket, assuming the data fits into a UDP datagram.

According to my knowledge, the receiver side will just de-multiplex the headers of the packet layer by layer so the data of the packet should be passed to the application layer of the server when the UDP header is de-multiplexed successfully.

  1. There is no 'de-multiplexing' of headers. 2. If there is a UDP application at the server receiving on the UDP port you sent the data to, what you say will occur. If not, the transmission will be dropped.

Is there any misconception?

Not really, but you're misusing standard terminology, and ascribing powers to the application that really lie elsewhere. The application has nothing to do with Ethernet or TCP or UDP or IP headers.

I also have a strong feeling you are making a mountain out of a molehill.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top