How to attach queue length in ip header of the packet using NS2?

Description

The queue length of the packet is attached in ip header of the packet and it is accessed in routing layer to find the current traffic status of the node.

C++ part :

struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);
int p_len = q_->length();
ih->qlengt_ = p_len;