This paper presents a formal modeling and simulation framework for mobile agent sys tems. A Mobile Discrete Event System Specifi cation (MDEVS) formalism is proposed to rep resent the dynamics of mobile agent systems. The MDEVS formalism supports structural changes of the systems, which include the cre ation, addition, deletion, and migration of mod els and the dynamic changes of couplings be tween models. AgentSim is a software environ ment for the simulation and execution of mobile agent systems modeled by the MDEVS formalism. AgentSim is implemented as a li brary built on IBM's Aglets. The modeling and simulation of an e-commerce mobile agent sys tem is exemplified to demonstrate the effective ness of the proposed modeling framework and the associated simulation environment.