-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterestProc.h
122 lines (91 loc) · 2.67 KB
/
InterestProc.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef __INTERESTPROC_H__
#define __INTERESTPROC_H__
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <string.h>
#include <iostream>
#include <mutex>
#include <fstream>
#include <jsoncpp/json/json.h>
#include "CS_LRU.h"
#include "FIB.h"
#include "PIT.h"
#include "UDPSocket.h"
#include "package.h"
using namespace std;
/**
* 用于处理Interest包的类
*/
class InterestProc{
private:
// Content Store 表
CSLRU* cslruInstance;
// FIB 表
FIB* fibInstance;
// PIT 表
PIT* pitInstance;
//接收Interest包的socket
UDPSocket udpInterestSocket;
/**
* 询问本级ICN节点是否有请求内容的Socket
* 这个inquireSocket是InterestProc下的私有成员,和InquireProc.cpp下的Socket不是同一个
*/
UDPSocket inquireSocket;
//绑定接收InterestSocket的接收端口
unsigned short InterestPort;
unsigned short DataPort;
//向本级别ICN节点查询的目的端口
unsigned short InquirePort;
//向本级别ICN节点查询的源端口
unsigned short InquireBindPort;
//记录客户端IP和客户端名称(比如 client1)的映射关系
unordered_map<string, int> clientName;
/**
* 设置本级查询超时时间
*/
int tv_sec;
int tv_usec;
void InitInterestProc();
vector<DataPackage> getContentStoreDataList(string name);
bool isNameExistInPIT(string name);
//insertIpAndPortByContentName
void Subscribe(string name, string IP, unsigned short port);
void UnSubscribe(string name, string IP, unsigned short port);
/**
* 查询这个Interest请求的name是不是归属于本地
*/
bool isMatchLocalNames(string name);
bool isVideoStream(string name);
/**
* 这个请求不属于本地的情况下,获得这个name应该转发的所有接口
*/
vector<string> getForwardingFaces(string name);
/**
* 当发现本级别的ICN节点存在想要的内容,则返回这个ICN节点的IP
*/
string getThisLevelIPIfContentExist(vector<string> &forwardingFaceList, InterestPackage &interestpack);
/**
* 获得应该转发到上一级的ICN节点的IP
*/
string getUpperLevelIP();
/**
* 打印调试信息
*/
void printInfo(InterestPackage interestpack);
/**
* 根据客户端源IP名称,分配显示主机名称clientName
*/
string allocateClientName(string IP);
public:
InterestProc();
~InterestProc();
/**
* 用于处理收到Interst包的函数
* 详细流程见《信息中心网络》清华大学著 108页
*/
void procInterestPackage();
};
#endif