-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPacket.java
More file actions
70 lines (53 loc) · 1.66 KB
/
Packet.java
File metadata and controls
70 lines (53 loc) · 1.66 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
// Jodi Hieronymus - CPE 400 Final Project - Fall 2022
// Class representing the packet to be sent.
import java.util.List;
import java.util.ArrayList;
public class Packet {
char routeMethod; // D = Dijkstras
// Link Layer
int sourceMAC; // Gives ID of router in graph/list
int destinationMAC;
List<Integer> pathSoFar = new ArrayList<Integer>(); // Would actually be IPs in network layer
// Network Layer
IPv4Address sourceAddress;
IPv4Address destinationAddress;
// Application Layer
String applicationData;
public Packet(int sourceMAC, int destinationMAC, IPv4Address sourceAddress, IPv4Address destinationAddress, String applicationData) {
this.sourceMAC = sourceMAC;
this.destinationMAC = destinationMAC;
this.sourceAddress = sourceAddress;
this.destinationAddress = destinationAddress;
this.applicationData = applicationData;
}
public void setDijkstras() {
this.routeMethod = 'D';
}
public void setNaive() {
this.routeMethod = 'N';
}
public int getSourceMAC() {
return sourceMAC;
}
public int getDestinationMAC() {
return destinationMAC;
}
public IPv4Address getDestinationAddress() {
return destinationAddress;
}
public IPv4Address getSourceAddress() {
return sourceAddress;
}
public String getApplicationData() {
return applicationData;
}
public char getRouteMethod () {
return routeMethod;
}
public void addAddressToPath (int MACAddress) {
pathSoFar.add(MACAddress);
}
public List<Integer> getPathSoFar () {
return pathSoFar;
}
}