user409: Messages on the Bitcoin network are identified by the magic value 0xD9B4BEF9, and on the testnet by 0xDAB5BFFA. Why were these values chosen?

user22965: It was chosen because it is a prime number, and also because 4190024921 is the hypotenuse of a primitive Pythagorean triple:
4190024921^2 = 2924728880^2 + 3000378279^2
Edit: Note that you must consider byte order. The TCP protocol requires the number to be encoded in big-endian. 0xf9beb4d9 (little) = 0xd9b4bef9 (big)
See https://stackoverflow.com/a/13514942 for more info about that.

user280: main.cpp carries this comment:
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ascii, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };


409: <p>Messages on the Bitcoin network are identified by the magic value 0xD9B4BEF9, and on the testnet by 0xDAB5BFFA. Why were these values chosen?</p>
 22965: <p>It was chosen because it is a prime number, and also because 4190024921 is the hypotenuse of a primitive Pythagorean triple:
4190024921^2 = 2924728880^2 + 3000378279^2</p>

<p>Edit: Note that you must consider byte order. The TCP protocol requires the number to be encoded in big-endian. 0xf9beb4d9 (little) = 0xd9b4bef9 (big)</p>

<p>See <a href="https://stackoverflow.com/a/13514942">https://stackoverflow.com/a/13514942</a> for more info about that.</p>
 280: <p>main.cpp carries this comment:</p>

<pre><code>// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ascii, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };
</code></pre>
