The P/G are used to generate keys. They can either be
A: Transmitted as part of the exchange or
B: Hard coded inside the client and server
Once the Client and server have the same P/G the secret key can be transmitted by generating a shared key which takes into account the P/G and secret key. Reversing the math used to generate the shared key allows the second computer to have the same secret key as the sender.