1

I'm working on a network stack at the moment, and I'm trying to implement IPv4 fragmentation. Whilst I have an implementation which works in theory, I would like to actually test that it works by throwing actual fragmented packets at it.

Is there any software or perhaps an easy way to write code to do this? I'd rather not go and modify MTUs on the hosts I'm testing with just to get this working. My development environment is Windows.

Matthew Iselin
  • 10,400
  • 4
  • 51
  • 62

3 Answers3

4

I think the simplest way is to use ping:

    ping -l 2000 192.168.0.1

for linux, it should be:

    ping -s 2000 192.168.0.1
cuble
  • 306
  • 2
  • 7
0

I ended up writing my own little application to send an n-sized packet. I reduced the MTU of the network segment I was testing on and the stack received and reassembled the fragmented packets.

Most of the software I found to do this required a listener on the target computer, which is implausible for the kind of testing I'm doing.

Matthew Iselin
  • 10,400
  • 4
  • 51
  • 62
0

UDP datagrams have no sequence numbers, so sending a big amount of data can result in fragmented datagrams. For example, netcat can be easily used on Linux to produce UDP fragments:

$ dd if=/dev/zero count=10  |  nc  192.168.0.1  1234

With tcpdump, we can observe the presence of the datagram id, the increasing fragment offset, and the “More fragments” flag:

# tcpdump -i eth0 -vvv udp and not port 53
00:41:35.449822 IP (tos 0x0, ttl 63, id 33788, offset 0, flags [+], proto UDP (17), length 1444)
    192.168.0.2.38920 > 192.168.0.1.1234: UDP, bad length 5120 > 1416
00:41:35.449947 IP (tos 0x0, ttl 63, id 33788, offset 1424, flags [+], proto UDP (17), length 1444)
    192.168.0.2 > 192.168.0.1: udp
00:41:35.449976 IP (tos 0x0, ttl 63, id 33788, offset 2848, flags [+], proto UDP (17), length 1444)
    192.168.0.2 > 192.168.0.1: udp
00:41:35.450000 IP (tos 0x0, ttl 63, id 33788, offset 4272, flags [none], proto UDP (17), length 876)
    192.168.0.2 > 192.168.0.1: udp

Some notes:

  • This does not require any listener on the destination node.
  • It produces different results (no fragments, it seems) if source and destination are the same machine, e.g. targetting localhost. Probably because my lo interface has a MTU of 65536.
  • TCP datagrams are not fragmented by netcat, the sequence number is used to reassemble the data chunks at the destination node.

I did not have a chance to try the Windows equivalent, but it is likely that it produces fragments as well. Given that the question was asked ten years ago anyway, the “Windows” restriction might not really matter anymore.

Qeole
  • 8,284
  • 1
  • 24
  • 52