move code from etherlab_master.cpp