Industrial applications of wireless sensor networks require timeliness in exchanging messages among nodes. Although IEEE 802.15.4 provides a superframe structure for real-time communication, a real-time message-scheduling algorithm is still required to schedule a large number of real-time messages to meet their timing constraints. We propose a distance-constrained real-time offline message-scheduling algorithm which generates the standard specific parameters such as beacon order, superframe order, and guaranteed-time-slot information and allocates each periodic real-time message to superframe slots for a given message set. The proposed scheduling algorithm is evaluated and analyzed extensively through simulations. In addition, a guaranteed time service is implemented in a typical industrial sensor node platform with a well-known IEEE 802.15.4-compliant transceiver CC2420 and ATmega128L to verify the feasibility of the guaranteed time service with the schedule generated by the proposed scheduling algorithm. Through experiments, we prove that the real system runs accurately according to the schedule calculated by the proposed algorithm.