AnsweredAssumed Answered

PPP on USB CDC

Question asked by biafra on Feb 12, 2019
Latest reply on Feb 21, 2019 by biafra

Hi everyone,

 

I'm working with MCUXpresso 10.2.1 and a custom build based on MK66FN180.

 

I've implemented the PPP protocol from LwIP library using a USB virtual COM: I can successfully connect with the device, setting up a TCP/IP socket and disconnect.

The problem is with a test session.

If the device sends a little packet (10/20) bytes) everything works fine, but if the packet is larger (~500 bytes) it doesn't work.

Searching for the reason of this behaviour, I changed the test: usigneg the command prompt I send the ping command with different packet sizes:

  • ping -n 1 -l 16 130.100.100.100 (16 byte ping packet size)
  • ping -n 1 -l 32 130.100.100.100 (32 byte ping packet size)

 

In the command prompt both the conditions run fine, but if I use an USB sniffer (Wireshark) I can see what is really happening:

 

This image shows the ICMP request packet of the first command: the ping packet is 16 bytes long, the application data section of the USB packet is 49 bytes long, the same length of the PPP packet.

 

This image shows the ICMP request packet of the second command: the ping packet is 32 bytes long, the application data section of the USB packet is 65 bytes long, the same length of the PPP packet.

 

Both the ping requests are embedded into a single USB packet sent from the host (the PC) to the device.

 

This image shows the ICMP reply packet of the first command: the ping packet is 16 bytes long, the application data section of the USB packet is 49 bytes long, the same length of the PPP packet.

 

This image shows the first portion of the ICMP reply packet of the second command: the ping packet is 32 bytes long, the application data section of the USB packet is 64 bytes long, a different length than the PPP packet, that is 65 bytes long. The last byte of the PPP packet is missing.

 

This image shows the final portion of the ICMP reply packet of the second command: the application data section of the USB packet is 1 byte long, the missing byte of the previous packet.

 

As you can see, if the application has to send more than 64 data bytes, thay are splitted in separate USB packets with a maximum length of 64 byte.

 

If the ping packet length is still small, the ping test seems to continue to work fine, even if there are the problems seen with Wireshark. But if the ping packet length becomes greater, using the command ping -n 1 -l 160 130.100.100.100 (160 byte ping packet size), the ping test fails.

I think this is the reason for the initial test not working.

 

I think that the limit of 64 byte come from the macro:

#define FS_CDC_VCOM_BULK_OUT_PACKET_SIZE ( 64 )

 

Can I increase this value?

How can I handle this situation?

 

Many thanks

Biafra

 

Outcomes