Skip to content

Commit 7daf9c8

Browse files
author
ditmarlange
committed
Hoplimit und so
1 parent a94e787 commit 7daf9c8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

RN4/src/router/Router.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.net.Socket;
1111
import java.net.SocketException;
1212
import java.util.ArrayList;
13+
import java.util.Arrays;
1314
import java.util.HashMap;
1415
import java.util.List;
1516
import java.util.Map;
@@ -26,11 +27,17 @@ public Router() throws IOException {
2627
while (i < 2) {
2728
System.out.println("Vor getpacket");
2829
ipp = nl.getPacket();
29-
3030
System.out.println(ipp.getDestinationAddress());
3131
System.out.println(ipp.getSourceAddress());
32-
33-
if (!routtable.containsKey(String.valueOf(ipp.getDestinationAddress()))) {
32+
ipp.setHopLimit(ipp.getHopLimit()-1);
33+
if(ipp.getHopLimit()<1){
34+
ControlPacket.Type controlType = ControlPacket.Type.valueOf("TimeExceeded");
35+
ControlPacket controlPacket = new ControlPacket(controlType, new byte[0]);
36+
ipp.setControlPayload(controlPacket.getBytes());
37+
// ipp.setDestinationAddress(ipp.getSourceAddress());
38+
// ipp.setNextHopIp(ipp.getDestinationAddress());
39+
nl.sendPacket(ipp);
40+
} else if (!routtable.containsKey(String.valueOf(ipp.getDestinationAddress()))) {
3441
System.out.println("HIER");
3542
ControlPacket.Type controlType = ControlPacket.Type.valueOf("DestinationUnreachable");
3643
ControlPacket controlPacket = new ControlPacket(controlType, new byte[0]);
@@ -46,7 +53,7 @@ public Router() throws IOException {
4653
.getByName((routtable.get(String.valueOf(ipp.getDestinationAddress()))[0]));
4754
ipp.setNextHopIp(nexthopip);
4855
System.out.println("Nexthopip: " + nexthopip + " Nextport: " + ipp.getNextHopPort());
49-
56+
System.out.println(Arrays.toString(nexthopip.getAddress()));
5057
nl.sendPacket(ipp);
5158
// IpPacket retp;
5259
// retp = nl.getPacket();

RN4/src/router/routen.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
2001:db8:2::/47;2001:db8:0:2::;5000
33
2001:db8:2::/48;2001:db8:0:3::;5000
44
/0:0:0:0:0:0:0:1;0:0:0:0:0:0:0:1;8000
5-
/fe80:0:0:0:4011:72ff:fef6:16b5;fe80:0:0:0:4011:72ff:fef6:16b5;6789
5+
/fe80:0:0:0:4011:72ff:fef6:16b5;fe80:0:0:0:4011:72ff:fef6:16b5;6789
6+
/fe80:0:0:0:850:ef1f:577d:c3e9;fe80:0:0:0:850:ef1f:577d:c3e9;6789

0 commit comments

Comments
 (0)