11.07.2015 Views

Redes de computadores - Universitat Oberta de Catalunya

Redes de computadores - Universitat Oberta de Catalunya

Redes de computadores - Universitat Oberta de Catalunya

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Re<strong>de</strong>s</strong> <strong>de</strong> <strong>computadores</strong>ª FUOC • XP04/90786/00020AnexosAnexo 1El algoritmo checksumLos protocolos IP y TCP utilizan, entre otros, un sencillo checksum parala <strong>de</strong>tección <strong>de</strong> errores. Ésta es una versión <strong>de</strong>l algoritmo checksum:u_short checksum(u_short * addr,int len){int aux_len = len;u_short *aux_addr = addr;u_short res;int sum = 0;while(aux_len > 1){sum+ = *aux_addr++;aux_len- = 2;}if(aux_len == 1)sum+ = *(u_char) *aux_addr;}sum = (sum>>16) + (sum & 0xffff);sum+ = (sum>>16);res = ~sum;return res;ANOTACIONES331

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!