This project demonstrates a model-based approach to designing and implementing the Stop-and-Wait Automatic Repeat reQuest (ARQ) protocol. Utilizing tools like Simulink Stateflow and itemis CREATE, we modeled the protocol's behavior and generated corresponding C++ code. This code was then integrated into a Qt-based chat application to simulate reliable data transmission over potentially unreliable channels.
- Modeling: Design the Stop-and-Wait ARQ protocol using state machine modeling tools.
- Code Generation: Automatically generate C++ code from the models.
- Integration: Develop a Qt-based chat application that utilizes the generated code to ensure reliable communication.
- Modeling Tools:
- Simulink Stateflow
- itemis CREATE
- Programming Languages:
- C++
- Frameworks:
- Qt (for GUI and application logic)
The repository is organized as follows:
Model-based-Design-and-Implementation-of-ARQ-Protocol/
├── Simulink/ # Simulink Stateflow models and their Qt-based chat application integration
├── itemisCREATE/ # itemis CREATE model and its Qt-based chat application integration
└── README.md # Project overview and instructions
- Simulink Stateflow: For viewing and editing the Stateflow models.
- itemis CREATE: For working with itemis CREATE models.
- Qt Framework: To build and run the chat application.
- C++ Compiler: Compatible with the Qt framework.
-
Clone the Repository:
git clone https://github.com/Aminho09/Model-based-Design-and-Implementation-of-ARQ-Protocol.git
-
Navigate to the Qt-based Chat Application:
- Change the current directory to either chat application implementations corresponding to each model designed:
cd Simulink/User1/implementation cd Simulink/User2/implementation cd itemisCREATE/implementation
-
Open the Project:
- Use Qt Creator to open the
.profile located in theimplementationdirectories.
- Use Qt Creator to open the
-
Build the Project:
- Configure the project with the appropriate kit and build the application.
-
Run the Application:
- Execute the built application to start the chat interface.
-
Launch the Application:
- Start the chat application on two separate instances or machines.
-
Establish Connection:
- Use the application's interface to connect the two instances, simulating a sender and a receiver.
-
Send Messages:
- Type and send messages from one instance; the Stop-and-Wait ARQ protocol ensures reliable delivery to the other instance.
The Stop-and-Wait ARQ protocol is a fundamental method for error control in data transmission. It operates by sending one frame at a time and waiting for an acknowledgment before sending the next frame. If an acknowledgment isn't received within a specified timeout, the frame is retransmitted. This ensures reliable communication over unreliable or noisy channels.
-
Simulink Stateflow:
-
Utilized to create a visual state machine representing the ARQ protocol's behavior.
-
Includes two concurrent states
sendandreceivedoing send and receive behaviors. -
Transitions are based on events like
send_data,send_ack,receive_packet, andTimeout. -
Functions which calculate the headers and check pakcets and acknowledgements. You can see the statechart in the picture below:
-
-
itemis CREATE:
-
Provided a modele-based approach to define the state machine.
-
Includes two concurrent states
sendandreceivedoing send and receive behaviors. -
Transitions are based on events like
send_data,send_ack,receive_packet, andTimeout. -
Functions which calculate the headers and check pakcets and acknowledgements.
-
Supported platform-independent C++ code generation, ensuring seamless integration with the Qt chat application.
-
Offered simulation and validation tools to verify correct state transitions and event handling before deployment. You can see the statechart in the picture below:
-
-
C++ Code Generation:
- Both modeling tools support automatic generation of C++ code from the defined state machines.
- This code encapsulates the logic of the ARQ protocol, handling state transitions and events.
- Note that MATLAB Simulink doesn't generate Qt C++, so the pure C++ generated code needs to wrap into Qt C++.
-
Integration with Qt:
- The generated C++ code is integrated into a Qt-based chat application.
- Qt handles the GUI and network communication, while the ARQ logic ensures message reliability.
Contributions to enhance the models or the chat application are welcome. Please fork the repository and submit a pull request with your improvements.