Remove all the items under your sink. Slip on a pair of rubber gloves and safety goggles to protect yourself from the potentially dangerous chemicals and bacteria lurking inside the existing trap.
Slide a bucket under the existing trap and loosen the compression nut holding the P-trap to the sink drain pipe with a pipe wrench. Loosen the compression nut that is holding the trap to the drain pipe that leads to the wall.
Pull the existing P-trap out and wipe down either end of the pipe with an old rag. Wrap a piece of string around the pipe only once. Remove the string and measure its length with a measuring tape. This is the number to take when purchasing a replacement pipe.