def outOfOrderPacket(recv, send):
    """Calculate how many packets were received out-of-order"""
    # Number of out of order packets
    if len(recv.seq) == 0:
        return 0

    ooo = 0
    max_seq = recv.seq.iloc[0]

    for i in range(1, len(recv.seq)):
        if recv.seq.iloc[i] < max_seq:
            ooo += 1
        max_seq = max(max_seq, recv.seq.iloc[i])

    return ooo