setting the other end's TCP segment size

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Jul 30 04:50:30 UTC 2008


On Wed, 30 Jul 2008 07:36:34 +0300, Giorgos Keramidas <keramida at FreeBSD.org> wrote:
> On Tue, 29 Jul 2008 21:04:53 -0700, perryh at pluto.rain.com wrote:
>>> [TCP] splits traffic to 'segments' using its own logic ...
>>
>> Is there a simple way for a FreeBSD system to cause its peer
>> to use a transmit segment size of, say, 640 bytes -- so that
>> the peer will never try to send a packet larger than that?
>>
>> I'm trying to get around a network packet-size problem.  In
>> case it matters, the other end is SunOS 4.1.1 on a sun3, and
>> I've been unable to find a way to limit its packet size
>> directly.
>
> Setting the interface MTU should do it, i.e.:
>
>     ifconfig re0 mtu 640
>
> Not all interfaces support setting the MTU and some may have
> range restrictions though.

In particular, this seems to work with my wlan0 interface, but not with
my re0 interface.  The wlan0 interface correctly limits the maximum TCP
segment size to 500 bytes when I set the MTU:

# ifconfig wlan0 | fgrep mtu
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
# ifconfig wlan0 down; ifconfig wlan0 mtu 50 up

Then a tcpdump to save SSH traffic to a particular host, and a dump of
the resulting pcap shows:

# tcpdump -s 2000 -l -vvv -w save.pcap 'host a.b.c.d port 22'
Got 42^C
# echo ` tcpdump -n -l -vvv -r save.pcap 2>/dev/null | \
         sed -e 's/.* length //' -e 's/).*//' ` | fmt
60 60 52 91 52 91 500 500 340 356 52 52 76 204 196 500 260 52 68
52 100 100 116 116 500 132 52 500 84 52 500 196 52 84 116 100 164
436 52 100 132 52

This should work for *both* sides of the connection because of the
initial maximum segment size negotiation between the two TCP hosts.
See for example the two first packets of the capture I mentioned above,
and look for the 'mss' option:

07:38:19.554338 IP (tos 0x0, ttl 64, id 44805, offset 0, flags [DF],
  proto TCP (6), length 60) 192.168.1.???.53468 > X.Y.Z.W.22:
  S, cksum 0x20d6 (correct), 4195632487:4195632487(0) win 65535
  <mss 460,nop,wscale 3,sackOK,timestamp 62534308 0>
07:38:19.591065 IP (tos 0x0, ttl 54, id 39804, offset 0, flags [DF],
  proto TCP (6), length 60) X.Y.Z.W.22 > 192.168.1.???.53468:
  S, cksum 0x7f2f (correct), 901580944:901580944(0) ack 4195632488 win 65535
  <mss 460,nop,wscale 3,sackOK,timestamp 3188303166 62534308>

The MSS advertised is less than 500 to leave some space for the IP and
TCP headers, but the full IP datagram _length_ that I displayed in the
fmt(1) output above shows that the full MTU is used some times for the
IP datagrams sent or received.



More information about the freebsd-questions mailing list