diff --git a/test/unit/ip4/test_ip4.c b/test/unit/ip4/test_ip4.c
index af715daf..59035077 100644
--- a/test/unit/ip4/test_ip4.c
+++ b/test/unit/ip4/test_ip4.c
@@ -21,17 +21,30 @@ static int linkoutput_byte_ctr;
 static u16_t linkoutput_pkt_len;
 static u8_t linkoutput_pkt[100];
 
+static FILE *linkoutput_file;
+
 /* reference internal lwip variable in netif.c */
 
 static err_t
 test_netif_linkoutput(struct netif *netif, struct pbuf *p)
 {
+  long unsigned int i;
+
   fail_unless(netif == &test_netif);
   fail_unless(p != NULL);
   linkoutput_ctr++;
   linkoutput_byte_ctr += p->tot_len;
   /* Copy start of packet into buffer */
   linkoutput_pkt_len = pbuf_copy_partial(p, linkoutput_pkt, sizeof(linkoutput_pkt), 0);
+  if (linkoutput_file != NULL) {
+    for (i = 0; i < p->tot_len; ++i) {
+      if (i % 16 == 0)
+	fprintf(linkoutput_file, "\n%06lx", i);
+      fprintf(linkoutput_file, " %02x",
+	      i < sizeof(linkoutput_pkt) ? linkoutput_pkt[i] : 0);
+    }
+    fprintf(linkoutput_file, "\n");
+  }
   return ERR_OK;
 }
 
@@ -157,6 +170,79 @@ START_TEST(test_ip4_frag)
   fail_unless(err == ERR_OK);
   fail_unless(linkoutput_ctr == 6);
   fail_unless(linkoutput_byte_ctr == (8000 + (6 * IP_HLEN)));
+
+  pbuf_free(data);
+
+  /* mtu=300, len=8000 */
+  linkoutput_ctr = 0;
+  linkoutput_byte_ctr = 0;
+  linkoutput_file = fopen("mtu300len8000.hex", "w");
+  data = pbuf_alloc(PBUF_IP, 8000, PBUF_RAM);
+  test_netif.mtu = 300;
+  err = ip4_output_if_src(data, &test_ipaddr, ip_2_ip4(&peer_ip),
+                          16, 0, IP_PROTO_UDP, &test_netif);
+  fclose(linkoutput_file);
+  linkoutput_file = NULL;
+  fail_unless(err == ERR_OK);
+  printf("MTU=%d, linkoutput_ctr=%d\n", test_netif.mtu, linkoutput_ctr);
+  printf("MTU=%d, linkoutput_byte_ctr=%d\n", test_netif.mtu, linkoutput_byte_ctr);
+  fail_unless(linkoutput_ctr == 29);
+  fail_unless(linkoutput_byte_ctr == (8000 + (29 * IP_HLEN)));
+
+  pbuf_free(data);
+
+  /* mtu=300, len=4*(((mtu-20)/8)*8)+4=1124 */
+  linkoutput_ctr = 0;
+  linkoutput_byte_ctr = 0;
+  linkoutput_file = fopen("mtu300len1124.hex", "w");
+  data = pbuf_alloc(PBUF_IP, 1124, PBUF_RAM);
+  test_netif.mtu = 300;
+  err = ip4_output_if_src(data, &test_ipaddr, ip_2_ip4(&peer_ip),
+                          16, 0, IP_PROTO_UDP, &test_netif);
+  fclose(linkoutput_file);
+  linkoutput_file = NULL;
+  fail_unless(err == ERR_OK);
+  printf("MTU=%d, linkoutput_ctr=%d\n", test_netif.mtu, linkoutput_ctr);
+  printf("MTU=%d, linkoutput_byte_ctr=%d\n", test_netif.mtu, linkoutput_byte_ctr);
+  fail_unless(linkoutput_ctr == 5);
+  fail_unless(linkoutput_byte_ctr == (1124 + (5 * IP_HLEN)));
+
+  pbuf_free(data);
+
+  /* mtu=304, len=8000 */
+  linkoutput_ctr = 0;
+  linkoutput_byte_ctr = 0;
+  linkoutput_file = fopen("mtu304len8000.hex", "w");
+  data = pbuf_alloc(PBUF_IP, 8000, PBUF_RAM);
+  test_netif.mtu = 304;
+  err = ip4_output_if_src(data, &test_ipaddr, ip_2_ip4(&peer_ip),
+                          16, 0, IP_PROTO_UDP, &test_netif);
+  fclose(linkoutput_file);
+  linkoutput_file = NULL;
+  fail_unless(err == ERR_OK);
+  printf("MTU=%d, linkoutput_ctr=%d\n", test_netif.mtu, linkoutput_ctr);
+  printf("MTU=%d, linkoutput_byte_ctr=%d\n", test_netif.mtu, linkoutput_byte_ctr);
+  fail_unless(linkoutput_ctr == 29);
+  fail_unless(linkoutput_byte_ctr == (8000 + (29 * IP_HLEN)));
+
+  pbuf_free(data);
+
+  /* mtu=304, len=4*(((mtu-20)/8)*8)+4=1124 */
+  linkoutput_ctr = 0;
+  linkoutput_byte_ctr = 0;
+  linkoutput_file = fopen("mtu304len1124.hex", "w");
+  data = pbuf_alloc(PBUF_IP, 1124, PBUF_RAM);
+  test_netif.mtu = 304;
+  err = ip4_output_if_src(data, &test_ipaddr, ip_2_ip4(&peer_ip),
+                          16, 0, IP_PROTO_UDP, &test_netif);
+  fclose(linkoutput_file);
+  linkoutput_file = NULL;
+  fail_unless(err == ERR_OK);
+  printf("MTU=%d, linkoutput_ctr=%d\n", test_netif.mtu, linkoutput_ctr);
+  printf("MTU=%d, linkoutput_byte_ctr=%d\n", test_netif.mtu, linkoutput_byte_ctr);
+  fail_unless(linkoutput_ctr == 5);
+  fail_unless(linkoutput_byte_ctr == (1124 + (5 * IP_HLEN)));
+
   pbuf_free(data);
   test_netif_remove();
 }
