Program: 5637
Project: 5637
Buggy source:
public void receivePacket(IPv6Packet packet){
  if (DEBUG) {
    System.out.println("String_Node_Str");
    packet.printPacket(System.out);
  }
  if (isForMe(packet.getDestinationAddress())) {
    if (DEBUG)     System.out.println("String_Node_Str" + packet.getDispatch());
switch (packet.nextHeader) {
case ICMP6Packet.DISPATCH:
      icmp6Handler.handlePacket(packet);
    if (networkEventListener != null) {
      networkEventListener.packetHandled(packet);
    }
  break;
case UDPPacket.DISPATCH:
if (packet.getIPPayload() != null) {
  packet.getIPPayload().printPacket(System.out);
  udpHandler.handlePacket(packet,(UDPPacket)packet.getIPPayload());
}
 else {
  UDPPacket p=new UDPPacket();
  p.parsePacketData(packet);
  p.printPacket(System.out);
  packet.setIPPayload(p);
  udpHandler.handlePacket(packet,p);
}
if (networkEventListener != null) {
networkEventListener.packetHandled(packet);
}
break;
case TCPPacket.DISPATCH:
TCPPacket p=new TCPPacket();
p.parsePacketData(packet);
p.printPacket(System.out);
packet.setIPPayload(p);
tcpHandler.handlePacket(packet);
if (networkEventListener != null) {
networkEventListener.packetHandled(packet);
}
break;
}
}
 else if (!isOnLink(packet.getDestinationAddress()) && packet.netInterface != tunnel) {
System.out.println("String_Node_Str" + tunnel);
if (packet.ipPayload == null) {
packet.setIPPayload(new BytePayload(packet));
}
System.out.print("String_Node_Str");
IPv6Packet.printAddress(System.out,myIPAddress);
System.out.print("String_Node_Str");
IPv6Packet.printAddress(System.out,packet.getDestinationAddress());
if (tunnel != null && tunnel.isReady()) {
tunnel.sendPacket(packet);
}
}
 else if (packet.netInterface != linkLayerHandler) {
System.out.println("String_Node_Str" + packet.getDestinationAddress() + "String_Node_Str");
if (packet.ipPayload == null) {
packet.setIPPayload(new BytePayload(packet));
if (findRoute(packet)) {
linkLayerHandler.sendPacket(packet);
}
}
}
 else {
System.out.println("String_Node_Str");
}
}

Fixed version (ground truth):
public void receivePacket(IPv6Packet packet){
  if (DEBUG) {
    System.out.println("String_Node_Str");
    packet.printPacket(System.out);
  }
  if (isForMe(packet.getDestinationAddress())) {
    if (DEBUG)     System.out.println("String_Node_Str" + packet.getDispatch());
switch (packet.nextHeader) {
case ICMP6Packet.DISPATCH:
      icmp6Handler.handlePacket(packet);
    if (networkEventListener != null) {
      networkEventListener.packetHandled(packet);
    }
  break;
case UDPPacket.DISPATCH:
if (packet.getIPPayload() != null) {
  packet.getIPPayload().printPacket(System.out);
  udpHandler.handlePacket(packet,(UDPPacket)packet.getIPPayload());
}
 else {
  UDPPacket p=new UDPPacket();
  p.parsePacketData(packet);
  p.printPacket(System.out);
  packet.setIPPayload(p);
  udpHandler.handlePacket(packet,p);
}
if (networkEventListener != null) {
networkEventListener.packetHandled(packet);
}
break;
case TCPPacket.DISPATCH:
TCPPacket p=new TCPPacket();
p.parsePacketData(packet);
p.printPacket(System.out);
packet.setIPPayload(p);
tcpHandler.handlePacket(packet);
if (networkEventListener != null) {
networkEventListener.packetHandled(packet);
}
break;
}
}
 else if (!isOnLink(packet.getDestinationAddress()) && packet.netInterface != tunnel) {
System.out.println("String_Node_Str" + tunnel);
if (packet.ipPayload == null) {
System.out.println("String_Node_Str");
packet.setIPPayload(new BytePayload(packet));
}
 else {
System.out.println("String_Node_Str");
}
System.out.print("String_Node_Str");
IPv6Packet.printAddress(System.out,myIPAddress);
System.out.print("String_Node_Str");
IPv6Packet.printAddress(System.out,packet.getDestinationAddress());
if (tunnel != null && tunnel.isReady()) {
tunnel.sendPacket(packet);
}
}
 else if (packet.netInterface != linkLayerHandler) {
System.out.println("String_Node_Str" + packet.getDestinationAddress() + "String_Node_Str");
if (packet.ipPayload == null) {
packet.setIPPayload(new BytePayload(packet));
if (findRoute(packet)) {
linkLayerHandler.sendPacket(packet);
}
}
}
 else {
System.out.println("String_Node_Str");
}
}