
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46


목차
[Rdt3.0_functions] 7.56kb
error.c
in_cksum.c
Makefile
np.h
packet.h
set_address.c
tselect.c
udp_server.c
udt_send.c
[receiver] 2.06MB
error.c
error.o
in_cksum.c
in_cksum.o
Makefile
np.h
packet.h
receiver
receiver.c
receiver.o
Result1.txt
Result2.jpg
set_address.c
set_address.o
tselect.c
tselect.o
udt_send.c
udt_send.o
[sender] 2.05MB
error.c
error.o
in_cksum.c
in_cksum.o
Makefile
np.h
packet.h
sender
sender.c
sender.o
set_address.c
set_address.o
Test1.txt
Test2.jpg
tselect.c
tselect.o
udt_send.c
udt_send.o
error.c
in_cksum.c
Makefile
np.h
packet.h
set_address.c
tselect.c
udp_server.c
udt_send.c
[receiver] 2.06MB
error.c
error.o
in_cksum.c
in_cksum.o
Makefile
np.h
packet.h
receiver
receiver.c
receiver.o
Result1.txt
Result2.jpg
set_address.c
set_address.o
tselect.c
tselect.o
udt_send.c
udt_send.o
[sender] 2.05MB
error.c
error.o
in_cksum.c
in_cksum.o
Makefile
np.h
packet.h
sender
sender.c
sender.o
set_address.c
set_address.o
Test1.txt
Test2.jpg
tselect.c
tselect.o
udt_send.c
udt_send.o
본문내용
#include "np.h"
uint16_t
in_cksum(uint16_t *addr, int len)
{
int nleft = len;
uint32_t sum = 0;
uint16_t *w = addr;
uint16_t answer = 0;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}
/* 4mop up an odd byte, if necessary */
if (nleft == 1) {
*(unsigned char *)(&answer) = *(unsigned char *)w ;
sum += answer;
}
/* 4add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return(answer);
}
uint16_t
in_cksum(uint16_t *addr, int len)
{
int nleft = len;
uint32_t sum = 0;
uint16_t *w = addr;
uint16_t answer = 0;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}
/* 4mop up an odd byte, if necessary */
if (nleft == 1) {
*(unsigned char *)(&answer) = *(unsigned char *)w ;
sum += answer;
}
/* 4add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return(answer);
}
추천자료
병원에서의 인터넷 전자상거래 도입 및 구현에 관한 연구
최단경로문제 동적계획(Floyd 알고리즘) 과Greedy설계법(Dijkstra알고리즘)소스실행후 비교평가
[C++] 여행사 운영프로그램 보고서(소스와 프로그램사진포함)
스마트 하이웨이 (개념, 국내외 현황, 수요 및 시장 전망 및 국내추진현황)
초등과학 지도서 발견학습모형 분석
전자무역 RFID(도입효과 및 시장전망,도입 시 문제 및 한계,기술 활용 개선방안 )
신호 및 시스템 프로젝트 Filter의 주파수 응답 plotter 설계
[그래프, 그래프와 표준그래프, 그래프와 아밀로그래프, 그래프와 개념그래프, 그래프와 그래...
[객체지향][객체][객체지향 언어][객체지향 JAVA언어][자바언어][UML언어]객체지향의 개념, ...
[e-비즈니스] ❶.OSI 7 Layer(레이어/계층) 모델의 각 프로토콜 계층의 명칭 기술,...
방통대 경제학과 : [IT와경영정보시스템 공통] (1) DDL(Data Definition Language)과 DML(Dat...
인터넷과정보사회 2016] 1 컴퓨팅기기의 입력장치와 출력장치 기능과 특징, 입력장치 출력장...
[컴퓨터의이해] 본인이 사용 중이거나 또는 최신 스마트폰을 1 개 선정하고, 스마트폰의 운영...
[e-비즈니스] 1) 암호화 알고리즘 중 PKI라고 불리는 공개키 방식 알고리즘 2) 암호화 화폐 ...