Linux udp to tcp

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Naively change a UDP stream to TCP.

bradleyfalzon/udp-to-tcp

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

udp-to-tcp connects to a remote TCP connect, listens for UDP packets and sends them to said TCP connection.

This application is not maintained, and as used as for a single specific purpose and it’s served its purpose. It was used to assist in adding some reliability to video stream over a slightly lossy link due to intermittent congestion.

Note, many others may use netcat or similar applications to achieve this functionality.

Further investigation needed to determine exact behaviour of TCP connection, such as behaviour with Nagle’s algorithm.

In the following example, this application listens on port udp/44001, sending to some destination over tcp/44011. netcat then listens on tcp/44011 and sends to the final destination on udp/44001.

while true; do udp-to-tcp -listen :44001 -backend :44011; sleep 1; done 
nc -k -l 0.0.0.0 44011 | nc -u 44001 

Источник

Читайте также:  Kali linux no root file system is defined

Convert UDP header to TCP header

Can somebody help me how this can be done. I am using linux machines.

Though libpcap can be one of the option (from wireshark), but it is not suitable for me because of performance reasons. I want a very light weight solution for this problem.

So where exactly are you stuck? You could just open a raw socket for sending and receiving your packets. But your question doesn’t sound like you are very familiar with the differences between UDP and TCP. I’m not sure if such a «conversion» is possible at all but if it is then it will require lots of work and hacks. It would be way easier to encapsulate UDP in TCP instead.

I didn’t need these things. I want to capture the packet when it going from Ethernet Layer to IP layer.

Why would you want to do that? Perhaps you would get an answer if you could explain what it is you want to achieve. Simply changing headers is not going to work. UDP is connectionless, while TCP is connection oriented. E.G How would you even establish the TCP connection? In that case I would rather write a proxy that reads UDP packets and forwards them over an established TCP connection.

2 Answers 2

Can’t be done. TCP is a stateful, reliable, connection-oriented byte-stream protocol. UDP is a stateless, unreliable, unconnected packet protocol.

The best you can do is, on machine B, open a new socket/TCP connection to C, accept socket/UDP packets from A, and write the contents of those packets to the TCP stream. Data flowing the other direction is a bit more difficult because you have to create UDP packets to A no larger than the maximum UDP packet size supported by your systems.

Neither of those is a conversion of UDP to TCP. You can send the data over a TCP stream or you can send the packets in their entirety over a TCP stream but you can’t just change the header. SCTP is a third protocol with some capabilities of both and is sort-of case #1. Firewalls that do this are using a TCP-based VPN to fully encapsulate the UDP packets in the stream ala case #2; the other side parses and packetizes the stream, re-sending the UDP packets locally.

Читайте также:  Linux shell создать файл

Your splitting hairs. And trying to seem smart in doing so. both are conversions by the very definition of such. And further more encapsulation yes but the encapsulation is not required. I can easily write a raw listener to recv and when I determine udp I can either convert or encapsulated it to tcp or vice versa.. soooo stfu and get a better edumacation. waterloo. kangsroo. wtf

The question is very specific: Delete the UDP header and add a TCP header. That is not possible. Period. All the other things you suggest are different things. And my «education» comes from having written a complete, working, production TCP/UDP/IP stack from scratch, not from my school.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Proxy UDP traffic over a TCP stream

mullvad/udp-over-tcp

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A library (and binaries) for tunneling UDP datagrams over a TCP stream.

Some programs/protocols only work over UDP. And some networks only allow TCP. This is where udp-over-tcp comes in handy. This library comes in two parts:

  • udp2tcp — Forwards incoming UDP datagrams over a TCP stream. The return stream is translated back to datagrams and sent back out over UDP again. This part can be easily used as both a library and a binary. So it can be run standalone, but can also easily be included in other Rust programs. The UDP socket is connected to the peer address of the first incoming datagram. So one [ Udp2Tcp ] instance can handle traffic from a single peer only.
  • tcp2udp — Accepts connections over TCP and translates + forwards the incoming stream as UDP datagrams to the destination specified during setup / on the command line. Designed mostly to be a standalone executable to run on servers. But can be consumed as a Rust library as well. tcp2udp continues to accept new incoming TCP connections, and creates a new UDP socket for each. So a single tcp2udp server can be used to service many udp2tcp clients.
Читайте также:  Linux bashrc export path

The format of the data inside the TCP stream is very simple. Each datagram is preceded with a 16 bit unsigned integer in big endian byte order, specifying the length of the datagram.

Make the server listen for TCP connections that it can then forward to a local UDP service. This will listen on 10.0.0.1:5001/TCP and forward anything that comes in to 127.0.0.1:51820/UDP :

user@server $ RUST_LOG=debug tcp2udp \ --tcp-listen 10.0.0.0:5001 \ --udp-forward 127.0.0.1:51820

RUST_LOG can be used to set logging level. See documentation for env_logger for information. The crate must be built with the env_logger feature for this to be active.

REDACT_LOGS=1 can be set to redact the IPs of the peers using the service from the logs. Allows having logging turned on but without storing potentially user sensitive data to disk.

This is one way you could integrate udp2tcp into your Rust program. This will connect a TCP socket to 1.2.3.4:9000 and bind a UDP socket to a random port on the loopback interface. It will then connect the UDP socket to the socket addr of the first incoming datagram and start forwarding all traffic to (and from) the TCP socket.

let udp_listen_addr = "127.0.0.1:0".parse().unwrap(); let tcp_forward_addr = "1.2.3.4:9000".parse().unwrap(); // Create a UDP -> TCP forwarder. This will connect the TCP socket // to `tcp_forward_addr` let udp2tcp = udp_over_tcp::Udp2Tcp::new( udp_listen_addr, tcp_forward_addr, udp_over_tcp::TcpOptions::default(), ) .await?; // Read out which address the UDP actually bound to. Useful if you specified port // zero to get a random port from the OS. let local_udp_addr = udp2tcp.local_udp_addr()?; spin_up_some_udp_thing(local_udp_addr); // Run the forwarder until the TCP socket disconnects or an error happens. udp2tcp.run().await?;

About

Proxy UDP traffic over a TCP stream

Источник

Оцените статью
Adblock
detector