Assignment/sliding_window_dp_FINAL.c
static void send_data_frame(MSG *msg, size_t len, int seq, int dest)
{
    FRAME f;
    size_t size;
    int link;

    if(len > DATA_SIZE_MAX)
        len = DATA_SIZE_MAX;

    f.seq = seq;
    f.len = len;
    f.type = DATA;
    f.checksum = 0;
    f.dest_node = dest;
    f.src_node = nodeinfo.nodenumber;
    link = routing_table[nodeinfo.nodenumber][f.dest_node]; //get link from routing table
    memcpy(&f.msg, msg, len);
    t_window[seq] = f; //place the frame into the message buffer
    size = FRAME_SIZE(f);
    f.checksum  = CNET_ccitt((unsigned char *) &f, (int)size);

    printf("Transmitting DATA through Link: %d\n", link);
    printf("DATA transmitted,\tFrom Node Number: %d, \tSequence No: %d,\tChecksum: %d\n", f.src_node, seq, f.checksum);

    CHECK(CNET_write_physical(link, (char *) &f, &size));
}
//This method is called when a data frame is to be sent from current node to destination node
This method is called when a data frame is to be sent from current node to destination node
This method is called when a data frame is to be sent from current node to destination node
static void send_data_frame(MSG *msg, size_t len, int seq, int dest)
{
    FRAME f;
    size_t size;
    int link;
    if(len > DATA_SIZE_MAX)
        len = DATA_SIZE_MAX;
    f.seq = seq;
    f.len = len;
    f.type = DATA;
    f.checksum = 0;
    f.dest_node = dest;
    f.src_node = nodeinfo.nodenumber;
    link = routing_table[nodeinfo.nodenumber][f.dest_node]; 
    memcpy(&f.msg, msg, len);
    t_window[seq] = f; 
    size = FRAME_SIZE(f);
    f.checksum  = CNET_ccitt((unsigned char *) &f, (int)size);
    printf("Transmitting DATA through Link: %d\n", link);
    printf("DATA transmitted,\tFrom Node Number: %d, \tSequence No: %d,\tChecksum: %d\n", f.src_node, seq, f.checksum);
    CHECK(CNET_write_physical(link, (char *) &f, &size));
}
static void send_data_frame ( MSG * msg , size_t len , int seq , int dest ) { FRAME f ; size_t size ; int link ; if ( len > DATA_SIZE_MAX ) len = DATA_SIZE_MAX ; f . seq = seq ; f . len = len ; f . type = DATA ; f . checksum = 0 ; f . dest_node = dest ; f . src_node = nodeinfo . nodenumber ; link = routing_table [ nodeinfo . nodenumber ] [ f . dest_node ] ; memcpy ( & f . msg , msg , len ) ; t_window [ seq ] = f ; size = FRAME_SIZE ( f ) ; f . checksum = CNET_ccitt ( ( unsigned char * ) & f , ( int ) size ) ; printf ( " \n " , link ) ; printf ( " \t \t \t \n " , f . src_node , seq , f . checksum ) ; CHECK ( CNET_write_physical ( link , ( char * ) & f , & size ) ) ; }
This method is called when a data frame is to be sent from current node to destination node
This method is called when a data frame is to be sent from current node to destination node
//get link from routing table //place the frame into the message buffer