计算机网络实验1

上传人:壹****1 文档编号:488767430 上传时间:2023-06-10 格式:DOC 页数:30 大小:260.50KB
返回 下载 相关 举报
计算机网络实验1_第1页
第1页 / 共30页
计算机网络实验1_第2页
第2页 / 共30页
计算机网络实验1_第3页
第3页 / 共30页
计算机网络实验1_第4页
第4页 / 共30页
计算机网络实验1_第5页
第5页 / 共30页
点击查看更多>>
资源描述

《计算机网络实验1》由会员分享,可在线阅读,更多相关《计算机网络实验1(30页珍藏版)》请在金锄头文库上搜索。

1、杭 州 电 子 科 技 大 学实 验 报 告学生姓名:韩民杨 学 号:20820 指引教师:吴端坡实验地点:108实验时间:-24一、实验室名称:1#8二、实验项目名称:计算机网络实验1Cding on erdectecting gthms(C+)三、实验学时:四、实验原理:C+编程五、实验目旳:运用C+编程CRC16校验及奇偶校验六、实验内容:Cong on errordetecting agorithms(C+)1. ylic redunday heckUing te polnmials belwto encode radom generted dastre (4100bits) Show

2、 the FEC,n ndd dataframe.CRC-44+x1IU.74CRC-1+x15+x2+1IBM SDLRC-322+x26+x23+.+x2+x+1IP, RAR, EE802 LN/FDDI, IEE 14,PPFCSF te rortte lised below, whatthecnlusionoeshe ceiver et? a the reivrfind the eos?CeErrr patternNo ero00000neerr1000.000Two eror1.001Randm rorsRanom error ptern2. Parity chc Using ev

3、enr d paity check on rnd geerated dta trem (8-20bis).hwencodd at rameForthe error pater istedbelow,hat the coclson doeste ecer ge?Cnhe reciverfndthe erors?CeError ternN error0000ne rror100.0o errr100.01七、实验器材(设备、元器件):PC机一台,装有C+集成开发环境。八、实验环节:#include#includestdli.#icludemmyh#includestring.h#includeco

4、nioh #ilue efin N_ROR efne NE_RROR #defineTWOE 3dfne RNDM_EROR4dfine REUTdefine CRC 0efeParity 0dene chec1tlg_pait;/判断奇偶校验vid ByteToBit(chr* ou,const chr*in,in bits);voi iutmesage(char*esge);int xor(char*p, a*d,int ln);car*crcfuction(ch *st,int ln,chr*ividend,inl_,int type,char crcp);cha Paritychec(

5、char *mesge_output,n lnth,int moe);oid man()int pattern = 0;intchane_a =;charege8=NUL;/ data thatpoduced b hance chamsage_otut1000=ULL;ar mesage_c NUL;/taspont egth; /messge leng/*这是固定了为4为旳c,当这里变化是就可以直接变化crc旳长度了*/chardiided=1011;car mesage_inpu100=;/*这里可以更改数值当时16为crc旳时候,此时旳e_d为15*/t len_5;/被除数长度设立ch

6、a fl;while (tr)ffuh(sin);/任意输入数据pint(pease ntthe essge!n);e(essage);pitf(A eed to en tis messge:%s,eage);engt = sten(messag);BytToit(messg_utut,mssge,legh8);for(int =0;kenh*;+)rn(%d,messae_optk);mesag_iutk mesge_uputk+48;patter 0;channl_ay =0;prt(n);pntf(Codingonerro deecng armn);pinf( 1.Ccic rdundn

7、cycheckn);print( .Parity ceck n);print( plae chie pattern: n);/*选择进入旳检错模式scnf(%d,pttrn);fflush(stdn);/清空缓存区if(tern = 1)pritf(*n);rintf( ag chanl);pintf( plse cho the ay of error);prinf(* 1.No eor *n);pritf(* 2.ne error *);prntf(* 3.Two errs *);prinf(* 4.Rndom ers *);scnf(%d,&nnel_way);prinf(nrc:);/进

8、行crc检测n en = legth*8;/prit(d,l);c *crc= NL;crc crcfctin(mesge_nput,le,vided,le_d,RC,NUL);or(it i ; lend;i+)pritf(%c,*r);message_pulength*i = crc;crc+=;printf(n);模拟信道ase ErrrpttenNo eor 0000Onerror 00.00To eror 00.001Ranm errorRandm ero pattern/i(cannelway = NO_ERROR)har*resul NL;int fagg=0;rf(信道中传播数

9、据:);or(i f =0;ength8len_d-1 ;f+)prnt(c,message_inputf);prnt(n);printf(正在检错中.n);prntf(检错成果:);fflus(sdin);reut=ccnction(mesagenput,len,didend,en_d,RULT,c-len_d);for(n = 0;i lend-1;i)rinf(%,*eult);i(rlt) - 48 ! 0)rntf( err! n);lag=1;bre;rest+=1;(fag = 0)print( no rror! n);i(hannel_wa=ONE_EROR)char*rult

10、= NUL;message_inpu = ((messag_iput 48)(1-48)) +8;printf(信道中传播数据:);for(int ;flengt*+l_- ;)rt(%c,essginutf);printf();prinf(正在检错中.);rintf(检错成果:);esult = cr_funcion(ssge_inpt,len,divided,le_d,RSULT,rc-len_d);for(int = 0;i len_d-;+)if(reslt = 1)prnt(da errr! );reak;lseontnue;result+1;f(channel_way =TWO_RRR)char *r

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号