I need code to simulate attacking the system by recovering the secret key from the data sent in the clear. And an explain that attack would not work in a real Diffie-Hellman implementation
You can use SimPy to build the scenario you need (endpoints, intermediate elements, and attackers) and simulate the message exchanges to analyze and extract whatever you need.
I do not think there is any library/component that provides a plain DH for SimPy but coding one for yourself is very easy.