Diffusion-based molecular communication is a promising bio-inspired paradigm to implement nanonetworks, i.e., the interconnection of nanomachines. The peculiarities of the physical channel in diffusion-based molecular communication require the development of novel models, architectures and protocols for this new scenario, which need to be validated by simulation. With this purpose, we present N3Sim, a simulation framework for diffusion-based molecular communication. N3Sim allows to simulate scenarios where transmitters encode the information by releasing molecules into the medium, thus varying their local concentration. N3Sim models the movement of these molecules according to Brownian dynamics, and it also takes into account their inertia and the interactions among them. Receivers decode the information by sensing the particle concentration in their neighborhood. The benefits of N3Sim are multiple: the validation of channel models for molecular communication and the evaluation of novel modulation schemes are just a few examples.