def METHOD_NAME(pkt):
    """ called when scapy receives a packet, since this function takes only one argument,
    schc_machine and scheduler must be specified as a global variable.
    """
    scheduler.run(session=schc_machine)
    # look for a tunneled SCHC pkt
    if pkt.getlayer(Ether) != None: #HE tunnel do not have Ethernet
        e_type = pkt.getlayer(Ether).type
        if e_type == 0x0800:
            ip_proto = pkt.getlayer(IP).proto
            if ip_proto == 17:
                udp_dport = pkt.getlayer(UDP).dport
                if udp_dport == socket_port: # tunnel SCHC msg to be decompressed
                    print ("tunneled SCHC msg")                    
                    schc_pkt, addr = tunnel.recvfrom(2000)
                    schc_bbuf = BitBuffer(schc_pkt)
                    rule = rm.FindRuleFromSCHCpacket(schc=schc_bbuf, device=device_id)
                    if rule[T_RULEID] == 6 and rule[T_RULEIDLENGTH]== 3:
                        print ("ping")
                        tunnel.sendto(schc_pkt, addr)
                    else:
                        # None when the reassambly + decompressing process is not finished and [device_id, decompressed packet in bytes] when All-1
                        print("core address", addr)
                        core_id = 'udp:'+ str(addr[0]) +":"+str(addr[1])
                        r = schc_machine.schc_recv(core_id=core_id, device_id=device_id, schc_packet=schc_pkt) 
                        if r is not None: #The SCHC machine has reassembled and decompressed the packet
                           dprint ("ping_device.py, r =", r)
                           schc_pkt_decompressed = r[1]
                           pkt_reply, core_id = create_echoreply(schc_pkt_decompressed, addr)                     
                           uncomp_pkt = schc_machine.schc_send(bytes(pkt_reply), core_id=core_id)
                           dprint(uncomp_pkt)
            elif ip_proto==41:
                schc_machine.schc_send(bytes(pkt)[34:], device_id=device_id)
                pkt.show2()