Survivability and performance optimization in communication networks using network coding