counter loop, transmit function