def read_ip_config(filename):
    """Read networking configuration from file.

    Format:

        [server_id] [ip] [port]

        0 172.31.40.143 50050
        1 172.31.36.140 50050
        2 172.31.47.147 50050
        3 172.31.30.180 50050

    Parameters
    ----------
    filename : str
        name of target configure file.

    Returns
    -------
    dict
        server namebook, e.g., 

          {0:'172.31.40.143:50050',
           1:'172.31.36.140:50050',
           2:'172.31.47.147:50050',
           3:'172.31.30.180:50050'}
    """
    assert len(filename) > 0, 'filename cannot be empty.'

    server_namebook = {}

    try:
        lines = [line.rstrip('\n') for line in open(filename)]
        for line in lines:
            ID, ip, port = line.split(' ')
            server_namebook[int(ID)] = ip+':'+port
    except:
        print("Incorrect format IP configure file, the data format on each line should be: [server_id] [ip] [port]")

    return server_namebook