You gain Total XP on public servers. Once a game ends, all players that are in either NF or BE add their score to their Total XP. (up to 100 points per game)
Players that switched from NF or BE to another team (including spec) reset their score. Total XP can only go up. If your score is negative at the end of a game you will get 0 XP.