To measure RTT You may refer to this research paper
.
The implementation is here for the above paper. Though I could find another paper, but i think this one would not give quite an accurate result. (Clock synchronization problems). Anyways You can have a look for motivation.