CITS3002 Computer Networks  
prev
next CITS3002 help3002 CITS3002 schedule  

Some Declarations for Introductory Protocols

Our early protocols will benefit from all using the same datatypes, so for simplicity we'll define some representative ones first.

As our protocols "evolve" we'll need to distinguish different types of data link frames from each other.

We can represent each data link frame as a structure in programming languages that support a 'byte' datatype, and permit a program to access/copy these bytes using their memory addresses. Notice that the frame itself consists of a header section and the actual data to be sent. We'll need to extend this header structure as our protocols develop.

#define  MAX_DATA_SIZE        1000

typedef struct {
// firstly, the frame's header
    int       len;            // length of the payload, only

// followed by the payload
    char      data[MAX_DATA_SIZE];
} FRAME;

#define FRAME_HEADER_SIZE     (sizeof(FRAME) - sizeof(FRAME.data))

#define FRAME_SIZE(f)         (FRAME_HEADER_SIZE + f.len)

Importantly, even though we've defined our FRAME structure to be of a fixed (large) size, we hope to avoid sending the whole (large) FRAME if possible. For example, while the standard Ethernet frame may carry up to 1500bytes of data, it may only need to carry, say, 80bytes.

In fact, protocols often exchange frames consisting of only the header (e.g. acknowledgment frames).


CITS3002 Computer Networks, Lecture 3, Data Link Layer protocols, p3, 13th March 2024.