Can someone help me type down the codes for me. please and thank you. Also I\'m
ID: 3754215 • Letter: C
Question
Can someone help me type down the codes for me. please and thank you. Also I'm using this on "Developer C++" if anyone has that it would be a lot easier for me. Thank you
Programming assignment 2 HIDLC (Layer 2 Protocol) HDLC (high-level data-link control) is a standard published by ISO that has achieved wide use throughout the world. HDLC is considered a superset to several other protocols. It provides for a number of options in its implementation HDLC supports both half-duplex and full-duplex transmission, point-to-point and multipoint configurations, as well as switched or non-switched channels. HDLC uses the term frame to indicate an Independent entity of data transmited across the link from one station to another. The frame consists of five or six fields. All frames must start and with the flag fields. The stations attached to the data link are required to continuously monitor for the flag sequence. The flag sequence consists of continuously transmitted on the link between HDLC frames. Flag Flag AddressControl Information FCS Figure 1: HDLC Frame Format Your assignment is to write a program that will receive the characters from the keyboard (O's, I's or any other character) until it detects an HDLC flag. Upon detection e program will continue to receive the characters from the keyboard to the of the first flag, th and shows them on the screen until a flag is detected again. The program prints screen that the end flag has been detected and that the is the information k between the two flags. No Carriage Return is allowed as part of your input at any ti eyed inExplanation / Answer
// C program
#include<stdio.h>
#include<conio.h>
struct HDLC
{
char validinput[64]; //this is used to store valid inputs
};
void displayinfo(struct HDLC fa_HDLC,int fc)
{
int i=1;
printf(" the end of the flag detected.");
printf(" the information sent was: ");
for(i;i<fc;i++)
{
printf("%c",fa_HDLC.validinput[i]);
}
}
main()
{
struct HDLC a_HDLC;
char ip;
int flag=0; //for detecting two flags,if flag=1 first flag dtected , flag=2 second flag detected.
int c=1; //counts the no of charcters
int j=0; // to tarck flag state
printf("this program exists upon entering'!' ");
while(ip !='!' && flag !=2 && c<64)
{
if(j==0) // check if part of flag detected or not
{
ip=getche();
}
if(ip=='0')
{
ip=getche(); //state1 detected.
j++;
if(ip=='1')
{
ip=getche(); //state2 detected.
j++;
if(ip=='1')
{
ip=getche();//state3 detected.
j++;
if(ip=='1')
{
ip=getche();//state4 detected.
j++;
if(ip=='1')
{
ip=getche();//state 5 detected.
j++;
if(ip=='1')
{
ip=getche();//state6 detected.
j++;
if(ip=='1')
{
ip=getche();//state7 detected.
j++;
if(ip=='0')
{//state8 detected.
if(flag==0)
{
printf(" the flag has been detected ");
}
j=0;
flag++;
ip=' '; //after flag buffer clearing
}
}
}
}
}
}
}
}
if(flag==1)
{
a_HDLC.validinput[c]=ip;
c++;
}
}
if(ip=='!')
{
printf(" the exit command was used");
}
else
{
displayinfo(a_HDLC,c);
}
}
output:
this program exists upon entering'!'
asdghjklittrcfhhhjjggghgjjjkkddggdgdgdgey01111110
the flag has been detected
sdfghjhjkkliytrfg01111110
the end of the flag detected.
the information sent was:
sdfghjhjkkliytrfg
Program finished with exit code 0
Press ENTER to exit console.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.