Decoding Network Codes using the Sum-Product Algorithm