September 19, 2012

Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC


Resolve IP Fragmentation, MTU, MSS, and PMTUD Issues with GRE and IPSEC


Excerpt:

Avoiding IP Fragmentation: What TCP MSS Does and How It Works

The TCP Maximum Segment Size (MSS) defines the maximum amount of data that a host is willing to accept in a single TCP/IP datagram. This TCP/IP datagram may be fragmented at the IP layer. The MSS value is sent as a TCP header option only in TCP SYN segments. Each side of a TCP connection reports its MSS value to the other side. Contrary to popular belief, the MSS value is not negotiated between hosts. The sending host is required to limit the size of data in a single TCP segment to a value less than or equal to the MSS reported by the receiving host.
Originally, MSS meant how big a buffer (greater than or equal to 65496K) was allocated on a receiving station to be able to store the TCP data contained within a single IP datagram. MSS was the maximum segment (chunk) of data that the TCP receiver was willing to accept. This TCP segment could be as large as 64K (the maximum IP datagram size) and it could be fragmented at the IP layer in order to be transmitted across the network to the receiving host. The receiving host would reassemble the IP datagram before it handed the complete TCP segment to the TCP layer.

September 18, 2012

vboxheadless does not listen on VRDE port

vboxheadless in virtualbox is really good, but it does not report error messages very well. If you see it running but does not listen on the VRDE port, there is a chance that you have the following issue:

This supposes that your host is Linux.

Your host may have loaded the linux KVM modules, which conflicts the VirtualBox.  Do a "lsmod" to see whether you have the following modules installed:


 kvm_intel
 kvm

If you do, "rmmod" them. To make it permanent, put them in /etc/modprobe.d/blacklist.conf


September 14, 2012

debug udev rules

To debug your udev rules, just run udevd as:

udevd --debug

Keep in mind that some udevd cannot detect changes in rule files so make sure you restart udevd after rule changes.

Qt embedded Linux usb keyboard auto detect

Qt in embedded Linux can detect the plug/unplug of an USB Mouse and enable it when USB mouse is plugged in. For USB keyboard, it does not support such capability.

To solve this problem, I have to resort to qt plugin. The following links will provide all the necessary material to write and deploy a plugin.

The plugin is a dynamic library that qt app looks for when it starts. In this case, the "customized qt keyboard driver" is located at qt-binary-directory/kbddrivers/libhotplugkbplugin.so. Before start the app, set the key board environment variable:


export QWS_KEYBOARD="HotPlugKb"

The plugin is based on the simplestyle plugin below structure-wise and based on the qt internal linuxInput driver function-wise.


http://doc.qt.nokia.com/4.7-snapshot/qkbddriverplugin.html
http://qt-project.org/doc/qt-5.0/deployment-plugins.html
http://doc.qt.nokia.com/4.7-snapshot/plugins-howto.html
http://doc.qt.nokia.com/4.7-snapshot/tools-styleplugin.html
http://doc.qt.nokia.com/4.7-snapshot/qt-embedded-charinput.html

Debugging Plugins

export QT_DEBUG_PLUGINS='2'

September 7, 2012

Makefile and autoconf/automake gcc version check

Makefile:

GCC_VERSION_GE_45 := $(shell g++ -dumpversion | gawk '{print $$1>=4.5?"1":"0"}')
ifeq ($(GCC_VERSION_GE_45),1)
    AM_CXXFLAGS +=-Wunreachable-code
endif

Note the use of double $ sign inside gawk script.


In Autoconf/Automake:
1. Add the following line to configure.ac
  AM_CONDITIONAL(GCC_GE_45, test `g++ -dumpversion | gawk '{print $1>=4.5?"1":"0"}'` = 1)

2. Add the following line to Makefile.am
  include $(top_srcdir)/common.mk

3. Add the following lines to common.mk
if GCC_GE_45
    AM_CXXFLAGS +=-Wunreachable-code
endif

September 6, 2012

buffer overflow example and gcc flags

If you want to try some buffer overflow examples online, make sure you compile your C code with the gcc flag:

     -mno-accumulate-outgoing-args 

otherwise your assembly code may look different than the assembly code on the book. Read more at this Stackoverflow post