Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. Most node files are just boilerplate from node.js int…
…ernals right now
- Loading branch information
Eric Jennings
committed
Aug 12, 2011
0 parents
commit 04c7251
Showing
129 changed files
with
22,767 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node-udt is a native Node.js wrapper for the UDT4 library, for high-speed data transfer. | ||
|
||
Modeling it off of the core Node.js "net" module, to mimic eventing, streaming, and async goodness when dealing with sockets (except with the super high speed of UDT). |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Copyright (c) 2001 - 2010, The Board of Trustees of the University of Illinois. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above | ||
copyright notice, this list of conditions and the | ||
following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the | ||
above copyright notice, this list of conditions | ||
and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the University of Illinois | ||
nor the names of its contributors may be used to | ||
endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
DIRS = src app | ||
TARGETS = all clean install | ||
|
||
$(TARGETS): %: $(patsubst %, %.%, $(DIRS)) | ||
|
||
$(foreach TGT, $(TARGETS), $(patsubst %, %.$(TGT), $(DIRS))): | ||
$(MAKE) -C $(subst ., , $@) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Copyright (c) 2001 - 2010, The Board of Trustees of the University of Illinois. | ||
All Rights Reserved. | ||
|
||
UDP-based Data Transfer (UDT) Library - version 4 | ||
Author: Yunhong Gu [yunhong.gu @ gmail.com] | ||
|
||
UDT version 4 is free software under BSD License. See ./LICENSE.txt. | ||
|
||
============================================================================ | ||
|
||
UDT Website: | ||
http://udt.sf.net | ||
http://sf.net/projects/udt/ | ||
|
||
|
||
CONTENT: | ||
./src: UDT source code | ||
./app: Example programs | ||
./doc: UDT documentation (HTML) | ||
./win: VS.Net project files for the Windows version of UDT | ||
|
||
|
||
To make: | ||
make -e os=XXX arch=YYY | ||
|
||
XXX: [LINUX(default), BSD, OSX] | ||
YYY: [IA32(default), POWERPC, IA64, AMD64] | ||
|
||
For example, on OS X, you may need to do "make -e os=OSX arch=POWERPC"; | ||
on 32-bit i386 Linux system, simply use "make". | ||
|
||
On Windows systems, use the Visual Studio .NET project files in ./win directory. | ||
|
||
|
||
To use UDT in your application: | ||
Read index.htm in ./doc. The documentation is in HTML format and requires your | ||
browser to support JavaScript. | ||
|
||
|
||
Questions? please post to the UDT project forum: | ||
https://sourceforge.net/forum/?group_id=115059 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version 4.8 | ||
|
||
fix a bug that may cause seg fault on concurrent close on the same socket | ||
add epoll support | ||
increase the listener's scalability to 100K concurrent connections | ||
fix a bug that may cause accept/select to return positively when an accepted socket is closed immediately after accept returns | ||
fix a bug that may cause connect to fail if the server closes listening socket immediately after accept returns | ||
fix recvfile fstream write status bug (e.g., when disk is full, recvfile should handle properly now) | ||
|
||
version 4.7a | ||
|
||
fix timeout bug introduced in 4.7 | ||
initialize CHandShake | ||
|
||
version 4.7 | ||
|
||
Fix several related bugs that can cause hang/memory leak/segmentation fault during cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
C++ = g++ | ||
|
||
ifndef os | ||
os = LINUX | ||
endif | ||
|
||
ifndef arch | ||
arch = IA32 | ||
endif | ||
|
||
CCFLAGS = -Wall -D$(os) -I../src -finline-functions -O3 | ||
|
||
ifeq ($(arch), IA32) | ||
CCFLAGS += -DIA32 #-mcpu=pentiumpro -march=pentiumpro -mmmx -msse | ||
endif | ||
|
||
ifeq ($(arch), POWERPC) | ||
CCFLAGS += -mcpu=powerpc | ||
endif | ||
|
||
ifeq ($(arch), IA64) | ||
CCFLAGS += -DIA64 | ||
endif | ||
|
||
LDFLAGS = -L../src -ludt -lstdc++ -lpthread -lm | ||
|
||
ifeq ($(os), UNIX) | ||
LDFLAGS += -lsocket | ||
endif | ||
|
||
DIR = $(shell pwd) | ||
|
||
APP = appserver appclient sendfile recvfile test | ||
|
||
all: $(APP) | ||
|
||
%.o: %.cpp | ||
$(C++) $(CCFLAGS) $< -c | ||
|
||
appserver: appserver.o | ||
$(C++) $^ -o $@ $(LDFLAGS) | ||
appclient: appclient.o | ||
$(C++) $^ -o $@ $(LDFLAGS) | ||
sendfile: sendfile.o | ||
$(C++) $^ -o $@ $(LDFLAGS) | ||
recvfile: recvfile.o | ||
$(C++) $^ -o $@ $(LDFLAGS) | ||
test: test.o | ||
$(C++) $^ -o $@ $(LDFLAGS) | ||
|
||
clean: | ||
rm -f *.o $(APP) | ||
|
||
install: | ||
export PATH=$(DIR):$$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
#ifndef WIN32 | ||
#include <unistd.h> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <netdb.h> | ||
#else | ||
#include <winsock2.h> | ||
#include <ws2tcpip.h> | ||
#include <wspiapi.h> | ||
#endif | ||
#include <iostream> | ||
#include <udt.h> | ||
#include "cc.h" | ||
|
||
using namespace std; | ||
|
||
#ifndef WIN32 | ||
void* monitor(void*); | ||
#else | ||
DWORD WINAPI monitor(LPVOID); | ||
#endif | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
if ((3 != argc) || (0 == atoi(argv[2]))) | ||
{ | ||
cout << "usage: appclient server_ip server_port" << endl; | ||
return 0; | ||
} | ||
|
||
// use this function to initialize the UDT library | ||
UDT::startup(); | ||
|
||
struct addrinfo hints, *local, *peer; | ||
|
||
memset(&hints, 0, sizeof(struct addrinfo)); | ||
|
||
hints.ai_flags = AI_PASSIVE; | ||
hints.ai_family = AF_INET; | ||
hints.ai_socktype = SOCK_STREAM; | ||
//hints.ai_socktype = SOCK_DGRAM; | ||
|
||
if (0 != getaddrinfo(NULL, "9000", &hints, &local)) | ||
{ | ||
cout << "incorrect network address.\n" << endl; | ||
return 0; | ||
} | ||
|
||
UDTSOCKET client = UDT::socket(local->ai_family, local->ai_socktype, local->ai_protocol); | ||
|
||
// UDT Options | ||
//UDT::setsockopt(client, 0, UDT_CC, new CCCFactory<CUDPBlast>, sizeof(CCCFactory<CUDPBlast>)); | ||
//UDT::setsockopt(client, 0, UDT_MSS, new int(9000), sizeof(int)); | ||
//UDT::setsockopt(client, 0, UDT_SNDBUF, new int(10000000), sizeof(int)); | ||
//UDT::setsockopt(client, 0, UDP_SNDBUF, new int(10000000), sizeof(int)); | ||
|
||
// Windows UDP issue | ||
// For better performance, modify HKLM\System\CurrentControlSet\Services\Afd\Parameters\FastSendDatagramThreshold | ||
#ifdef WIN32 | ||
UDT::setsockopt(client, 0, UDT_MSS, new int(1052), sizeof(int)); | ||
#endif | ||
|
||
// for rendezvous connection, enable the code below | ||
/* | ||
UDT::setsockopt(client, 0, UDT_RENDEZVOUS, new bool(true), sizeof(bool)); | ||
if (UDT::ERROR == UDT::bind(client, local->ai_addr, local->ai_addrlen)) | ||
{ | ||
cout << "bind: " << UDT::getlasterror().getErrorMessage() << endl; | ||
return 0; | ||
} | ||
*/ | ||
|
||
freeaddrinfo(local); | ||
|
||
if (0 != getaddrinfo(argv[1], argv[2], &hints, &peer)) | ||
{ | ||
cout << "incorrect server/peer address. " << argv[1] << ":" << argv[2] << endl; | ||
return 0; | ||
} | ||
|
||
// connect to the server, implict bind | ||
if (UDT::ERROR == UDT::connect(client, peer->ai_addr, peer->ai_addrlen)) | ||
{ | ||
cout << "connect: " << UDT::getlasterror().getErrorMessage() << endl; | ||
return 0; | ||
} | ||
|
||
freeaddrinfo(peer); | ||
|
||
// using CC method | ||
//CUDPBlast* cchandle = NULL; | ||
//int temp; | ||
//UDT::getsockopt(client, 0, UDT_CC, &cchandle, &temp); | ||
//if (NULL != cchandle) | ||
// cchandle->setRate(500); | ||
|
||
int size = 100000; | ||
char* data = new char[size]; | ||
|
||
#ifndef WIN32 | ||
pthread_create(new pthread_t, NULL, monitor, &client); | ||
#else | ||
CreateThread(NULL, 0, monitor, &client, 0, NULL); | ||
#endif | ||
|
||
for (int i = 0; i < 1000000; i ++) | ||
{ | ||
int ssize = 0; | ||
int ss; | ||
while (ssize < size) | ||
{ | ||
if (UDT::ERROR == (ss = UDT::send(client, data + ssize, size - ssize, 0))) | ||
{ | ||
cout << "send:" << UDT::getlasterror().getErrorMessage() << endl; | ||
break; | ||
} | ||
|
||
ssize += ss; | ||
} | ||
|
||
if (ssize < size) | ||
break; | ||
} | ||
|
||
UDT::close(client); | ||
|
||
delete [] data; | ||
|
||
// use this function to release the UDT library | ||
UDT::cleanup(); | ||
|
||
return 1; | ||
} | ||
|
||
#ifndef WIN32 | ||
void* monitor(void* s) | ||
#else | ||
DWORD WINAPI monitor(LPVOID s) | ||
#endif | ||
{ | ||
UDTSOCKET u = *(UDTSOCKET*)s; | ||
|
||
UDT::TRACEINFO perf; | ||
|
||
cout << "SendRate(Mb/s)\tRTT(ms)\tCWnd\tPktSndPeriod(us)\tRecvACK\tRecvNAK" << endl; | ||
|
||
while (true) | ||
{ | ||
#ifndef WIN32 | ||
sleep(1); | ||
#else | ||
Sleep(1000); | ||
#endif | ||
|
||
if (UDT::ERROR == UDT::perfmon(u, &perf)) | ||
{ | ||
cout << "perfmon: " << UDT::getlasterror().getErrorMessage() << endl; | ||
break; | ||
} | ||
|
||
cout << perf.mbpsSendRate << "\t\t" | ||
<< perf.msRTT << "\t" | ||
<< perf.pktCongestionWindow << "\t" | ||
<< perf.usPktSndPeriod << "\t\t\t" | ||
<< perf.pktRecvACK << "\t" | ||
<< perf.pktRecvNAK << endl; | ||
} | ||
|
||
#ifndef WIN32 | ||
return NULL; | ||
#else | ||
return 0; | ||
#endif | ||
} |
Oops, something went wrong.