Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Go-Back-N ARQ with PHY Layer

This model shows a Go-Back-N automatic repeat request (ARQ) system. The example simulates multiple layers of the Open System Interconnection (OSI) protocol stack using one Simulink model. The Communications System Toolbox™ is used to model the physical layer (PHY) of the communications link, and SimEvents® is used to model the ARQ. You must have a SimEvents license to run this model.

Go-Back-N ARQ

In Go-Back-N, the transmitter continues to send a number of packets controlled by a sliding window. The transmit window size is N and receive window size is 1, i.e., the transmitter can transmit N packets to the receiver before requiring an acknowledgement (ACK) message.

The Go-Back-N sequence diagram below shows a basic communication network with one transmitter (Tx) and one receiver (Rx). Tx has a window with size of N=3 and Rx waits for one packet at one time, so we can say that the window size of Rx is 1. In the diagram, you can observe how the sliding window works under different situation, including packet corruption, ACK corruption and disordered packet.

Correctly ACK'ed Packets

Once the packet is ACK'ed, the base index of the window increases to the last unACK'ed packet, and more packets are sent out. For example, in the sequence diagram, when ACK 3 is confirmed, Packet 2 and 3 are ACK'ed, and the base of the window moves to Packet 4. As the window size is 3, two more packets, i.e., Packet 5 and 6 are sent out.

Packet Retransmit Due To Timeout

If the corresponding ACK is not received upon timeout, the packet is retransmitted immediately. In the sequence diagram, Tx did not receive ACK 2 before Packet 2 timeout, therefore it retransmits Packet 2.

Packets Discarded Because They Are Disordered

Due to the different end to end delays incurred by different packets, the packets may arrive at the receiver not in the original sequence. The receiver only accepts the expected packet and discards all other packets. In the figure, the receiver is expecting Packet 6, but Packet 7 arrives first. Therefore, Packet 7 is discarded.

Packets Discarded Because They Are Corrupted

The receiver examines the parity bit to determine if the received packet is corrupted. A corrupted packet is then discarded by the receiver. In the sequence diagram, Packet 2 is corrupted during the transmission, so it is dropped by the receiver.

Structure of the Example

The model includes a transmitter that creates packets and transmits them over a physical link using BPSK modulation and BCH (63,51) coding. An AWGN channel introduces noise to the transmitted signals before they arrive at the receiver. This example uses the term 'packet' for the data transmission unit on the data link layer.

For each received data packet, the receiver examines the parity check bit to see if the packet is corrupted or not. If the packet is not corrupted, the receiver sends an ACK message back to the transmitter, through the return channel. The parity check bit is based on the BCH code check, i.e., when the BCH code is not able to correct all the bit errors, the parity check bit indicates the packet is corrupted.

If the transmitter does not receive an ACK message within a specific period (timeout), it retransmits all packets that have not yet been acknowledged with an ACK. By modeling the transmission and flow of data packets, this model lets you visualize the system's behavior and analyze its performance under different SNR and propagation delay conditions.

This model's packet transmission and reception subsystems also illustrate joint usage of SimEvents and the Communications System Toolbox.

The figure below illustrates the model.

Data Link Layer Transmitter

Packet Creation

The entity generator is a component in SimEvents, which generates entities at specific intervals. In the model, the 'From Upper Layer' block is the entity generator, which creates payloads with a fixed or random inter-frame generation time, and passes the payloads to the link layer 'Transmitter' block. In the transmitter, a sequence number (SN), i.e., a unique number to identify the packet, is added to the payload as a header.

Packet Transmit to The Physical Layer

After generating the whole packet, the transmitter sends it out through the output port of transmitter block to the 'PHY Link (Data)' block.

Reception

When receiving an ACK from the 'PHY Link (ACK)' block, the transmitter checks the sequence number and the parity check bit of the ACK. If the check bit is correct, the transmitter confirms all packets with sequence number smaller than or equal to the sequence number of the ACK. Otherwise, the transmitter may retransmit the packets due to timeout caused by corrupted or lost ACKs.

Data Link Layer Receiver

Packet Reception

After receiving a packet, the 'Receiver' block checks if the received packet is the expected packet by examining the sequence number (SN). Then the receiver sends an ACK message back to the transmitter for each expected and correct packet it receives. Otherwise, the packets are discarded. Upon rejecting a packet, the receiver continues rejecting subsequent packets, until the packet that was originally rejected is correctly received.

ACK Generation

An ACK is generated if the expected packet is received correctly. The ACK contains the corresponding sequence number and parity check.

Physical Layer

This example explicitly models the physical layer and combines it with the data link layer. The PHY link subsystem employs BCH encoding techniques, BCH (63,51) for data link and BCH (4,1) for ACK link, and then applies BPSK modulation. The subsystem transmits the modulated symbols through the AWGN channel, with an SNR value you can specify. On the other end of the AWGN channel, the receiver on the PHY link applies a BPSK demodulator and BCH decoder to recover the packet.

Model Simplification

The forward and reverse channels represent the propagation delay, which is by default assumed to be longer than the transmission delay. That is, the transmitter finishes sending a complete packet before the packet arrives at the receiver. The model also simulates the situation that packets might be potentially corrupted by noise. In an end to end network, the packets may be dropped by intermediate nodes if they exceed the time to live (TTL) limit. For the purpose of simplification, this model does not simulate this situation, i.e., the packets are not dropped during transmission. While packets might be potentially corrupted by noise, they are not dropped during transmission. Also, the model implements another simplification by ensuring that the sequence number(SN) of the packet and the ACK are never corrupted.

Results and Displays

The viewer below shows the active process of Go-Back-N ARQ, in which Tx and Rx each have 100 packet buffers, shown as white blocks. During the transmission, different conditions are shown as blocks with different colors. The upper right section of the viewer contains the configuration and performance metrics such as window size, timeout, SNR, throughput etc. The lower right section of the viewer explains the meaning of differently colored blocks.

Configuration and Performance Metrics:

  • Time -Normalized simulation time.

  • Window Size -The sliding window size of the transmitter. Unit: Packets.

  • Timeout - The value indicates the normalized timeout expiration period.

  • SNR - Signal to noise ratio, in dB.

  • Total Sent - The total number of transmitted packets from the transmitter, including new transmission and retransmissions. Unit: Packets.

  • Discarded - The total number of discarded packets at the receiver, including corrupted and disordered packets. Unit: Packets.

  • Mean Round Trip Time - Round trip time (RTT) indicates the length of time it takes for a packet to be sent plus the length of time it takes for an ACK of that packet to be received. Mean RTT applies moving average algorithm to calculate RTT: EstimatedRTT=0.875*EstimatedRTT + 0.125*SampleRTT.

  • Throughput - The ratio of received packets at the receiver over the total generated packets from the transmitter.

Legend:

  • Empty buffer - The transmitter (Tx) and the receiver (Rx) each has 100 empty buffer blocks on one layout.

  • Tx buffered packets - Tx generates packets in the buffer. Each packet is shown as one yellow block.

  • Tx packets to resend - Packets will be retransmitted after timeout shown as orange blocks.

  • Tx packets waiting for an ACK - After sending packets, the Tx waits for the ACKs from the receiver. The blue block indicates the Tx waiting for an ACK.

  • Tx disordered ACKs - Due to different propagation delays, the ACKs may arrive at Tx in the wrong order. A cyan color block indicates the disordered ACK. Although the Rx does not permit disordered packets, the Tx does permit disordered ACKs. Therefore, a green block with cyan square indicates the confirmed and disordered ACK.

  • Tx confirmed ACKs - If an ACK is received and not corrupted, it is confirmed as green block at Tx.

  • Rx received packets - If the received packet is the expected packet and it is not corrupted, it is shown as green block at Rx.

  • Rx corrupted packets - If the received packet is the expected packet but it is corrupted, it is shown as a red block at Rx. When the receiver finally receives the correct packet after retransmission, it is shown as a green block with a red square in the center.

  • Rx disordered packets - Rx expects only one packet at one time. All the other received packets are considered as disordered packets, shown as pink blocks. The pink blocks are transient, as the Rx discards the disordered packets immediately after they are received, and the buffer blocks return to white. In this model, two conditions may result in disordered packets. First, due to different propagation delays in the data PHY link, some packets may transmit late but arrive earlier. Second, if the expected packet fails to pass the parity check, i.e., is corrupted, the Rx then discards the corrupted packet and continues rejecting subsequent packets, until the packet that was originally rejected is correctly received. The packets from both conditions are considered as disordered packets.

Exploring the Example

Comparison with different parameter pairs

You can compare throughput after applying different parameters. For example, you can change the payload generation rate in the Entity Generator, i.e., commgobacknwithphy/From Upper Layer. You may also change the propagation delay by changing the service time in the Entity Server block which is located in the subsystem of the PHY link at commgobacknwithphy/PHY Link (Data) and commgobacknwithphy/PHY Link (ACK). Also, you can change the size of the sliding window, timeout, and other parameters created by the initialization file.

Two types of parameters exist in the model. The first type is fixed parameter, i.e., in the simulation process the parameter remains unchanged. Most of the model parameters are fixed. The second type is a dynamic parameter, where the value of the parameter changes during run time. In this model, the interframe generation rate of the payloads from the 'From Upper Layer' block and the propagation delay from both PHY Link(ACK) and PHY Link(Data) blocks are dynamic parameters.

To change the fixed parameter values, change the values of paramGobacknwithphy struct that exists in the MATLAB base workspace after the model loads. For example, you can change the values of paramGobacknwithphy.windowSize, paramGobacknwithphy.txTimeout and paramGobacknwithphy.dataLinkSNR to determine the impact of such changes on the throughput and round trip time of the comms link.

For the dynamic type parameters, to change the payload generation rate:

  • Step 1, double click the 'From Upper Layer' block.

  • Step 2, select the 'Entity generation' tab, set the variable 'dt' to the value you need in the 'Intergeneration time action'.

For the propagation delay, if it is fixed, all the packets have the same delay and arrive at the receiver in the right order. If the propagation delay value is random during the run time, the packets may arrive at the receiver end disordered, i.e., not in the original sequence. To change the propagation delay of the PHY link:

  • Step 1, click the 'PHY Link' block and enter the subsystem by pressing 'Ctrl' + 'U'.

  • Step 2, double click the 'server' block, i.e., the circle icon with infinity symbol.

  • Step 3, select the 'Main' tab, set the variable 'dt' to the value you need in 'Service time action'.

A PHY link block currently uses a normally distributed random number as propagation delay of a packet. The mean of the random delay can be configured via paramGobacknwithphy.dataLinkMean and paramGobacknwithphy.ACKLinkMean, for the data link and ACK link respectively. Similarly, the standard deviation of the random delay can be configured via paramGobacknwithphy.dataLinkStd and paramGobacknwithphy.ACKLinkStd. Changing values of these parameters will impact throughtput. For example, reducing the value of paramGobacknwithphy.dataLinkStd results in fewer disordered packets, and therefore increases the number of correctly received packets and throughtput.

Compare with other ARQ Protocols

You can compare Go-Back-N ARQ with other network protocols, for example, selective-repeat ARQ. In order to do this, modify the receiver commgobacknwithphy/Receiver block by adding a sliding window with size more than 1.

Appendix

This example uses the following System objects and functions:

Selected Bibliography

[1] Andrew Tanenbaum. 2002. Computer Networks (4th Edition). Prentice Hall Professional Technical Reference.

[2] James F. Kurose and Keith W. Ross. 2012. Computer Networking: A Top-Down Approach (6th Edition). Pearson.

Was this topic helpful?