Optimal threshold policy for opportunistic network coding under phase type arrivals