The gelling process of particle suspension in a capillary which is crucial for in-situ preparing small size foam products has been simulated with an off-lattice diffusion limited cluster aggregation (DLCA) model by the three-dimensional Monte Carlo simulations. The effects of the model parameters, such as the interaction between capillary wall and particles, particle volume fraction, capillary size etc. on the density distribution of the system have been fully explored. And the aggregation kinetics process over a broad range of volume fractions and interactions have also been discussed. The results show that the geometric constraint of capillary can be analogous to a weak repulsive interaction between capillary wall and particles. And we found that as the capillary size or particle volume fraction increase, particle concentration distribution will be more uniform with other parameters constant. Porous network with relatively uniform density distribution can be also obtained through controlling the interaction between capillary wall and particles. In addition, by analyzing the aggregation kinetics process, we found that the attraction of capillary wall dramatically reduces the probability of gelation in the small-scale capillary. The obtained results will be of great importance in controlling the density distribution of porous materials prepared by in-situ methods.