SlideShare a Scribd company logo
1 of 12
BUMP implementation in Java.docx
The project is to implement the BUMP client in java,
with window size 1. Here is an overview of the three WUMP
protocols (BUMP, HUMP, and CHUMP). Here are the
files wumppkt.java, containing the packet format classes,
and wclient.java, which contains an outline of the actual
program. Only the latter file should be modified; you
should not have to make changes to wumppkt.java.
What you are to do is the following, by modifying and
extending the wclient.java outline file:
· Implement the basic transfer
· Add all appropriate packet sanity checks: timeouts, host/port,
size, opcode, and block number
· Generate output. The transferred file is to be written to
System.out. A status message about every packet (listing size
and block number) is to be written to System.err.
Do not confuse these!
· Terminate after a packet of size less than 512 is received
· Implement an appropriate "dallying" strategy
· send an ERROR packet if it receives a packet from the wrong
port. The appropriate ERRCODE in this case is EBADPORT.
An outline of the program main loop is attached
recommended that you implement this in phases, as follows.
1. Latch on to the new port: save the port number from Data[1],
and make sure all ACKs get sent to this port. This will mean
that the transfer completes. You should also make sure the
client stops when a packet with less than 512 bytes of data is
received. Unless you properly record the source port for
Data[1], you have no place to which to send ACK[1]!
2. For each data packet received, write the data to System.out.
All status messages should go to System.err, so the two data
streams are separate if stdout is redirected. To write to
System.out, use System.out.write:
System.out.write(byte[] buf, int offset, int length);
For your program, offset will be 0, buf will typically be
dpacket.data(), where dpacket is of type DATA
(wumppkt.DATA). The length will be dpacket.size() -
wumppkt.DHEADERSIZE (or, equivalently, dg.getLength() -
wumppkt.DHEADERSIZE, where dg is a DatagramPacket
object).
3. Add sanity checks, for (in order) host/port, packet size,
opcode, and block number.
4. Handle timeouts, by retransmitting the most recently sent
packet when the elapsed time exceeds a certain amount (4
seconds?). One way to do this is to keep a DatagramPacket
variable LastSent, which can either be reqDG or ackDG, and
just resend LastSent. Note that the response to an
InterruptedIOException, a "true" timeout, will simply be to
continue the loop again.
5. Add support for an dallying and error packets. After the
client has received the file, dallying means to wait 2.0 - 3.0
timeout intervals (or more) to see if the final data packet is
retransmitted. If it is, it means that the final ACK was lost. The
dally period gives the client an opportunity to resend the final
ACK. Error packets are to be sent to any sender of an apparent
data packet that comes from the wrong port.
vanilla Normal transfer
lose Lose everything after the first windowful (min 3). It
will be retransmitted when you retransmit the previous ACK.
spray Constant barrage of data[1]. Implies LOSE too. In this
case, no timeout events will occur; you must check for elapsed
time.
delay Delays sending packet 1, prompting a duplicate REQ
and thus results in multiple server instances on multiple ports.
reorder Sends the first windowful in the wrong order. You're
probably not implementing windows.
dupdata2
DATA[2] is sent twice
losedata2
DATA[2] is lost on initial send, until you resend ACK[1]
marspacket
A packet from the wrong port (a "martian" port) arrives
badopcode
a packet arrives with an incorrect opcode
nofile
you get an error packet with a NO FILE error code.
At this point, the only ones that work on port 4716
are vanilla, lose2 (losedata2) and dup2 (dupdata2).
wumppkt.javawumppkt.java// The following implements the pac
ket formats for BUMP and HUMP.
// Each individual packet type derives from class BASE, contain
ing
// protocol and opcode fields only; we don't really use this inher
itance
// hierarchy though.
// packets can be constructed with the applicable constructors;
// each ctor requires parameters for the necessary fields.
// when possible, there is a "convenience" ctor setting proto = B
UMPPROTO.
// The "raw" packet format, as sent and received via DatagramS
ocket,
// is byte[]. Packets (at least those that one might *receive*)
// can be constructed from a byte[]. For DATA packets, we also
need
// to specify the length of the packet, not necessarily the same a
s
// the length of the byte[] buffer.
// All packet classes also have a write() member function that
// writes out the packet fields into a byte[], for sending.
//import java.lang.*; //pld
//import java.net.*; //pld
//import java.lang.System.*;
import java.io.*;
publicclass wumppkt {
publicstaticfinalshort BUMPPROTO =1;
publicstaticfinalshort HUMPPROTO =2;
publicstaticfinalshort CHUMPPROTO=3;
publicstaticfinalshortREQop=1;
publicstaticfinalshortDATAop=2;
publicstaticfinalshortACKop=3;
publicstaticfinalshortERRORop=4;
publicstaticfinalshortHANDOFFop=5;
publicstaticfinalshort SERVERPORT =4715;
publicstaticfinalshort SAMEPORT =4716;
publicstaticfinalint INITTIMEOUT =3000;// milliseconds
publicstaticfinalint SHORTSIZE =2;// in bytes
publicstaticfinalint INTSIZE =4;
publicstaticfinalint BASESIZE =2;
publicstaticfinalint MAXDATASIZE=512;
publicstaticfinalint DHEADERSIZE = BASESIZE + SHORTSI
ZE + INTSIZE;// DATA header size
publicstaticfinalint MAXSIZE = DHEADERSIZE + MAXDAT
ASIZE;
publicstaticfinalint EBADPORT =1;/* packet from wrong port
*/
publicstaticfinalint EBADPROTO =2;/* unknown protocol */
publicstaticfinalint EBADOPCODE=3;/* unknown opcode */
publicstaticfinalint ENOFILE =4;/* REQ for nonexistent file
*/
publicstaticfinalint ENOPERM =5;/* REQ for file with wron
g permissions */
staticint proto(byte[] buf){
return buf[0];
}
staticint opcode(byte[] buf){
return buf[1];
}
publicstaticvoid w_assert(boolean cond,String s){
if(cond)return;
System.err.println("assertion failed: "+ s);
java.lang.System.exit(1);
}
//***************************************************
*********************
publicclass BASE {//implements Externalizable {
// don't construct these unless the buffer has length >=4!
// the data:
privatebyte _proto;
privatebyte _opcode;
//---------------------------------
public BASE(int proto,int opcode){
//super(); // call to base ctor
_proto =(byte) proto;
_opcode =(byte) opcode;
}
public BASE(byte[] buf){// constructs pkt out of packetbuf
}
public BASE(){}// packet ctors do all the work!
publicbyte[] write(){// not used
returnnull;
}
publicint size(){
return BASESIZE;
}
publicint proto(){return _proto;}
publicint opcode(){return _opcode;}
}
//*******************
publicclass REQ extends BASE {
privateshort _winsize;
privateString _filename;
//---------------------------------
public REQ(int proto,int winsize,String filename){
super(proto,REQop);
_winsize =(short) winsize;
_filename = filename;
}
public REQ(int winsize,String filename){
this(BUMPPROTO, winsize, filename);
}
public REQ(byte[] buf){// not complete but not needed
//super(BUMPPROTO, REQop);
}
publicbyte[] write(){
ByteArrayOutputStream baos =newByteArrayOutputStream(size
());
DataOutputStream dos =newDataOutputStream(baos);
try{
//writeExternal(dos);
dos.writeByte(super.proto());
dos.writeByte(super.opcode());
dos.writeShort(_winsize);
dos.writeBytes(_filename);
dos.writeByte(0);
return baos.toByteArray();
}catch(IOException ioe){
System.err.println("BASE packet output conversion failed");
returnnull;
}
//return null;
}
publicint size(){
returnsuper.size()+ SHORTSIZE + _filename.length()+1;
}
publicString filename(){return _filename;}
}
//*******************
publicclass ACK extends BASE {
privateint _blocknum;
//---------------------------------
public ACK(int blocknum){
this(BUMPPROTO, blocknum);
}
public ACK(short proto,int blocknum){
super(proto,ACKop);
_blocknum = blocknum;
}
publicint blocknum(){return _blocknum;}
publicvoid setblock(int blocknum){_blocknum = blocknum;}
publicbyte[] write(){
ByteArrayOutputStream baos =newByteArrayOutputStream(size
());
DataOutputStream dos =newDataOutputStream(baos);
try{
//writeExternal(dos);
dos.writeByte(super.proto());
dos.writeByte(super.opcode());
dos.writeShort(0);// padding
dos.writeInt(_blocknum);
return baos.toByteArray();
}catch(IOException ioe){
System.err.println("ACK packet output conversion failed");
returnnull;
}
}
publicint size(){
returnsuper.size()+ SHORTSIZE + INTSIZE;
}
public ACK(byte[] buf){}// not complete but not needed
}
//*******************
publicclass DATA extends BASE {
privateint _blocknum;
privatebyte[] _data;
//---------------------------------
public DATA(int proto,int blocknum,byte[] data){
super(proto,DATAop);
_blocknum = blocknum;
_data = data;
}
public DATA(int proto,int blocknum,byte[] data,int len){
super(proto,DATAop);
_blocknum = blocknum;
_data = data;
}
public DATA(byte[] buf,int bufsize){
this(BUMPPROTO, buf, bufsize);
}
// for building a DATA out of incoming buffer:
public DATA(int proto,byte[] buf,int bufsize){
super(proto,DATAop);
ByteArrayInputStream bais =newByteArrayInputStream(buf,0, b
ufsize);
DataInputStream dis =newDataInputStream(bais);
try{
int p = dis.readByte();
w_assert(p==proto,"Expecting proto "+ proto +", got "+
p);
int o = dis.readByte();
w_assert(o==DATAop,"Expecting opcode=DATA, got "
+ o);
int pad=dis.readShort();
_blocknum =(dis.readInt());
_data =newbyte[dis.available()];
dis.read(_data);
}catch(IOException ioe){
System.err.println("DATA packet conversion failed");
return;
}
}
public DATA(int proto){// for creating "empty" DATA objects
super(proto,DATAop);
_blocknum =0;
_data =newbyte[MAXDATASIZE];
}
public DATA(){this(BUMPPROTO);}
publicint blocknum(){return _blocknum;}
publicbyte[] data(){return _data;}
publicbyte[] write(){// not complete but not needed
returnnull;
}
publicint size(){
returnsuper.size()+ SHORTSIZE + INTSIZE + _data.length;
}
}
//*******************
publicclass ERROR extends BASE {
privateshort _errcode;
//---------------------------------
public ERROR(short proto,short errcode){
super(proto,ERRORop);
_errcode = errcode;
}
publicshort errcode(){return _errcode;}
publicbyte[] write(){
ByteArrayOutputStream baos =newByteArrayOutputStream(size
());
DataOutputStream dos =newDataOutputStream(baos);
try{
//writeExternal(dos);
dos.writeByte(super.proto());
dos.writeByte(super.opcode());
dos.writeShort(_errcode);
return baos.toByteArray();
}catch(IOException ioe){
System.err.println("ERROR packet output conversion failed");
returnnull;
}
}
public ERROR(byte[] buf){this(BUMPPROTO, buf);}
public ERROR(int proto,byte[] buf){
super(proto,DATAop);
int opcode = wumppkt.this.opcode(buf);
w_assert(opcode ==ERRORop,"Expecting opcode=ERROR
, got "+ opcode);

More Related Content

Similar to BUMP implementation in Java.docxThe project is to implemen.docx

Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docxMARRY7
 
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfPlease do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfaioils
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoYu-Shuan Hsieh
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debuggingHao-Ran Liu
 
Testing CAN network with help of CANToolz
Testing CAN network with help of CANToolzTesting CAN network with help of CANToolz
Testing CAN network with help of CANToolzAlexey Sintsov
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabMichelle Holley
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresGowtham Reddy
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoScyllaDB
 
Wireshark Lab IP v6.0 Supplement to Computer Networking.docx
Wireshark Lab IP v6.0  Supplement to Computer Networking.docxWireshark Lab IP v6.0  Supplement to Computer Networking.docx
Wireshark Lab IP v6.0 Supplement to Computer Networking.docxalanfhall8953
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio Cesare
 
Wireshark udp
Wireshark udpWireshark udp
Wireshark udperombapu
 
Lavigne bsdmag may13
Lavigne bsdmag may13Lavigne bsdmag may13
Lavigne bsdmag may13Dru Lavigne
 
forwarder.java.txt java forwarder class waits for an in.docx
forwarder.java.txt java forwarder class waits for an in.docxforwarder.java.txt java forwarder class waits for an in.docx
forwarder.java.txt java forwarder class waits for an in.docxbudbarber38650
 
#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdf#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdfarasanlethers
 

Similar to BUMP implementation in Java.docxThe project is to implemen.docx (20)

Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx Lab Assignment 4 CSE330 Spring 2014  Skeleton Code for ex.docx
Lab Assignment 4 CSE330 Spring 2014 Skeleton Code for ex.docx
 
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfPlease do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
Packet filtering using jpcap
Packet filtering using jpcapPacket filtering using jpcap
Packet filtering using jpcap
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in Go
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Testing CAN network with help of CANToolz
Testing CAN network with help of CANToolzTesting CAN network with help of CANToolz
Testing CAN network with help of CANToolz
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on Lab
 
#2 (UDP)
#2 (UDP)#2 (UDP)
#2 (UDP)
 
Implementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphoresImplementing of classical synchronization problem by using semaphores
Implementing of classical synchronization problem by using semaphores
 
htogcp.docx
htogcp.docxhtogcp.docx
htogcp.docx
 
07 coms 525 tcpip - udp
07    coms 525 tcpip - udp07    coms 525 tcpip - udp
07 coms 525 tcpip - udp
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
 
Wireshark Lab IP v6.0 Supplement to Computer Networking.docx
Wireshark Lab IP v6.0  Supplement to Computer Networking.docxWireshark Lab IP v6.0  Supplement to Computer Networking.docx
Wireshark Lab IP v6.0 Supplement to Computer Networking.docx
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
Wireshark udp
Wireshark udpWireshark udp
Wireshark udp
 
Lavigne bsdmag may13
Lavigne bsdmag may13Lavigne bsdmag may13
Lavigne bsdmag may13
 
forwarder.java.txt java forwarder class waits for an in.docx
forwarder.java.txt java forwarder class waits for an in.docxforwarder.java.txt java forwarder class waits for an in.docx
forwarder.java.txt java forwarder class waits for an in.docx
 
#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdf#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdf
 
netLec5.pdf
netLec5.pdfnetLec5.pdf
netLec5.pdf
 

More from hartrobert670

BUS M02C – Managerial Accounting SLO Assessment project .docx
BUS M02C – Managerial Accounting SLO Assessment project .docxBUS M02C – Managerial Accounting SLO Assessment project .docx
BUS M02C – Managerial Accounting SLO Assessment project .docxhartrobert670
 
BUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docx
BUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docxBUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docx
BUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docxhartrobert670
 
BUS LAW2HRM Management Discussion boardDis.docx
BUS LAW2HRM Management Discussion boardDis.docxBUS LAW2HRM Management Discussion boardDis.docx
BUS LAW2HRM Management Discussion boardDis.docxhartrobert670
 
BUS 571 Compensation and BenefitsCompensation Strategy Project.docx
BUS 571 Compensation and BenefitsCompensation Strategy Project.docxBUS 571 Compensation and BenefitsCompensation Strategy Project.docx
BUS 571 Compensation and BenefitsCompensation Strategy Project.docxhartrobert670
 
BUS 475 – Business and Society© 2014 Strayer University. All Rig.docx
BUS 475 – Business and Society© 2014 Strayer University. All Rig.docxBUS 475 – Business and Society© 2014 Strayer University. All Rig.docx
BUS 475 – Business and Society© 2014 Strayer University. All Rig.docxhartrobert670
 
BUS 210 Exam Instructions.Please read the exam carefully and a.docx
BUS 210 Exam Instructions.Please read the exam carefully and a.docxBUS 210 Exam Instructions.Please read the exam carefully and a.docx
BUS 210 Exam Instructions.Please read the exam carefully and a.docxhartrobert670
 
BUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docx
BUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docxBUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docx
BUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docxhartrobert670
 
BUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docx
BUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docxBUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docx
BUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docxhartrobert670
 
BUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docx
BUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docxBUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docx
BUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docxhartrobert670
 
BullyingIntroductionBullying is defined as any for.docx
BullyingIntroductionBullying is defined as any for.docxBullyingIntroductionBullying is defined as any for.docx
BullyingIntroductionBullying is defined as any for.docxhartrobert670
 
BUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docx
BUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docxBUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docx
BUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docxhartrobert670
 
BUS 303 Graduate School and Further Education PlanningRead and w.docx
BUS 303 Graduate School and Further Education PlanningRead and w.docxBUS 303 Graduate School and Further Education PlanningRead and w.docx
BUS 303 Graduate School and Further Education PlanningRead and w.docxhartrobert670
 
Bulletin Board Submission 10 Points. Due by Monday at 900 a.m..docx
Bulletin Board Submission 10 Points. Due by Monday at 900 a.m..docxBulletin Board Submission 10 Points. Due by Monday at 900 a.m..docx
Bulletin Board Submission 10 Points. Due by Monday at 900 a.m..docxhartrobert670
 
BUS 371Fall 2014Final Exam – Essay65 pointsDue Monda.docx
BUS 371Fall 2014Final Exam – Essay65 pointsDue  Monda.docxBUS 371Fall 2014Final Exam – Essay65 pointsDue  Monda.docx
BUS 371Fall 2014Final Exam – Essay65 pointsDue Monda.docxhartrobert670
 
Burn with Us Sacrificing Childhood in The Hunger GamesSus.docx
Burn with Us Sacrificing Childhood in The Hunger GamesSus.docxBurn with Us Sacrificing Childhood in The Hunger GamesSus.docx
Burn with Us Sacrificing Childhood in The Hunger GamesSus.docxhartrobert670
 
BUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docx
BUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docxBUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docx
BUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docxhartrobert670
 
Burgerville- Motivation Goals.Peer-reviewed articles.Here ar.docx
Burgerville- Motivation Goals.Peer-reviewed articles.Here ar.docxBurgerville- Motivation Goals.Peer-reviewed articles.Here ar.docx
Burgerville- Motivation Goals.Peer-reviewed articles.Here ar.docxhartrobert670
 
Bullying Bullying in Schools PaperName.docx
Bullying     Bullying in Schools PaperName.docxBullying     Bullying in Schools PaperName.docx
Bullying Bullying in Schools PaperName.docxhartrobert670
 
Building Design and Construction FIRE 1102 – Principle.docx
Building Design and Construction FIRE 1102 – Principle.docxBuilding Design and Construction FIRE 1102 – Principle.docx
Building Design and Construction FIRE 1102 – Principle.docxhartrobert670
 
Building on your initial user interface (UI) design mock-up of the.docx
Building on your initial user interface (UI) design mock-up of the.docxBuilding on your initial user interface (UI) design mock-up of the.docx
Building on your initial user interface (UI) design mock-up of the.docxhartrobert670
 

More from hartrobert670 (20)

BUS M02C – Managerial Accounting SLO Assessment project .docx
BUS M02C – Managerial Accounting SLO Assessment project .docxBUS M02C – Managerial Accounting SLO Assessment project .docx
BUS M02C – Managerial Accounting SLO Assessment project .docx
 
BUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docx
BUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docxBUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docx
BUS 409 – Student Notes(Prerequisite BUS 310)COURSE DESCR.docx
 
BUS LAW2HRM Management Discussion boardDis.docx
BUS LAW2HRM Management Discussion boardDis.docxBUS LAW2HRM Management Discussion boardDis.docx
BUS LAW2HRM Management Discussion boardDis.docx
 
BUS 571 Compensation and BenefitsCompensation Strategy Project.docx
BUS 571 Compensation and BenefitsCompensation Strategy Project.docxBUS 571 Compensation and BenefitsCompensation Strategy Project.docx
BUS 571 Compensation and BenefitsCompensation Strategy Project.docx
 
BUS 475 – Business and Society© 2014 Strayer University. All Rig.docx
BUS 475 – Business and Society© 2014 Strayer University. All Rig.docxBUS 475 – Business and Society© 2014 Strayer University. All Rig.docx
BUS 475 – Business and Society© 2014 Strayer University. All Rig.docx
 
BUS 210 Exam Instructions.Please read the exam carefully and a.docx
BUS 210 Exam Instructions.Please read the exam carefully and a.docxBUS 210 Exam Instructions.Please read the exam carefully and a.docx
BUS 210 Exam Instructions.Please read the exam carefully and a.docx
 
BUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docx
BUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docxBUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docx
BUS 137S Special Topics in Marketing (Services Marketing)Miwa Y..docx
 
BUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docx
BUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docxBUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docx
BUS 313 – Student NotesCOURSE DESCRIPTIONThis course intro.docx
 
BUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docx
BUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docxBUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docx
BUS 1 Mini Exam – Chapters 05 – 10 40 Points S.docx
 
BullyingIntroductionBullying is defined as any for.docx
BullyingIntroductionBullying is defined as any for.docxBullyingIntroductionBullying is defined as any for.docx
BullyingIntroductionBullying is defined as any for.docx
 
BUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docx
BUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docxBUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docx
BUS1001 - Integrated Business PerspectivesCourse SyllabusSch.docx
 
BUS 303 Graduate School and Further Education PlanningRead and w.docx
BUS 303 Graduate School and Further Education PlanningRead and w.docxBUS 303 Graduate School and Further Education PlanningRead and w.docx
BUS 303 Graduate School and Further Education PlanningRead and w.docx
 
Bulletin Board Submission 10 Points. Due by Monday at 900 a.m..docx
Bulletin Board Submission 10 Points. Due by Monday at 900 a.m..docxBulletin Board Submission 10 Points. Due by Monday at 900 a.m..docx
Bulletin Board Submission 10 Points. Due by Monday at 900 a.m..docx
 
BUS 371Fall 2014Final Exam – Essay65 pointsDue Monda.docx
BUS 371Fall 2014Final Exam – Essay65 pointsDue  Monda.docxBUS 371Fall 2014Final Exam – Essay65 pointsDue  Monda.docx
BUS 371Fall 2014Final Exam – Essay65 pointsDue Monda.docx
 
Burn with Us Sacrificing Childhood in The Hunger GamesSus.docx
Burn with Us Sacrificing Childhood in The Hunger GamesSus.docxBurn with Us Sacrificing Childhood in The Hunger GamesSus.docx
Burn with Us Sacrificing Childhood in The Hunger GamesSus.docx
 
BUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docx
BUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docxBUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docx
BUS 305 SOLUTIONS TOPRACTICE PROBLEMS EXAM 21) B2) B3.docx
 
Burgerville- Motivation Goals.Peer-reviewed articles.Here ar.docx
Burgerville- Motivation Goals.Peer-reviewed articles.Here ar.docxBurgerville- Motivation Goals.Peer-reviewed articles.Here ar.docx
Burgerville- Motivation Goals.Peer-reviewed articles.Here ar.docx
 
Bullying Bullying in Schools PaperName.docx
Bullying     Bullying in Schools PaperName.docxBullying     Bullying in Schools PaperName.docx
Bullying Bullying in Schools PaperName.docx
 
Building Design and Construction FIRE 1102 – Principle.docx
Building Design and Construction FIRE 1102 – Principle.docxBuilding Design and Construction FIRE 1102 – Principle.docx
Building Design and Construction FIRE 1102 – Principle.docx
 
Building on your initial user interface (UI) design mock-up of the.docx
Building on your initial user interface (UI) design mock-up of the.docxBuilding on your initial user interface (UI) design mock-up of the.docx
Building on your initial user interface (UI) design mock-up of the.docx
 

Recently uploaded

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 

Recently uploaded (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

BUMP implementation in Java.docxThe project is to implemen.docx

  • 1. BUMP implementation in Java.docx The project is to implement the BUMP client in java, with window size 1. Here is an overview of the three WUMP protocols (BUMP, HUMP, and CHUMP). Here are the files wumppkt.java, containing the packet format classes, and wclient.java, which contains an outline of the actual program. Only the latter file should be modified; you should not have to make changes to wumppkt.java. What you are to do is the following, by modifying and extending the wclient.java outline file: · Implement the basic transfer · Add all appropriate packet sanity checks: timeouts, host/port, size, opcode, and block number · Generate output. The transferred file is to be written to System.out. A status message about every packet (listing size and block number) is to be written to System.err. Do not confuse these! · Terminate after a packet of size less than 512 is received · Implement an appropriate "dallying" strategy · send an ERROR packet if it receives a packet from the wrong port. The appropriate ERRCODE in this case is EBADPORT. An outline of the program main loop is attached recommended that you implement this in phases, as follows. 1. Latch on to the new port: save the port number from Data[1], and make sure all ACKs get sent to this port. This will mean that the transfer completes. You should also make sure the client stops when a packet with less than 512 bytes of data is received. Unless you properly record the source port for Data[1], you have no place to which to send ACK[1]! 2. For each data packet received, write the data to System.out. All status messages should go to System.err, so the two data
  • 2. streams are separate if stdout is redirected. To write to System.out, use System.out.write: System.out.write(byte[] buf, int offset, int length); For your program, offset will be 0, buf will typically be dpacket.data(), where dpacket is of type DATA (wumppkt.DATA). The length will be dpacket.size() - wumppkt.DHEADERSIZE (or, equivalently, dg.getLength() - wumppkt.DHEADERSIZE, where dg is a DatagramPacket object). 3. Add sanity checks, for (in order) host/port, packet size, opcode, and block number. 4. Handle timeouts, by retransmitting the most recently sent packet when the elapsed time exceeds a certain amount (4 seconds?). One way to do this is to keep a DatagramPacket variable LastSent, which can either be reqDG or ackDG, and just resend LastSent. Note that the response to an InterruptedIOException, a "true" timeout, will simply be to continue the loop again. 5. Add support for an dallying and error packets. After the client has received the file, dallying means to wait 2.0 - 3.0 timeout intervals (or more) to see if the final data packet is retransmitted. If it is, it means that the final ACK was lost. The dally period gives the client an opportunity to resend the final ACK. Error packets are to be sent to any sender of an apparent data packet that comes from the wrong port. vanilla Normal transfer lose Lose everything after the first windowful (min 3). It will be retransmitted when you retransmit the previous ACK. spray Constant barrage of data[1]. Implies LOSE too. In this case, no timeout events will occur; you must check for elapsed time. delay Delays sending packet 1, prompting a duplicate REQ and thus results in multiple server instances on multiple ports. reorder Sends the first windowful in the wrong order. You're
  • 3. probably not implementing windows. dupdata2 DATA[2] is sent twice losedata2 DATA[2] is lost on initial send, until you resend ACK[1] marspacket A packet from the wrong port (a "martian" port) arrives badopcode a packet arrives with an incorrect opcode nofile you get an error packet with a NO FILE error code. At this point, the only ones that work on port 4716 are vanilla, lose2 (losedata2) and dup2 (dupdata2). wumppkt.javawumppkt.java// The following implements the pac ket formats for BUMP and HUMP. // Each individual packet type derives from class BASE, contain ing // protocol and opcode fields only; we don't really use this inher itance // hierarchy though. // packets can be constructed with the applicable constructors; // each ctor requires parameters for the necessary fields. // when possible, there is a "convenience" ctor setting proto = B UMPPROTO. // The "raw" packet format, as sent and received via DatagramS ocket, // is byte[]. Packets (at least those that one might *receive*) // can be constructed from a byte[]. For DATA packets, we also need // to specify the length of the packet, not necessarily the same a
  • 4. s // the length of the byte[] buffer. // All packet classes also have a write() member function that // writes out the packet fields into a byte[], for sending. //import java.lang.*; //pld //import java.net.*; //pld //import java.lang.System.*; import java.io.*; publicclass wumppkt { publicstaticfinalshort BUMPPROTO =1; publicstaticfinalshort HUMPPROTO =2; publicstaticfinalshort CHUMPPROTO=3; publicstaticfinalshortREQop=1; publicstaticfinalshortDATAop=2; publicstaticfinalshortACKop=3; publicstaticfinalshortERRORop=4; publicstaticfinalshortHANDOFFop=5; publicstaticfinalshort SERVERPORT =4715; publicstaticfinalshort SAMEPORT =4716; publicstaticfinalint INITTIMEOUT =3000;// milliseconds publicstaticfinalint SHORTSIZE =2;// in bytes publicstaticfinalint INTSIZE =4; publicstaticfinalint BASESIZE =2; publicstaticfinalint MAXDATASIZE=512; publicstaticfinalint DHEADERSIZE = BASESIZE + SHORTSI ZE + INTSIZE;// DATA header size publicstaticfinalint MAXSIZE = DHEADERSIZE + MAXDAT ASIZE;
  • 5. publicstaticfinalint EBADPORT =1;/* packet from wrong port */ publicstaticfinalint EBADPROTO =2;/* unknown protocol */ publicstaticfinalint EBADOPCODE=3;/* unknown opcode */ publicstaticfinalint ENOFILE =4;/* REQ for nonexistent file */ publicstaticfinalint ENOPERM =5;/* REQ for file with wron g permissions */ staticint proto(byte[] buf){ return buf[0]; } staticint opcode(byte[] buf){ return buf[1]; } publicstaticvoid w_assert(boolean cond,String s){ if(cond)return; System.err.println("assertion failed: "+ s); java.lang.System.exit(1); } //*************************************************** ********************* publicclass BASE {//implements Externalizable { // don't construct these unless the buffer has length >=4! // the data: privatebyte _proto; privatebyte _opcode; //---------------------------------
  • 6. public BASE(int proto,int opcode){ //super(); // call to base ctor _proto =(byte) proto; _opcode =(byte) opcode; } public BASE(byte[] buf){// constructs pkt out of packetbuf } public BASE(){}// packet ctors do all the work! publicbyte[] write(){// not used returnnull; } publicint size(){ return BASESIZE; } publicint proto(){return _proto;} publicint opcode(){return _opcode;} } //******************* publicclass REQ extends BASE { privateshort _winsize; privateString _filename; //--------------------------------- public REQ(int proto,int winsize,String filename){ super(proto,REQop); _winsize =(short) winsize; _filename = filename;
  • 7. } public REQ(int winsize,String filename){ this(BUMPPROTO, winsize, filename); } public REQ(byte[] buf){// not complete but not needed //super(BUMPPROTO, REQop); } publicbyte[] write(){ ByteArrayOutputStream baos =newByteArrayOutputStream(size ()); DataOutputStream dos =newDataOutputStream(baos); try{ //writeExternal(dos); dos.writeByte(super.proto()); dos.writeByte(super.opcode()); dos.writeShort(_winsize); dos.writeBytes(_filename); dos.writeByte(0); return baos.toByteArray(); }catch(IOException ioe){ System.err.println("BASE packet output conversion failed"); returnnull; } //return null; } publicint size(){ returnsuper.size()+ SHORTSIZE + _filename.length()+1; } publicString filename(){return _filename;} }
  • 8. //******************* publicclass ACK extends BASE { privateint _blocknum; //--------------------------------- public ACK(int blocknum){ this(BUMPPROTO, blocknum); } public ACK(short proto,int blocknum){ super(proto,ACKop); _blocknum = blocknum; } publicint blocknum(){return _blocknum;} publicvoid setblock(int blocknum){_blocknum = blocknum;} publicbyte[] write(){ ByteArrayOutputStream baos =newByteArrayOutputStream(size ()); DataOutputStream dos =newDataOutputStream(baos); try{ //writeExternal(dos); dos.writeByte(super.proto()); dos.writeByte(super.opcode()); dos.writeShort(0);// padding dos.writeInt(_blocknum); return baos.toByteArray(); }catch(IOException ioe){ System.err.println("ACK packet output conversion failed"); returnnull; } }
  • 9. publicint size(){ returnsuper.size()+ SHORTSIZE + INTSIZE; } public ACK(byte[] buf){}// not complete but not needed } //******************* publicclass DATA extends BASE { privateint _blocknum; privatebyte[] _data; //--------------------------------- public DATA(int proto,int blocknum,byte[] data){ super(proto,DATAop); _blocknum = blocknum; _data = data; } public DATA(int proto,int blocknum,byte[] data,int len){ super(proto,DATAop); _blocknum = blocknum; _data = data; } public DATA(byte[] buf,int bufsize){ this(BUMPPROTO, buf, bufsize); } // for building a DATA out of incoming buffer: public DATA(int proto,byte[] buf,int bufsize){ super(proto,DATAop);
  • 10. ByteArrayInputStream bais =newByteArrayInputStream(buf,0, b ufsize); DataInputStream dis =newDataInputStream(bais); try{ int p = dis.readByte(); w_assert(p==proto,"Expecting proto "+ proto +", got "+ p); int o = dis.readByte(); w_assert(o==DATAop,"Expecting opcode=DATA, got " + o); int pad=dis.readShort(); _blocknum =(dis.readInt()); _data =newbyte[dis.available()]; dis.read(_data); }catch(IOException ioe){ System.err.println("DATA packet conversion failed"); return; } } public DATA(int proto){// for creating "empty" DATA objects super(proto,DATAop); _blocknum =0; _data =newbyte[MAXDATASIZE]; } public DATA(){this(BUMPPROTO);} publicint blocknum(){return _blocknum;} publicbyte[] data(){return _data;} publicbyte[] write(){// not complete but not needed returnnull; } publicint size(){
  • 11. returnsuper.size()+ SHORTSIZE + INTSIZE + _data.length; } } //******************* publicclass ERROR extends BASE { privateshort _errcode; //--------------------------------- public ERROR(short proto,short errcode){ super(proto,ERRORop); _errcode = errcode; } publicshort errcode(){return _errcode;} publicbyte[] write(){ ByteArrayOutputStream baos =newByteArrayOutputStream(size ()); DataOutputStream dos =newDataOutputStream(baos); try{ //writeExternal(dos); dos.writeByte(super.proto()); dos.writeByte(super.opcode()); dos.writeShort(_errcode); return baos.toByteArray(); }catch(IOException ioe){ System.err.println("ERROR packet output conversion failed"); returnnull; } } public ERROR(byte[] buf){this(BUMPPROTO, buf);}
  • 12. public ERROR(int proto,byte[] buf){ super(proto,DATAop); int opcode = wumppkt.this.opcode(buf); w_assert(opcode ==ERRORop,"Expecting opcode=ERROR , got "+ opcode);