LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-09-2014, 04:33 PM   #1
Pluto is a Planet
LQ Newbie
 
Registered: Nov 2011
Posts: 5

Rep: Reputation: Disabled
Forwarding UDP Packets


Hi,

I've written a program in Python to act as a proxy to forward packets for a game. This involves both TCP connections and UDP messages. I had absolutely no problem with TCP, but I did run into issues with UDP.

I've used NAT with my router's Firewall and iptables on my Linux box to selectively forward packets. Here's what it looks like (IP Addresses changed)...

Router (Forwarding all TCP on port 443 to 443 on 192.168.1.99)
Router (Forwarding all UDP on port 53 to 443 on 192.168.1.99)
My Box (Forwarding UDP from IP 100.100.100.100 on port 443 to app 1 on my box or 192.168.1.99:10000)
My Box (Forwarding TCP from IP 100.100.100.100 on port 443 to app 1 on my box or 192.168.1.99:10000)
My Box (Forwarding UDP from IP 11.11.11.11 on port 443 to app 2 on my box or 192.168.1.99:11000)
My Box (Forwarding TCP from IP 11.11.11.11 on port 443 to app 2 on my box or 192.168.1.99:11000)

On my box, I see all incoming UDP packets (and can send them to/receive new packets from the server IP), but when I try to send the new packets back to my game client, it only sometimes gets through. When it doesn't work, I've used iptraf to look at my network traffic on my box (a Raspberry Pi) and I can see UDP packets received on port 443 from the external IPs, UDP packets sent to the server IP, UDP packets received from the server IP, and UDP packets sent to the game client (from port 443). On the computer running the game client, I only see the outgoing UDP packets though (using Wireshark).

I'm not really sure what's happening. On one of the game clients, it would normally work (and other times it won't work for like 10 minutes). On the other one, it doesn't ever seem to work. Do you think there's something wrong with this setup for some reason, or where should I look for problems at?

EDIT: Yeah just to double check, I ran the program in our local network with no forwarding or anything, and it works perfectly.

Last edited by Pluto is a Planet; 04-09-2014 at 10:45 PM.
 
Old 04-12-2014, 09:49 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Remember that the U in UDP = 'unreliable'; the IP layer is entitled to drop udp pkts if the n/w is getting loaded, which is why it (udp cxn) may come and go ...
 
Old 04-12-2014, 11:55 PM   #3
Pluto is a Planet
LQ Newbie
 
Registered: Nov 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Well that's not actually what the U stands for but I guess I wasn't very clear in my post as to precisely what the problem is xD

What I'm saying is that I'm able to receive every packet from the client, send every packet to the server, receive every packet back, and every packet I send to the client isn't making it. As in there's a 0% success rate going in 1 of four directions. A total of 3 packets are sent, and the 4th never works.

...except for the first person I set this up for. It turns out the issue they were having was a software issue that I resolved, and now it always works for them. Even if they haven't been online for hours, I can't set this up for another person. I'm even trying to connect to this with our external IP and all the forwarding rules set up, and the same problem exists.
 
Old 04-14-2014, 06:09 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Tricky... you'll have to investigate the differences between the setups.

I don't know anything about games systems, but some of the guys do, so post much info as possible for them to help.


(Actually, I do know the the 'U' doesn't actually stand for that but the practical effect is as if it were eg https://en.wikipedia.org/wiki/User_D...trol_solutions )
 
Old 04-16-2014, 01:34 PM   #5
Pluto is a Planet
LQ Newbie
 
Registered: Nov 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Tricky... you'll have to investigate the differences between the setups.
Yeah which is why I posted here, because there practically is none >.< I think I'm going to adjust my application to have one thread to listen to all UDP packets with one socket and send them to the appropriate thread to make everything happen on the same application. Each thread will then be responsible for using their own socket to forward and receive the data from the server, and using that one socket to send data back to the client.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with intercepting and forwarding UDP packets knonaka Linux - Networking 4 04-26-2010 03:06 PM
Forwarding UDP Packets tzahi Linux - Networking 1 03-12-2006 02:02 PM
UDP: Short Packets: and UDP bad checksum: entries in dmesg minutes2memories Linux - Networking 2 02-26-2006 07:28 PM
encapsulating TCP packets in UDP packets... yoshi95 Programming 3 06-03-2004 02:53 PM
How to receive UDP and ICMP packets, by one UDP socket(PMTUD) myself_rajat Linux - Networking 0 05-28-2004 05:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration