Calculating port positions