If you are within a few years of your retirement, you can simply log on to the CRA My Account Website and get :
1) Your CPP Statement of Contributions - this shows your annual CPP contributions from the time that you were 18 years old
2) Estimate of CPP Benefits - this is an estimate, based on your work history, of what your CPP benefits will be at age 65.
For those that are close to retirement, the estimate will be very accurate. For those that are more than 5 years out, the estimate will include a number of assumptions which may cause the estimate to be pretty far off.
For a detailed outline of the math to come up with your CPP calculation, see here an article from Doug Runchey. He's also written another one to help you understand your statement of contributions here.
The information in this material is not intended as investment, tax, or legal advice. Please consult your advisor or tax professionals. The opinions expressed and material provided are for general information, and should not be considered a solicitation for the purchase or sale of any security.