def calculate_bps(current_sample_octets, current_sample_time, historical_sample_octets, historical_sample_time):
    """Calculate the bits-per-second based on the octets and timeticks (hundreths of a second)."""

    # When the SNMP counter reaches 18446744073709551615, it will rollover and reset to ZERO.
    # If this happens, we want to make sure we don't output a negative bps
    if current_sample_octets < historical_sample_octets:
        # If we reset to 0, add the max value of the octets counter
        current_sample_octets += 18446744073709551615

    delta = current_sample_octets - historical_sample_octets

    # SysUpTime is in TimeTicks (Hundreds of a second), so covert to seconds
    seconds_between_samples = (current_sample_time - historical_sample_time) / 100.0

    # Multiply octets by 8 to get bits
    bps = (delta * 8) / seconds_between_samples
    bps /= 1048576          # Convert to Mbps  (use 1024 for Kbps)
    bps = round(bps, 2)
    return bps