802.11 protocol code parsing in NS2.

Source: Internet
Author: User
Packet sending process:
  1. Upper-layer objects (such as data queues) Call Recv ();
  2. Recv () calls send ();
  3. Send () encapsulate the data packet by calling senddata (P) and assign P to pkttx _. Because you need to send the RTS packet before sending the data packet, send () also calls sendrts () generates an RTS packet for packet P and assigns the generated RTS packet to pktrts _. When the rollback timer expires and the channel is idle, a delay timer is also set to prevent conflicts with other nodes. The delay is usually DIFs + (0 ~ The random value between the congestion window size) * The length of each gap. If the channel is not idle, you need to start a new rollback timer;
  4. After the delay timer expires, deferhandler () is called. This function calls check_pktrts (), in this function, the time-out time for sending an RTS message is equal to the transmission latency of the sent RTS message, the one-way transmission latency, the switching latency of the receiving end to the sending status, the transmission latency of the sent CTS message, and the one-way transmission. transmission latency. Check_pktrts () calls transmit (pktrts _, timeout) and sets and starts the sending timeout timer based on this timeout value. The transmit () function also copies packets to the channels of the physical layer, and starts the interface timeout timer with the transmission duration.
  5. After the sending timeout timer expires, sendhandler () is called, and send_timer () is called. In this function, you may use retransmitrts () to re-transmit the RTS packets.
  6. If the node receives the CTS packet before the sending timeout timer expires, it indicates that the sent RTS packet is correctly received, recvcts () will delete pktrts _ and stop sending the timeout timer, and call tx_resume (). This function will send data packets stored in pkttx.

Note: According to the 802.11 protocol, you must confirm the status of both parties and the channel through RTS, CTS, and ACK before sending real data packets.

Package receiving process:
  1. Recv () is called for lower-level objects (such as wirelessphy ().
  2. Recv () assigns the incoming packet to pktrx _, sets and starts the receiving timeout timer, which is usually the transmission time (Packet Processing Time) txtime (p) of the packet ).
  3. When the receiving timeout timer expires, recvhandler () is called and recv_timer () is called ().
  4. Recv_timer () checks the package type and child type received in pktrx _ and calls the corresponding function. For example, control packets: recvrts (), recvcts (), recvack (), and data packets: recvdata (). Other types of packets are not processed in NS2.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.