Create TCP.java

This commit is contained in:
jiacai_wang 2018-06-10 21:05:42 +08:00 committed by GitHub
parent c49689668e
commit 912b3734d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

39
TCP.java Normal file
View File

@ -0,0 +1,39 @@
package TCP;
public class MySegment {
public short SourcePort;
public short DestinationPort;
public int SequenceNumber;
public int AcknowledgementNumber;
public boolean ACK;
public short Window;
public byte Content;
public int Check;
public String toSend;
public MySegment()
{
SourcePort=0;
DestinationPort=0;
SequenceNumber=0;
AcknowledgementNumber=0;
ACK=false;
Window=0;
Content=0;
Check=SourcePort^DestinationPort^SequenceNumber^AcknowledgementNumber^Window^Content;
toSend=Integer.toString(SourcePort)+"--"+Integer.toString(DestinationPort)+"--"+Integer.toString(SequenceNumber)+"--"+Integer.toString(AcknowledgementNumber)+"--"+Boolean.toString(ACK)+"--"+Integer.toString(Window)+"--"+Byte.toString(Content)+"--"+Integer.toString(Check);
}
public MySegment(int sourcePort, int destinationPort, int sequenceNumber, int acknowledgementNumber, boolean ack, int window, byte content) {
SourcePort = (short)sourcePort;
DestinationPort = (short)destinationPort;
SequenceNumber = sequenceNumber;
AcknowledgementNumber = acknowledgementNumber;
ACK = ack;
Window = (short)window;
Content = content;
Check=SourcePort^DestinationPort^SequenceNumber^AcknowledgementNumber^Window^Content;
toSend=Integer.toString(sourcePort)+"--"+Integer.toString(destinationPort)+"--"+Integer.toString(sequenceNumber)+"--"+Integer.toString(acknowledgementNumber)+"--"+Boolean.toString(ack)+"--"+Integer.toString(window)+"--"+Byte.toString(content)+"--"+Integer.toString(Check);
}
}