Time varying optimal control with packet losses