Skip to content

Commit

Permalink
TCP checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 5, 2013
1 parent 924fc4a commit cd61526
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ccs/neu/edu/andang/TCPHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public TCPHeader(int source_port, int destination_port, long seq_num, long ack_n
this.generateChecksum(tcpPacket, pseudoHeader);
}

private void generateChecksum(byte[] byteArray, byte[] psedoHeader) {
private int generateChecksum(byte[] byteArray, byte[] psedoHeader) {
long sum = 0;

//add TCP pseudo header containing src and dest IP addresses as 16 bit words
Expand Down Expand Up @@ -103,7 +103,8 @@ private void generateChecksum(byte[] byteArray, byte[] psedoHeader) {
//compute one's complement of sum
sum = (~sum&0xFFFF);
checksum = (int) sum;
System.out.println("The Checksum after one's complement-->"+Integer.toHexString(checksum));
System.out.println("The Checksum after one's complement-->"+Integer.toHexString(checksum));
return checksum;
}

// Generate the TCP Header in a byte array format
Expand Down

0 comments on commit cd61526

Please sign in to comment.