'Checks if a session has timed out and tries to retransmit packet if allowed.
:param session: The given session.
:return: True or False indicating if the session has failed.'

def _check_session_timeout(self, session):

    has_failed = False
    timeout = (session.timeout * (2 ** session.retries))
    if ((session.last_contact_time + timeout) < time()):
        if ((session.retries < self._max_retries) and (session.last_sent_packet['opcode'] in (OPCODE_ACK, OPCODE_DATA))):
            self._send_packet(session, session.last_sent_packet)
            session.retries += 1
        else:
            has_failed = True
    return has_failed
