public void sendMessage(String message) throws ProtocolException
// Announce action
// This is to help with debugging, it's not required by the protocol
System.out.println("Sending message => " + message);
// The following statement shows how the frame sender is invoked.
// At the moment it just passes the whole message directly to the
// physical layer. That is, of course, wrong!
// sendMessage needs to split large messages into several smaller
// segments and encode each segment as a frame in the required
// format before passing it to sendFrame.
I fail to see the purpose of your post...do you have a question?
Originally Posted by copeg
The supplied version of sendMessage just passes the whole message string directly to sendFrame without framing or segmentation. As a first step, experiment with running the code supplied to become familiar with the operation of the test harness.
A next logical step is to implement a partial solution for the simple case of a short message that fits in a single frame and contains no awkward ':' characters. Just set the checksum to '000' for now. For example, if the message is hello the result of this stage will be (hello:000:.). Hint: only one line of Java needs to be edited for this step!
Implement the checksum field next, e.g. the result should become (hello:532:.). Character values can be obtained using the charAt method (look up the String class in a book or see the online Java API documentation). Java treats individual char values as numbers so they needn't be converted to ints before use in arithmetic calculations.
Next add code to expand ':' characters to '::'. Don't forget the checksum is calculated before any expansions. E.g. "a:b" would become (a::b:253:.).
Implement segmentation so that long messages are split into several frames according to the MTU. Don't forget the MTU applies to the whole frame including any expanded ':' characters. The end-of-message flag must be set according to the specification.
sorry this may be abit confusing but i am not able to do it. Every help is appreciated