they are from a surplus m16a1 stock http://i.imgur.com/s9mTP29.jpg
They are markings designed to aid in organization. While all rifles in military service have a serial number, they are tiny, difficult to read, and have quite a few digits. When not being used for training or deployments, weapons are almost always stored in an armory. When issuing or returning weapons, there's a need for a system that makes the weapons readily identifiable.
To make keeping track of the weapons easier armories will often employ their own system for organizing them, and that usually includes marking them in the manner of the picture you provided. There is a surprising amount of leeway in how they are marked. Sometimes colors are used to further differentiate weapons.
As for the markings on your specific rifle, it's very likely that the D stands for "Delta Company". The 17 might be a numerical designation, or it might be some other classification, dependent upon the system the armorers were using.