How does Catapult actually determine a unique network?

Does Catapult use a unique identifier for a network or is there some other unique manner of identifying a network?

As far as I can tell NetworkIdentifier is used to do this.

namespace {
	const std::array<std::pair<const char*, NetworkIdentifier>, 4> String_To_Network_Identifier_Pairs{{
		{ "mijin", NetworkIdentifier::Mijin },
		{ "mijin-test", NetworkIdentifier::Mijin_Test },
		{ "public", NetworkIdentifier::Public },
		{ "public-test", NetworkIdentifier::Public_Test }
	}};
}

Which seems to map to this:

#define NETWORK_IDENTIFIER_LIST \
/* A default (zero) identifier that does not identify any known network. */ \
ENUM_VALUE(Zero, 0) \
\
/* Mijin network identifier. */ \
ENUM_VALUE(Mijin, 0x60) \
\
/* Mijin test network identifier. */ \
ENUM_VALUE(Mijin_Test, 0x90) \
\
/* Public main network identifier. */ \
ENUM_VALUE(Public, 0x68) \
\
/* Public test network identifier. */ \
ENUM_VALUE(Public_Test, 0x98)

But I feel like this is not right. On Tendermint for instance, it generates a unique network hash, then you set at least one root peer - then all new nodes can find each other using that hash and listed peer(s).

Also I’m aware that there is a generationHash but it seems to be dependent on that NetworkIdentifier - if this is used, can we guarantee the unique network using network ID mijin-test?

/// Creates a network info around a network \a identifier, a nemesis public key (\a publicKey)
	/// and a nemesis generation hash (\a generationHash).
	constexpr NetworkInfo(NetworkIdentifier identifier, const Key& publicKey, const Hash256& generationHash)
			: Identifier(identifier)
			, PublicKey(publicKey)
			, GenerationHash(generationHash)
	{}

What is the process for Catapult?

As you can see in NEM’s first version, the network identifier is also used in the address generation process :

For Mijin Test, it is the network ID 90 which will result in S (hex ‘90’) starting addresses. Unsure if this answers your question.

So perhaps the prefix is used in the peer discovery then.

So I can probably safely conclude that when people want to launch their own networks they should change the string identifier and the prefix, compile the code, then deploy.

correct, when you call /node/extended-info you can see the networkId in there.

I am unsure if it is really so important to change the networkId. When you are running your own network, you also provide with a peers list (or at least the tip of it, as you mentioned) and those peers would simply be configured with your networkId.

Network Name doesn’t matter the slightest I think, but the identifier yes. If you wish a more custom experience (addresses starting with X,… whatever) you would always change the identifier in the software yep.