-
Notifications
You must be signed in to change notification settings - Fork 0
/
Port.cs
41 lines (33 loc) · 1004 Bytes
/
Port.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace KruskallRSTP {
class Port {
public MAC mac { get; private set; }
public Port destinationPort { get; private set; }
public int Time { get; private set; }
private Queue<BPDU> bpdus;
public Port(MAC mac, Port destinationPort, int time) {
this.mac = mac;
this.destinationPort = destinationPort;
if (destinationPort != null) {
this.Time = time;
} else {
this.Time = int.MaxValue;
}
bpdus = new Queue<BPDU>();
}
private void receiveBPDU(BPDU bpdu) {
bpdus.Enqueue(bpdu);
}
public void sendBPDU(BPDU bpdu) {
if (destinationPort != null) {
destinationPort.receiveBPDU(bpdu);
}
}
public BPDU getBPDU() {
return bpdus.Dequeue();
}
}
}