Compensation of nonlinearity in an optical-communication link by using optical phase