#include #include #include using namespace std; class SlidingWindow { private: int window_size; int total_frames; vector sent_frames; // queue of sent frames int next_frame_to_send; // index of the next frame to send int next_frame_to_receive; // index of the next frame to receive public: SlidingWindow(int window_size, int total_frames) { this->window_size = window_size; this->total_frames = total_frames; this->next_frame_to_send = 0; this->next_frame_to_receive = 0; } // send a frame void send_frame() { if (sent_frames.size() < window_size && next_frame_to_send < total_frames) { sent_frames.push_back(next_frame_to_send); next_frame_to_send++; cout<<"Sent frame "<> window_size; cout << "Enter the total number of frames:\t"; cin >> total_frames; SlidingWindow window(window_size, total_frames); while (!window.all_frames_sent() || !window.all_frames_received()) { window.send_frame(); // simulate receiving frames for (int i=0; i