-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSRRdtSender.h
37 lines (29 loc) · 1018 Bytes
/
SRRdtSender.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef STOP_WAIT_RDT_SENDER_H
#define STOP_WAIT_RDT_SENDER_H
#include <vector>
#include <fstream>
#include "RdtSender.h"
//#include "Config.h"
//extern fstream file;
class SRRdtSender :public RdtSender
{
private:
const int WindowsSize;
const int SeqSize; //分组序号
int expectSequenceNumberSend; // 下一个发送序号
int base; //等待ACK序号
bool waitingState; // 是否处于等待Ack的状态
Packet packetWaitingAck; //已发送并等待Ack的数据包
std::vector<Packet> PacketWindows;
std::vector<int> AckWindows;
std::fstream file;
public:
bool getWaitingState();
bool send(Message &message); //发送应用层下来的Message,由NetworkServiceSimulator调用,如果发送方成功地将Message发送到网络层,返回true;如果因为发送方处于等待正确确认状态而拒绝发送Message,则返回false
void receive(Packet &ackPkt); //接受确认Ack,将被NetworkServiceSimulator调用
void timeoutHandler(int seqNum); //Timeout handler,将被NetworkServiceSimulator调用
public:
SRRdtSender();
virtual ~SRRdtSender();
};
#endif