-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouter.java
More file actions
74 lines (70 loc) · 2.3 KB
/
Router.java
File metadata and controls
74 lines (70 loc) · 2.3 KB
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
package entity;
import java.util.HashMap;
/*路由器实体类,包含routerId,port,RouterTable*/
public class Router {
/*产生全局唯一的序列化的实体ID*/
private static final long serialVersionUID = -4112736218089137504L;
/*路由 ID*/
private int routerId;
/*路由端口*/
private int port;
/*路由表*/
private RouterTable RouterTable;
/*存储计时器的Map*/
private HashMap<Integer,TimeCounter> createTimerMapsForNeighbers=new HashMap<Integer,TimeCounter>();
/*存储上一次该路由器收到某个路由器的路由表时间*/
private HashMap<Integer,Long> lastTimeMaps=new HashMap<Integer,Long>();
/*默认的构造方法*/
public Router() {
super();
}
/*有参数routerId和port的构造方法*/
public Router(int routerId, int port) {
super();
this.routerId = routerId;
this.port = port;
}
/*有参数 routerId 和 port 和 routerTable的构造方法*/
public Router(int routerId, int port, RouterTable routerTable) {
super();
this.routerId = routerId;
this.port = port;
RouterTable = routerTable;
}
/*getters 和 setters方法*/
public int getRouterId() {
return routerId;
}
public void setRouterId(int routerId) {
this.routerId = routerId;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public RouterTable getRouterTable() {
return RouterTable;
}
public void setRouterTable(RouterTable routerTable) {
RouterTable = routerTable;
}
public HashMap<Integer, TimeCounter> getCreateTimerMapsForNeighbers() {
return createTimerMapsForNeighbers;
}
public void setCreateTimerMapsForNeighbers(HashMap<Integer, TimeCounter> createTimerMapsForNeighbers) {
this.createTimerMapsForNeighbers = createTimerMapsForNeighbers;
}
public HashMap<Integer, Long> getLastTimeMaps() {
return lastTimeMaps;
}
public void setLastTimeMaps(HashMap<Integer, Long> lastTimeMaps) {
this.lastTimeMaps = lastTimeMaps;
}
/*tostring 方法*/
@Override
public String toString() {
return "Router [routerId=" + routerId + ", port=" + port + ", RouterTable=" + RouterTable + "]";
}
}