Alpha Geek

(8)

$10/per page/Negotiable

About Alpha Geek

Levels Tought:
University

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Environmental science,Essay writing,Programming,Social Science,Statistics Hide all
Teaching Since: Apr 2017
Last Sign in: 438 Weeks Ago, 2 Days Ago
Questions Answered: 9562
Tutorials Posted: 9559

Education

  • bachelor in business administration
    Polytechnic State University Sanluis
    Jan-2006 - Nov-2010

  • CPA
    Polytechnic State University
    Jan-2012 - Nov-2016

Experience

  • Professor
    Harvard Square Academy (HS2)
    Mar-2012 - Present

Category > Programming Posted 18 Aug 2017 My Price 15.00

c++ or c scheduler of Round Robin type for Weighted Fair Queueing

 am looking to have c++ or c program on windows work as schedular of Round Robin type which could implement Weighted Fair Queueing, i sent sample program so simelar one with simple report or notes expalining the structure of your program.m regards hatim
The PC Switch

 

Scheduler

 

*/

 

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <sys/socket.h> // socket() & bind()

#include <errno.h> // for DieWithError() function

#include <arpa/inet.h> // sockaddr_in

 

// Defining all the input and output ports of the scheduler

#define INPUT_PORT 50002

#define OUTPUT_PORT 50003

#define LOCAL_ADDRESS "127.0.0.1"

#define MAX_MSG_LEN 200

 

typedef struct packet packet; // Struct of packet being sent between each module

struct packet {

char ip_dest[4][9];

char ip_source[4][9];

short int dataLength;

char data[100];

int frameCheck;

int fromPort;

int toPort;

int sequenceNum;

int portSequenceNum;

int timer;

};

 

typedef struct packetBuffer packetBuffer;

// Declare buffer struct that holds packet struct

struct packetBuffer {

packet queuedPacket;

packetBuffer *nextSource;

packetBuffer *nextSameSource;

};

 

// Misc functions

void DieWithError(char *errorMessage);

int bin2dec(char *binary);

 

int main(void) {

struct sockaddr_in fabOUT_addr;// client info (fabric) variable, data given when received message

struct sockaddr_in schedIN_addr;// struct for incoming packets

struct sockaddr_in schedOUT_addr;// struct for outgoing packets

unsigned int fabAddrLen;// int to store length of client address (fabric) data when received

packet recvPacket, outGoing;// packet struct that will be received

int sockIN, sockOUT, recvMsgLen, n, ip[4], i=0, port, pIP[4], qIP[4], dropped=0, time=0, lastTime=0, timeToSend=4, maxSameSource=4;

packetBuffer *current = NULL;// keep track of where loop is pointing to in queue row

packetBuffer *newPacket = NULL;// used when creating new queue element

    packetBuffer *temp = NULL; // temp packetBuffer element when deleting root of queue row

    packetBuffer *previous[8]; // keep track of previous element in queue

packetBuffer *nextSend[8];// pointer to next element to be sent on port n

packetBuffer *root[8];// array of queues, queue 0 is for gateway port, 1-7 corresponding to other ports

 

//----------------Network code----------------

// Open socket

if((sockIN = socket(AF_INET, SOCK_DGRAM, 0)) < 0)

DieWithError("socket() failed");

if((sockOUT = socket(AF_INET, SOCK_DGRAM, 0)) < 0)

DieWithError("socket() failed");

 

// Construct local address structure

bzero((char *)&schedIN_addr, sizeof(schedIN_addr));// zeroes out struct before data copied

    schedIN_addr.sin_family = AF_INET; // specifies Address Family

    schedIN_addr.sin_addr.s_addr = htonl(INADDR_ANY); // accept from any network interface

    schedIN_addr.sin_port = htons(INPUT_PORT); // Using port 50002

    // Construct outgoing address structure

bzero((char *)&schedOUT_addr,sizeof(schedOUT_addr));// zeroes out struct before data copied

    schedOUT_addr.sin_family = AF_INET; // specifies Address Family

    schedOUT_addr.sin_addr.s_addr = inet_addr(LOCAL_ADDRESS); // Connect to local address

    schedOUT_addr.sin_port = htons(OUTPUT_PORT); // output port 50003

       

Answers

(8)
Status NEW Posted 18 Aug 2017 09:08 AM My Price 15.00

int----------- ma-----------in(-----------) {----------- in-----------t c-----------oun-----------t,j-----------,n,-----------tim-----------e,r-----------ema-----------in,-----------fla-----------g=0-----------,ti-----------me_-----------qua-----------ntu-----------m; -----------int----------- wa-----------it_-----------tim-----------e=0-----------,tu-----------rna-----------rou-----------nd_-----------tim-----------e=0-----------,at-----------[10-----------],b-----------t[1-----------0],-----------rt[-----------10]-----------; p-----------rin-----------tf(-----------"En-----------ter----------- To-----------tal----------- Pr-----------oce-----------ss:-----------\t -----------");-----------

Attachments

file 1503050330-33529_1_636385454975300177_RR.txt preview (263 words )
int----------- ma-----------in(-----------) ----------- ----------- ----------- -----------int----------- co-----------unt-----------,j,-----------n,t-----------ime-----------,re-----------mai-----------n,f-----------lag-----------0,t-----------ime-----------_qu-----------ant-----------um ----------- ----------- in-----------t w-----------ait-----------_ti-----------me0-----------,tu-----------rna-----------rou-----------nd_-----------tim-----------e0,-----------at1-----------0,b-----------t10-----------,rt-----------10 ----------- ----------- pr-----------int-----------f(E-----------nte-----------r T-----------ota-----------l P-----------roc-----------ess-----------t )----------- ----------- s-----------can-----------f(d-----------,n)----------- ----------- r-----------ema-----------inn----------- ----------- f-----------or(-----------cou-----------nt0-----------cou-----------ntn-----------cou-----------nt)----------- ----------- ----------- ----------- -----------pri-----------ntf-----------(En-----------ter----------- Ar-----------riv-----------al -----------Tim-----------e a-----------nd -----------Bur-----------st -----------Tim-----------e f-----------or -----------Pro-----------ces-----------s P-----------roc-----------ess----------- um-----------ber----------- d -----------,co-----------unt-----------1) ----------- ----------- -----------sca-----------nf(-----------d,a-----------tco-----------unt-----------) ----------- ----------- s-----------can-----------f(d-----------,bt-----------cou-----------nt)----------- ----------- ----------- rt-----------cou-----------ntb-----------tco-----------unt----------- ----------- ----------- ----------- pr-----------int-----------f(E-----------nte-----------r T-----------ime----------- Qu-----------ant-----------umt-----------) ----------- -----------sca-----------nf(-----------d,t-----------ime-----------_qu-----------ant-----------um)----------- ----------- p-----------rin-----------tf(-----------nnP-----------roc-----------ess-----------tTu-----------rna-----------rou-----------nd
Not Rated(0)