if (node.allSensorData!=""):
                buff.append(node.allSensorData)
                node.allSensorData = ""
            #for nodeInfo in node.network:

                #recvmsg = ''
                #node.receive(nodeInfo[0], nodeInfo[1]) # collect all the info from neighboring nodes
                #if (recvmsg!=''):
                #    buff.append(recvmsg)
            
            timeBetweenLast = time.time() - lastSend
            if (timeBetweenLast > 20):
                sendMsg = ''
                for i in range(0, len(buff)):
                    sendMsg += '\t'+ buff[i]
                sendMsg=MS_Handler.Encode_Sensor_Data(sendMsg)
                node.send(BS_addr, BS_port, sendMsg)

                lastSend = time.time()
                buff = []


            duree = time.time() - timerUpdateHead
            # change cluster head
            if (duree > 40):
                print '******************************'
                print "Begin to find next clusterhead"
                node.network=[]
                node.broadcast()
                time.sleep(2)
                node.RefreshNetwork([node.addr, node.energy,node.coordinate])