def calc_freight_reliability(df_rel):
    """
    Calculates TTTR (Truck Travel Time Reliability), AKA freight reliability.
    Args: df_rel, a pandas dataframe.
    Returns: df_rel, a pandas dataframe with new columns 'weighted_ttr'
             tttr_index, the full freight reliability index measure of the 
             whole interstate system.   
    """
    df_int = df_rel.loc[df_rel['interstate'] == 1]
    # Total length of the interstate system
    df_int_sum = df_int['miles'].sum()
    
    # Calculated weighted tttr for trucks
    df_int['weighted_ttr'] = df_int['miles'] * df_int['tttr']  
    sum_weighted = df_int['weighted_ttr'].sum()
    tttr_index =  sum_weighted / df_int_sum
    
    return df_rel, tttr_index