  We prove that a 2-step nilpotent Lie algebras admitting an ad-invariant
metric can be constructed from a vector space $\mathfrak v$ endowed with a
inner product $<, >$ and an injective homomorphism $\rho: \mathfrak v \to
\mathfrak{so}(\mathfrak v)$ satisfying $\rho(v)v=0$ for all $v\in \mathfrak v$.
The corresponding simply connected pseudo-Riemannian Lie groups are flat and
any isometry fixing the identity element does not depend on $\rho$. The
description allows to construct examples starting with a compact semisimple Lie
algebra and it is useful to show some applications.
