Split a packet into different links to transmit as 6lowpan packets.
        Usage example:
          >>> ipv6 = ..... (very big packet)
          >>> pkts = sixlowpan_fragment(ipv6, datagram_tag=0x17)
          >>> send = [Dot15d4()/Dot15d4Data()/x for x in pkts]
          >>> wireshark(send)

def sixlowpan_fragment(packet, datagram_tag=1):
    """Split a packet into different links to transmit as 6lowpan packets.
        Usage example:
          >>> ipv6 = ..... (very big packet)
          >>> pkts = sixlowpan_fragment(ipv6, datagram_tag=0x17)
          >>> send = [Dot15d4()/Dot15d4Data()/x for x in pkts]
          >>> wireshark(send)
    """
    if not packet.haslayer(IPv6):
        raise Exception("SixLoWPAN only fragments IPv6 packets !")

    str_packet = raw(packet[IPv6])

    if len(str_packet) <= MAX_SIZE:
        return [packet]

    def chunks(l, n):
        return [l[i:i + n] for i in range(0, len(l), n)]

    new_packet = chunks(str_packet, MAX_SIZE)

    new_packet[0] = LoWPANFragmentationFirst(datagramTag=datagram_tag, datagramSize=len(str_packet)) / new_packet[0]  # noqa: E501
    i = 1
    while i < len(new_packet):
        new_packet[i] = LoWPANFragmentationSubsequent(datagramTag=datagram_tag, datagramSize=len(str_packet), datagramOffset=MAX_SIZE // 8 * i) / new_packet[i]  # noqa: E501
        i += 1

    return new_packet