carnipacket.intTransportProtocol = Constants.intTCP;
TCPPacket tcpPacket = (TCPPacket)packet;
//carnipacket.senderAddress = (IPAddress) IPAddress.getByName(tcpPacket.getSourceAddress());
//carnipacket.receiverAddress = (IPAddress) IPAddress.getByName(tcpPacket.getDestinationAddress());
carnipacket.senderAddress = new IPAddress(tcpPacket.getSourceAddress());
carnipacket.receiverAddress = new IPAddress(tcpPacket.getDestinationAddress());
carnipacket.senderPort = tcpPacket.getSourcePort();
carnipacket.receiverPort = tcpPacket.getDestinationPort();
carnipacket.data = packet.getData();
carnipacket.ipHeader = ((IPPacket)packet).getIPHeader();
carnipacket.tcpHeader = packet.getHeader();
carnipacket.date = packet.getTimeval().getDate();
carnipacket.ipIdentification = ((IPPacket)packet).getId();
// System.out.println("[Core] Sec: "+ tcpPacket.getSequenceNumber() +
// " (rSec: "+ (tcpPacket.getSequenceNumber() + tcpPacket.getPayloadDataLength()) + ")" +
// " Ack: "+tcpPacket.getAcknowledgementNumber() +
// " Len: "+tcpPacket.getPayloadDataLength());
// carnipacket.jpTCPPacket = tcpPacket;
carnipacket.setTcpSequenceNumber(tcpPacket.getSequenceNumber());
carnipacket.setTcpAcknowledgementNumber(tcpPacket.getAcknowledgementNumber());
carnipacket.setSyn(tcpPacket.isSyn());
carnipacket.setAck(tcpPacket.isAck());
carnipacket.setPsh(tcpPacket.isPsh());
carnipacket.setRst(tcpPacket.isRst());
carnipacket.setFin(tcpPacket.isFin());
carnipacket.setIpLength(((IPPacket) tcpPacket).getLength());
carnipacket.setIpHeaderLength(((IPPacket) tcpPacket).getIPHeaderLength());
carnipacket.setTcpHeaderLength(tcpPacket.getHeaderLength());
carnipacket.setTcpWindowSize(tcpPacket.getWindowSize());
carnipacket.setTcpPayloadDataLength(tcpPacket.getPayloadDataLength());
carnipacket.setReceiverMacAddress(tcpPacket.getDestinationHwAddress());
carnipacket.setSenderMacAddress(tcpPacket.getSourceHwAddress());
PacketCacheThread.instance().addPacket(carnipacket);
//handle UDP packets
} else if(packet instanceof UDPPacket) {
//Log.debug("["+this.getClass().getName()+"] packet is a UDPPacket");
carnipacket.strTransportProtocol = Constants.strUDP;
carnipacket.intTransportProtocol = Constants.intUDP;
UDPPacket udpPacket = (UDPPacket)packet;
//carnipacket.senderAddress = (IPAddress) IPAddress.getByName(udpPacket.getSourceAddress());
//carnipacket.receiverAddress = (IPAddress) IPAddress.getByName(udpPacket.getDestinationAddress());
carnipacket.senderAddress = new IPAddress(udpPacket.getSourceAddress());
carnipacket.receiverAddress = new IPAddress(udpPacket.getDestinationAddress());
carnipacket.senderPort = udpPacket.getSourcePort();
carnipacket.receiverPort = udpPacket.getDestinationPort();
carnipacket.data = packet.getData();
carnipacket.ipHeader = ((IPPacket)packet).getIPHeader();
carnipacket.tcpHeader = packet.getHeader();