CSE 132 (Spring 2011)
Studio 7: FLAP

Abstract: For about an hour, you will work on a design for a simple framing package. You (and some other groups) will then discuss your design with a TA to consider important tradeoffs and to arrive at a better design. Finally you will begin Lab 4a and begin implementing FLAP support.

Setup (5 minutes)

Review studio procedures, if necessary, before starting.

Some guidelines for this week's studio:

Resources (take a quick look and keep these links handy):

Background (5 minutes)


Overview of FLAP (10 minutes)

Before we can talk with the AOL serer, we have to frame our messages using FLAP. Although we connect to AOL using TCP (the FedEx of transport protocols -- practically guarantees delivery, as compared with UDP, which does not), AOL is not so trusting that messages are delivered properly.

Think of FLAP as an envelope that contains the data you want to transmit or receive.
Every frame is of the following form:
Byte offset Length (bytes) What
0 1 An asterisk

The asterisk is transmitted as a byte, but you can cast it to a char and then compare it with '*' to see if it is what you expect. Why do all frames begin this way? It's so you can catch framing errors. If you read too much or too little in the previous frame, then the next frame (probably) won't begin with the asterisk you expect.

1 1 Frame type

For our application, this will be an integer in the set {1, 2, 5}, and it indicates the type of the frame, as described below and in the TOC document.

2 2 Sequence Number

This is an unsigned, 2-byte integer that is managed separately in each direction. You should make sure to increment this number for every frame you send to the server; the same is true going from server to client.

4 2 Payload Length

This is the length in bytes of the rest of this frame. Thus, this is an unsigned, 2-byte integer. You must make sure to consume exactly the right number of bytes for the payload, or you will experience a framing error.

Exercise 1:

Payload for Signon Frame (Frame Type = 1)

Beware that there are two froms of this frame: the longer one goes from the client ot the server and the shorter goes from the server to the client, as indicated in the table below.

Byte offset Length (bytes) What
6+0 4 FLAP Version Number (Server ←→ Client)

This is a four-byte, unsigned integer that is expected to be 1 in both directions.

6+4 2 TLV Tab (Client → Server)

This is a 2-byte unsigned integer that is expected to be 1. This field is not transmitted from server to client.

6+6 2 User Name Length (Client → Server)

This is the length of the normalized user name that comes next. In a sense this is redundant, since the length of the entire frame is given up front, but this is what is required and probably simplifies life for the server. This field is not transmitted from server to client.

6+8 Payload Length - 8 User Name (Client → Server)

The rest of the frame contains the normalized user name. Normalized means no spaces anywhere, and all characters in lower-case form. Placing the user name in this canonical form simplfies life for the server. This field is not transmitted from server to client.

Exercise 2:


Payload for Data Frame (Frame Type = 2)

Pay attention to when strings are null-terminated and when they are not!
Byte offset Length (bytes) What
6+0 Payload Length Data

The length of the data is given in the header. The data is a sequence of characters that is null-terminated ('\0') from the client to the server, but not in the other direction. The length includes the null character if it is present.


Payload for KeepAlive Frame (Frame Type = 5)

I am not sure that the KeepAlive Frame is still being used in TOC2. You should be prepared to receive it just in case.
Byte offset Length (bytes) What
6+0 4 I'm not sure what this is. If you figure it out please let me know. It seems always to have the value of 50.


Design Problem (20 minutes)

Remember that in design, there are seldom solutions that are absolutely right or wrong.

However, you should be prepared to discuss the advantages or disadvantages of any aspect of your design.

Generally, think about the following in arriving at your design:

As a team, develop the specification for a flap package.

This means typing in stubs for methods into eclipse, without providing any meaningful implementations. For methods with non-void return types, just return 0 or null or anything easy for now.
The package must include a superclass Frame that could be any FLAP frame, and extensions that represent the individual frames of interest.

Your design must observe the following:


Design Discussion (20 minutes)

At the TAs' signal, multiple groups will gather with a given TA to discuss the design of the flap package. Each group must be prepared to present its design and to participate in the discussion about the design.


Start Implementing! (30 minutes)

When you done with this studio, you must be cleared by the TA to receive credit.

Studio repo name: studio7- (from your sticker)

People on your team:

Last name 6-digit ID
1
2
3
4
5
6

TA: Password:



Last modified 14:48:49 CDT 22 March 2011 by Ron K. Cytron