Saturday, June 8, 2013

Phase 2 - Creating Frames

What to do
1) Decide the structure of a frame (Need help? please look at the file Help_Sess2_B04.pdf). 

struct frame {
    unsigned int Seq     // the sequence of the frame being sent, starts from 0
    unsigned int Ack     //the ack number, not used yet in this phase
    unsigned int EOM        // if the end of message
    unsigned int lenOfLastFrame     // same as lenOfLastPacket
    unsigned char Content[128]    // the payload (according to the requirement, the maximum payload of a frame is 128 bytes)    frame_kind Kind  // {ACK, NAK, DATA} // the kind of the frame, in this phase, there is only one kind, i.e. DATA    message_type Type   // {COM, FILEDATA} // same as the Type in packets
    crc CRC   // checksum, crc is of type unsigned int, this member will be used in phase 3  }
The size of each frame is 156 bytes.

Bugs encountered and solutions
1) You should not used function strncpy to pass bytes in a packet to a frame (took me 5 hours to find this bug). You got no problem with assembling the target file at server side but when you are trying to open the file, it just failed, i.e. you cannot view image.jpg or play music.mp3. Use function memcpy instead. !!!

Structure Graph


Goal Of Phase 2
Based on the code we finished on Phase 1, we add additional functionality. In this phase, the client program needs to be able to create frames based on the  packets received at Datalink Layer, transfer these frames one by one to the server. Each time the server receives a frame, it create a packet according to the data in that frame and sends the packet to the Application Layer. 

No comments:

Post a Comment