We describe a framework for the design of collective behaviors for groups of identical mobile agents. The approach is based on decentralized simultaneous estimation and control, where each agent communicates with neighbors and estimates the global performance properties of the swarm needed to make a local control decision. Challenges of the approach include designing a control law with desired convergence properties, assuming each agent has perfect global knowledge; designing an estimator that allows each agent to make correct estimates of the global properties needed to implement the controller; and possibly modifying the controller to recover desired convergence properties when using the estimates of global performance. We apply this framework to two different problems: (1) controlling the moment statistics describing the location and shape of a swarm, and (2) cooperative target localization. For the swarm formation control problem, we derive small-gain conditions which, if satisfied, guarantee that the formation statistics are driven to desired values, even in the presence of a changing network topology and the addition and deletion of robots.