How to mirror UDP packets

This is what I want,
LAN---- (UDP packets flow)----->Router [Mirror UDP packets & Send these packets to the same destination port/IP in order]--------> Internet
Any ideas?
Side note: I want to try if this work to reduce UDP packets loss by sending multiple packets to the destination server via it's IP or port.

From your statement it seems the router and Internet are the same. Are you trying to:

  • NAT to another IP (NAT)
  • multicast
  • have the host forward traffic it receives (config on host); or
  • just literally send the the same packets to another interface? (Routing)

I'm sure you're aware you cannot have two hosts with the same IP, so a little clarity is necessary.

Maybe you should explain the service experiencing packet loss. If this is local, it's likely a problem.

(Moved topic to Installing and Using OpenWrt)

1 Like

http://ipset.netfilter.org/iptables-extensions.man.html

The TEE target will clone a packet and redirect this clone to another machine on the local network segment. In other words, the nexthop must be the target, or you will have to configure the nexthop to forward it further if so desired.

--gateway ipaddr

Send the cloned packet to the host reachable at the given IP address. Use of 0.0.0.0 (for IPv4 packets) or :: (IPv6) is invalid.

To forward all incoming traffic on eth0 to an Network Layer logging box:

-t mangle -A PREROUTING -i eth0 -j TEE --gateway 2001:db8::1

1 Like

The service on the other end getting multiple identical packets will need to be OK with that... it's a risk.

I think you could probably mirror the packets to IFB device, similar to what is done in SQM, but in SQM it redirects them.

http://man7.org/linux/man-pages/man8/tc-mirred.8.html

1 Like

UDP is meant to be unreliable, the server should be ok with receiving duplicates, ... This seems like a bad solution from the beginning.

3 Likes

Well I just want to duplicate gaming UDP packets by one or two to send them to the same server which they are destined to.

Bad plan. Look into the root cause of your problems, ie your packet loss, and try to fix that. The receiving end of an UDP stream should be okay with not receiving all packets.

2 Likes

Ah okay. So TEE is not the right choice here.
You maybe want to take a look at:
http://man7.org/linux/man-pages/man8/tc-netem.8.html

NetEm is an enhancement of the Linux traffic control facilities that allow to add delay, packet loss, duplication and more other characteristics to packets outgoing from a selected network interface.

2 Likes

Wow that actually answers my question! :smiley: But again for my actual purpose I should figure out where the packet loss happens instead of sending duplicates. So I'll update you soon :slight_smile:

1 Like

If the packet loss happens somewhere between you and the server, on the internet, at your ISP... then the duping packets could be a good answer actually.... provided the server doesn't get the packets and get confused... like it has you shoot twice when you only shot once or you stand up and sit down twice each time you press the key or whatever.

Well whenever I play with friends who live far away sometimes game connect to their server. So when I shoot an enemy sometimes packets don't receive to the server (Ping is more than 80 to 100) So I thought let's give a shot sending duplicate packets in each frame. After all, UDP packets are stateless protocol. Server will decide which one to refuse but first of all 'packets need to be delivered' at least.

Yes, but it depends a lot on how well the server is written, it may see two "shot" packets and think "you took two shots" or something... it really depends on how knowledgeable the programmers were on networking ideas.

1 Like
  • I honestly believe you need to solve the problem; because, if there's a "bad router" along the way, you're only sending twice as many packets for it to drop (and twice as many for the server)
  • If you use [UDP] traceroute, perhaps there's a hop that's dropping packets along the way, if you know the port, even better
    • On most Linux: traceroute -U <destination> -p <port>
    • On OpenWrt: traceroute <destination> -p <port>
  • I also advice the My traceroute program mtr
    • On most Linux: mtr -u <destination> -P <port>

Sending in the same frame makes no sense, as frames are a Layer 2 concept; and if it were to solve the problem, the issue is likely local. In any case, it would be easiest to duplicate these packets on your game client.

While stateless, there are [sequence] IDs and checksums - and to some degree at the OpenWrt at least, connection tracking. You may need to tweak/disable the sum if duplicating packets. You may actually cause more CPU overhead for the devices and routers along the way. I'm almost certain that a router keeping track of sequence IDs may not send a dupe.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.