LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 07-22-2008, 08:21 AM   #1
bricedebrignaisplage
Member
 
Registered: Apr 2006
Location: singapore
Distribution: debian
Posts: 51

Rep: Reputation: 16
UDP client / server program in c++ suddenly limited to 1468 bytes


My application is sending data over an UDP connection on a LAN to another computer that read that data and display it. It's been working for a long time, even with large messages (up to 15,000 bytes or so). But suddenly it doesn't work for messages larger than 1,468, i.e. 32 bytes smaller than the MTU. What happens is that the client doesn't receive any message at all, not even incomplete ones.

The strange thing is that it's not symmetric: if I invert the client and the server, then messages with more than 1468 bytes are sent over. I use a network sniffer on one side (wireshark) and I can see the fragmented packet.

Unfortunately, I can't use wireshark on the other side because I don't have a graphic interface there. So I use tcpdump. I can see that 1469 long packets are sent, but on the other end I can't see them arriving.

I tried with a direct connection (without passing through the router) and I obtain the same behavior...

Anybody? Any hint would be appreciated



PS:
1) I am using Ubuntu 6.06 and Ubuntu 8.04. 6.06 is the one that doesn't want to send messages larger than 1468 bytes.

2) The only recent change I made is to add a gateway address in /etc/network/interfaces so that the computers with static IP (as opposed to DHCP) can access the internet. I undid this but the problem persists. I also played around a little with the route table in order to get internet access: I typed "route add default gw 172.16.0.50 eth0" once, then found out about adding a gateway line in /etc/network/interfaces and never typed it again. I don't think it's permanent, is it?
 
Old 07-22-2008, 09:47 PM   #2
exkor5000
Member
 
Registered: Nov 2003
Distribution: Slackware
Posts: 51

Rep: Reputation: 16
Hi

Can you connect them with a patched cable and give the following output from both boxes:
Code:
ifconfig -a
Code:
mii-tool -v
Best
 
Old 07-23-2008, 04:29 AM   #3
bricedebrignaisplage
Member
 
Registered: Apr 2006
Location: singapore
Distribution: debian
Posts: 51

Original Poster
Rep: Reputation: 16
let's make things clearer:
  • I am on a small LAN, behind a linksys router, but I am having the same problem when using a cross cable.
  • Computer A (static IP 172.16.0.1) normally acts a the server. Ubuntu 6.06. It sends UDP packets of various length (possibly several tens of thousands bytes) to all clients connected.
  • Computer B (DHCP obtained IP 172.16.0.6) normally is a client. Ubuntu 8.04. It receives data and displays them. This one cannot receive messages with length larger that 1468 bytes, which is 32 bytes smaller than the MTU (1500). Things were working well as of last week.
  • Computer C is also a client. Ubuntu 7.10. It receives all messages properly.

I discovered that the problem is only with computer B. Did I upgrade a package that messed up the networking? Did I mess up some configuration file???

exkor5000:
on computer A (the server):
Code:
# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:20:9D:11:88:97
          inet addr:172.16.0.1  Bcast:172.16.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:209 errors:0 dropped:0 overruns:0 frame:0
          TX packets:146 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:27377 (26.7 KiB)  TX bytes:20989 (20.4 KiB)
          Base address:0xd000 Memory:ec000000-ec020000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
Code:
# mii-tool -v
eth0: negotiated 100baseTx-FD flow-control, link ok
  product info: vendor 00:aa:00, model 56 rev 0
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
on computer B:
Code:
$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:1a:a0:ba:f4:82
          inet addr:172.16.0.6  Bcast:172.16.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:a0ff:feba:f482/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1492  Metric:1
          RX packets:567 errors:0 dropped:0 overruns:0 frame:0
          TX packets:539 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:228657 (223.2 KB)  TX bytes:94508 (92.2 KB)
          Interrupt:16

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:724 (724.0 B)  TX bytes:724 (724.0 B)
Code:
$ sudo mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 00:50:ef, model 14 rev 0
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
  link partner: 1000baseT-HD 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
 
Old 07-23-2008, 09:08 AM   #4
exkor5000
Member
 
Registered: Nov 2003
Distribution: Slackware
Posts: 51

Rep: Reputation: 16
Hi

first thing to note is that both boxes are on different subnets:
Code:
eth0      Link encap:Ethernet  HWaddr 00:20:9D:11:88:97
          inet addr:172.16.0.1  Bcast:172.16.255.255  Mask:255.255.0.0

eth0      Link encap:Ethernet  HWaddr 00:1a:a0:ba:f4:82
          inet addr:172.16.0.6  Bcast:172.16.0.255  Mask:255.255.255.0
So I hope you and your router know about this.
As a general note I would avoid routing between two subnets like 172.16.0.0/24 and 172.16.0.0/16 because they have the same prefix and it's an awful habbit. Change one of the subnets to 172.17.0.0 or put both in one subnet.

The actual MTU computer B can handle is 1492:
Code:
eth0      Link encap:Ethernet  HWaddr 00:1a:a0:ba:f4:82
          inet addr:172.16.0.6  Bcast:172.16.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:a0ff:feba:f482/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1492  Metric:1
But even if your messages go above the MTU they will be just fragmented to smaller pieces. It's done on Layer 3 so it is below TCP or UDP.

I wonder why your loopback interface is being used to send/recieve packets.

Get rid of IPv6 (if you don't use it) on Computer B.
Avoid using the router until you find the problem, use a cross-over and monitor on Computer A if UDP packets arrive.
Try sending the same UDP data from Computer B to Computer B, see if it gets there (by using tcpdump or wireshark) via IPv4 only.

Can you post output from both commands when the two boxes are connected with a cross-over.

And also:
Code:
dmesg | grep eth

Best

Last edited by exkor5000; 07-23-2008 at 09:14 AM.
 
Old 07-24-2008, 04:12 AM   #5
bricedebrignaisplage
Member
 
Registered: Apr 2006
Location: singapore
Distribution: debian
Posts: 51

Original Poster
Rep: Reputation: 16
OK I made some more discoveries:
  • If I test between 2 computers that get their IP through DHCP from the router everything's ok.
  • If I test between 2 computers connected to the router, but with static IP, everything's ok. Same if they are connected directly, or through a switch. So I guess the router acts as a switch in that case.
  • The problem occurs if I am testing between one computer that got its IP though DHCP and another that uses a static IP. Even if I directly connect them subsequently.

In the router settings I assigned static IPs to the 3 computers that require a static IP. Et voila! Now everything works fine.

I don't understand everything though: How come I could connect to those computer via ssh (and fish) but have problem with UDP ???

The most important is that everything works now.
Thank you very much exkor5000 for your help.
 
Old 07-25-2008, 12:13 AM   #6
bricedebrignaisplage
Member
 
Registered: Apr 2006
Location: singapore
Distribution: debian
Posts: 51

Original Poster
Rep: Reputation: 16
I still need your help, it seems that it's not completely solved after all...

My LAN topology can be seen here: http://guppy.mpe.nus.edu.sg/~rebsame...workConfig.png

The 3 computers on the robot need a static IP so that they can communicate together when the robot is not attached to that LAN.
For the development computers it's convenient if they receive their IP through DHCP...

So for the 3 on the robot I configured their /etc/network/interface to get a static IP 172.16.0.[1,2,3] and netmask 255.255.255.0
The router is configured as a DHCP server, it assigns IP 172.16.0.[1,2,3] to the 3 computers on the robot based on their MAC address (there is a table for that in the router config page). The development computers just get an IP via normal DHCP.

All of those computers can communicate together using SSH, we can access files remotely with FISH, and access the internet. All fine!

BUT!!!
The weird part is that large data packets sent through UDP are lost. Small packet (<= 1468 bytes to be precise) get through. However, if the robot is configured with DHCP they no longer get lost. (it's part of our application: the robot sends data to external computer for graphical display)

So how can I fix that? Here are some of my ideas, but I don't know how to implement them:
  • Configure the router properly to allow static IP and DHCP assigned IP to coexist. I am using a Linksys WRT54GC.
  • Configure the robot's computers to try to get a DHCP address and if it fails, fall back to a static IP.
  • Create an IP alias eth0:1 that would get its IP through DHCP, while eth0 would have a static IP.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
client/server echo program of UDP sockets memisbah Programming 2 04-08-2008 10:27 AM
simple udp server client programm in not working between two systems gssmsc Programming 4 02-26-2008 10:56 AM
openvpn client certificate is 0 bytes Sleen Linux - Networking 6 10-24-2006 05:03 AM
how to get client ip address at udp server cranium2004 Programming 2 03-21-2005 11:35 PM
Server Client program using UDP frostmagic Programming 9 11-14-2003 11:06 PM


All times are GMT -5. The time now is 07:10 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration