Skip to content

Commit fc3913d

Browse files
committed
Initial commit of code written so far
1 parent 4461cbc commit fc3913d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+52753
-0
lines changed

VERSION-INFO

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Implements remy, kernel cc (cubic on linux), UDT's TCP aimd implementation and PCC (slightly doubtful and buggy) on a poisson on-off traffic model (currently configures for 5s mean).
2+
3+
For remy and aimd congestion control, it is not a reliable transport. Kernel's and UDT's tcp implementations are naturally reliable. This could cause bias in readings.
4+
5+
It sends it on a real network. It prints command line usage except for cctype, which is assumed to be 'remy' by default (other options are 'kernel', 'tcp' and 'pcc').
6+
7+
Further, the signal type (with loss signal-without slow_rewma, without slow-rewma and aith slow_rewma-without loss signal) are controlled by which memory-xx.hh/memory-xx.cc are included (xx can be 'default,' 'with-loss-signal' and 'without-slow-rewma') are included and also by the appropriate protobufs-xx folder. This are controlled in the options in compile.sh. According to that appropriate binaries (remy, rat-runner, scoring-example) are generated. Binaries generated with these three configurations are already present.
8+
9+
Receivers:
10+
- The receivers for various types of congestion control algorithms are as follows
11+
- 'remy', 'tcp' - receiver (simply echoes back the first few bytes (ie. the header) if the received UDP packet)
12+
- 'kernel' - 'iperf -s' (which is required on both ends, for measuring RTT, use 'tcpdump' followed by 'tcptrace -lr'
13+
- 'pcc' - pcc-receiver
14+
15+
Can be run either on a real network or on mahi-mahi. When running on mahi-mahi, note that the receiver's address is the address of the interface on the outside part of the os (do an ifconfig on a fresh terminal). Everything except the kernel version (which uses iperf) runs over UDP, last time I could not send udp between two GENI nodes, although it should be possible to do so.
16+
17+
PS: sockperf can also be used, just uncomment the apropriate line and comment the iperf line in kernelTCP.hh

ccc.hh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef CCC_HH
2+
#define CCC_HH
3+
4+
#include<iostream>
5+
6+
class CCC
7+
{
8+
public:
9+
CCC() :
10+
_intersend_time( 0 ),
11+
_the_window( 2 ),
12+
_timeout( 0.002 ) {}
13+
14+
virtual ~CCC() {}
15+
public:
16+
virtual void init() {}
17+
virtual void close() {}
18+
virtual void onACK( int ack __attribute((unused)) ) {std::cout<<"Hello!";}
19+
//virtual void onLoss(const int* losslist, const int& size) {} virtual void onTimeout() {}
20+
virtual void onPktSent( int seq_num __attribute((unused)) ) { }
21+
virtual void onTimeout() {}
22+
//virtual void onPktReceived(const CPacket* pkt) {}
23+
//virtual void processCustomMsg(const CPacket& pkt) {}
24+
25+
double get_the_window(){ return _the_window; }
26+
double get_intersend_time(){ return _intersend_time; }
27+
double get_timeout(){ return _timeout; }
28+
29+
protected:
30+
void setRTO(const int& usRTO){ _timeout = usRTO/1000.0;}
31+
32+
double _intersend_time;
33+
double _the_window;
34+
35+
private:
36+
double _timeout;
37+
};
38+
39+
#endif

compile.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
clear
2+
clear
3+
echo Compiling...
4+
5+
OPTIONS="-I./protobufs-default -DREMYTYPE_DEFAULT -I./udt"
6+
7+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT random.o -MD -MP -c -o random.o random.cc
8+
9+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT memory.o -MD -MP -c -o memory.o memory.cc
10+
11+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT memoryrange.o -MD -MP -c -o memoryrange.o memoryrange.cc
12+
13+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT rat.o -MD -MP -c -o rat.o rat.cc
14+
15+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT whisker.o -MD -MP -c -o whisker.o whisker.cc
16+
17+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT whiskertree.o -MD -MP -c -o whiskertree.o whiskertree.cc
18+
19+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT udp-socket.o -MD -MP -c -o udp-socket.o udp-socket.cc
20+
21+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT traffic-generator.o -MD -MP -c -o traffic-generator.o traffic-generator.cc
22+
23+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT ctcp.o -MD -MP -c -o ctcp.o ctcp.cc
24+
25+
#g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT remycc.o -MD -MP -c -o remycc.o remycc.cc
26+
27+
g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -Werror -fno-default-inline -pg -O2 -MT pcc-tcp.o -MD -MP -c -o pcc-tcp.o pcc-tcp.cc
28+
29+
g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT sender.o -MD -MP -c -o sender.o sender.cc
30+
31+
g++ -DHAVE_CONFIG_H -I. $OPTIONS -std=c++11 -pthread -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -MT receiver.o -MD -MP -c -o receiver.o receiver.cc
32+
33+
34+
35+
echo Linking sender...
36+
g++ -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -o sender udp-socket.o ctcp.o pcc-tcp.o traffic-generator.o memoryrange.o memory.o rat.o whisker.o whiskertree.o random.o remycc.o sender.o ./protobufs-default/libremyprotos.a -ljemalloc -lm -pthread -lprotobuf -lpthread -ljemalloc -ludt #-static-libstdc++
37+
#g++ -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -o sender random.o udp-socket.o ctcp.o traffic-generator.o remycc.o sender.o ./protobufs/libremyprotos.a -ljemalloc -lm -pthread -lprotobuf -lpthread -ljemalloc
38+
39+
echo Linking receiver...
40+
#g++ -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -o receiver udp-socket.o ctcp.o memory.o memoryrange.o rat.o whisker.o whiskertree.o random.o receiver.o ./protobufs/libremyprotos.a -ljemalloc -lm -pthread -lprotobuf -lpthread -ljemalloc
41+
g++ -pedantic -Wall -Wextra -Weffc++ -Werror -fno-default-inline -pg -O2 -o receiver random.o udp-socket.o ctcp.o receiver.o -ljemalloc -lm -pthread -lprotobuf -lpthread -ljemalloc

configs.hh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define SCALE_SEND_RECEIVE_EWMA

congctrls.hh

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#include "ccc.hh"
2+
3+
class DefaultCC: public CCC
4+
{
5+
public:
6+
DefaultCC() :
7+
m_issthresh( 83333 ),
8+
m_bSlowStart( true ),
9+
m_iDupACKCount( 0 ),
10+
m_iLastACK( 0 )
11+
{}
12+
13+
void init()
14+
{
15+
m_issthresh = true;
16+
m_bSlowStart = 83333;
17+
18+
_intersend_time = 0.0;
19+
_the_window = 2.0;
20+
21+
//setACKInterval(2);
22+
setRTO(1000000);
23+
}
24+
25+
virtual void onACK(const int& ack)
26+
{
27+
if (ack == m_iLastACK)
28+
{
29+
if (3 == ++ m_iDupACKCount)
30+
DupACKAction();
31+
else if (m_iDupACKCount > 3)
32+
_the_window += 1.0;
33+
else
34+
ACKAction();
35+
}
36+
else
37+
{
38+
if (m_iDupACKCount >= 3)
39+
_the_window = m_issthresh;
40+
41+
m_iLastACK = ack;
42+
m_iDupACKCount = 1;
43+
44+
ACKAction();
45+
}
46+
}
47+
48+
virtual void onTimeout()
49+
{
50+
//m_issthresh = getPerfInfo()->pktFlightSize / 2;
51+
m_issthresh = _the_window / 2;
52+
if (m_issthresh < 2)
53+
m_issthresh = 2;
54+
55+
m_bSlowStart = true;
56+
_the_window = 2.0;
57+
}
58+
59+
protected:
60+
virtual void ACKAction()
61+
{
62+
if (m_bSlowStart)
63+
{
64+
_the_window += 1.0;
65+
66+
if (_the_window >= m_issthresh)
67+
m_bSlowStart = false;
68+
}
69+
else
70+
_the_window += 1.0/_the_window;
71+
}
72+
73+
virtual void DupACKAction()
74+
{
75+
m_bSlowStart = false;
76+
77+
//m_issthresh = getPerfInfo()->pktFlightSize / 2;
78+
m_issthresh = _the_window / 2;
79+
if (m_issthresh < 2)
80+
m_issthresh = 2;
81+
82+
_the_window = m_issthresh + 3;
83+
}
84+
85+
protected:
86+
int m_issthresh;
87+
bool m_bSlowStart;
88+
89+
int m_iDupACKCount;
90+
int m_iLastACK;
91+
};
92+
93+
94+
class CUDPBlast: public CCC
95+
{
96+
public:
97+
CUDPBlast()
98+
{
99+
_intersend_time = 1000000;
100+
_the_window = 83333.0;
101+
}
102+
103+
public:
104+
void setRate(double mbps)
105+
{
106+
//_intersend_time = (m_iMSS * 8.0) / mbps;
107+
_intersend_time = (1500 * 8.0) / mbps;
108+
}
109+
};

ctcp.cc

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*#include <string.h>
2+
#include <stdio.h>
3+
4+
#include "ctcp.hh"
5+
6+
using namespace std;
7+
8+
double current_timestamp( chrono::high_resolution_clock::time_point &start_time_point ){
9+
using namespace chrono;
10+
high_resolution_clock::time_point cur_time_point = high_resolution_clock::now();
11+
return duration_cast<duration<double>>(cur_time_point - start_time_point).count()*1000; //convert to milliseconds, because that is the scale on which the rats have been trained
12+
}
13+
14+
template<class T>
15+
void CTCP<T>::send_data ( double duration, int flow_id, int src_id ){
16+
TCPHeader header, ack_header;
17+
18+
char buf[packet_size];
19+
memset(buf, '-', sizeof(char)*packet_size);
20+
buf[packet_size-1] = '\0';
21+
22+
chrono::high_resolution_clock::time_point start_time_point = chrono::high_resolution_clock::now();
23+
_last_send_time = 0.0;
24+
double cur_time = 0;
25+
int transmitted_bytes = 0;
26+
27+
int seq_num = 0;
28+
_last_send_time = 0.0;
29+
_largest_ack = -1;
30+
_packets_sent = 0;
31+
32+
double delay_sum = 0;
33+
int num_packets_transmitted = 0;
34+
35+
congctrl.init();
36+
37+
while ( cur_time < duration ){
38+
cur_time = current_timestamp( start_time_point );
39+
assert( _packets_sent >= _largest_ack + 1 );
40+
while( ( (_packets_sent < _largest_ack + 1 + congctrl.get_the_window())
41+
and (_last_send_time + congctrl.get_intersend_time() <= cur_time) )
42+
and cur_time < duration ){
43+
44+
header.seq_num = seq_num;
45+
header.flow_id = flow_id;
46+
header.src_id = src_id;
47+
header.sender_timestamp = cur_time;
48+
49+
memcpy(buf, &header, sizeof(TCPHeader));
50+
congctrl.onPktSent( seq_num );
51+
socket.senddata( buf, packet_size, NULL );
52+
53+
cur_time = current_timestamp( start_time_point );
54+
_packets_sent++;
55+
_last_send_time = cur_time;
56+
seq_num += 1;
57+
58+
cout<<"sent"<<congctrl.get_the_window()<<" ";
59+
}
60+
61+
cur_time = current_timestamp( start_time_point );
62+
double timeout = _last_send_time + congctrl.get_timeout(); // everything in milliseconds
63+
if( congctrl.get_the_window() > 0 )
64+
timeout = min( timeout, _last_send_time + congctrl.get_intersend_time() - cur_time );
65+
66+
sockaddr_in other_addr;
67+
if( socket.receivedata( buf, packet_size, timeout, other_addr ) == 0 ) {
68+
cur_time = current_timestamp( start_time_point );
69+
if( cur_time > _last_send_time + congctrl.get_timeout() )
70+
congctrl.onTimeout();
71+
continue;
72+
}
73+
74+
memcpy(&ack_header, buf, sizeof(TCPHeader));
75+
ack_header.seq_num ++; //because the receiver doesn't do that for us yet
76+
77+
if ( ack_header.src_id != src_id || ack_header.flow_id != flow_id ){
78+
if( ack_header.src_id != src_id ){
79+
std::cerr<<"Received incorrect ack for src "<<ack_header.src_id<<" to "<<src_id<<endl;
80+
}
81+
continue;
82+
}
83+
84+
_largest_ack = max(_largest_ack, ack_header.seq_num);
85+
congctrl.onACK(seq_num);
86+
cout<<"acked";
87+
88+
// Track statistics
89+
cur_time = current_timestamp( start_time_point );
90+
delay_sum += cur_time - ack_header.sender_timestamp;
91+
this->tot_delay += cur_time - ack_header.sender_timestamp;
92+
93+
transmitted_bytes += data_size;
94+
this->tot_bytes_transmitted += data_size;
95+
96+
num_packets_transmitted += 1;
97+
this->tot_packets_transmitted += 1;
98+
}
99+
100+
congctrl.close();
101+
102+
cur_time = current_timestamp( start_time_point );
103+
this->tot_time_transmitted += cur_time;
104+
105+
double throughput = transmitted_bytes/( cur_time / 1000.0 );
106+
double delay = (delay_sum / 1000) / num_packets_transmitted;
107+
108+
std::cout<<"\n\nData Successfully Transmitted\n\tThroughput: "<<throughput<<" bytes/sec\n\tAverage Delay: "<<delay<<" sec/packet\n";
109+
110+
double avg_throughput = tot_bytes_transmitted / ( tot_time_transmitted / 1000.0);
111+
double avg_delay = (tot_delay / 1000) / tot_packets_transmitted;
112+
std::cout<<"\n\tAvg. Throughput: "<<avg_throughput<<" bytes/sec\n\tAverage Delay: "<<avg_delay<<" sec/packet\n";
113+
}
114+
115+
template<class T>
116+
void CTCP<T>::listen_for_data ( ){
117+
118+
}*/

0 commit comments

Comments
 (0)