about collision filtering

Hi, everyone!
I am doing a game that need to use the collision filtering. I checked the manual and it tells me that I can use the categoryBits and maskBits of a fixture to control filtering. However the manual doesn't explain them too much.
Can anyone tell me what do the categoryBits and maskBits mean? How should I use them correctly?
Thank you for any help
Suppose I have 2 types of objects: walls, and balls. I want the balls to bounce off of the walls and floors (which are just horizontal walls), but I don't want them to hit each other.

I can do the following:

for each wall, set categoryBits = 1
for each ball, set categoryBits = 2
for each ball, set maskBits = 1

maskBits here says that a ball will only collide with a floor.

Also, I believe the default categoryBits is 1, so you don't have to explicitly set it on the walls.

If you wanted to add crates that the balls should bounce off, and you wanted them to have their own category as well, then you could set their category to 4 and set ball.maskBits = 1 | 4 (i.e., 5)
hi, jj.mac! thank you.
I am not sure if i understand your meaning clearly. Do you mean the actually the maskBits controls the collision filtering? If I set maskBits = 2 for ball then the ball will only collide with ball not with wall, right?
but why the ball can collide with everything when i use the default maskBits? You know the default maskBits is 0xFFFF. what does 0xFFFF mean?

Original thread: https://box2d.org/forum/viewtopic.php?t=5607