Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Created by https://www.gitignore.io/api/c++
# Edit at https://www.gitignore.io/?templates=c++

### C++ ###
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
cellsim
saturatr
saturatr-m
buffer-setpoint
cellsim-tap
controlled-delay
depend
send1way
# End of http-://www.gitignore.io/api/c++
63 changes: 63 additions & 0 deletions emulate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
trap 'finalize' 2

if [ $# -lt 5 ]; then
echo "Usage : $0 up_trace down_trace lossrate internet_facing_if client_facing_if uplink_log downlink_log"
exit
fi ;

BRIDGE_NAME="br0"
THROUGHPUT_GRAPH_RESOLUTION=100

UP_TRACE="$1"
DOWN_TRACE="$2"
LOSSRATE="$3"
INTERNET_IF="$4"
CLIENT_IF="$5"

UPLOG_SET=false
DOWNLOG_SET=false

if [ -z "$6" ]
then
UPLINK_LOG=""
else
UPLOG_SET=true
UPLINK_LOG="$6"
fi

if [ -z "$7" ]
then
DOWNLINK_LOG=""
else
DOWNLOG_SET=true
DOWNLINK_LOG="$7"
fi


finalize(){
echo "# bringing bridge \"$BRIDGE_NAME\" up"
ifconfig "$BRIDGE_NAME" up

if [ "$UPLOG_SET" = true ]
then
echo "# generating graphs for uplink from log $UPLINK_LOG..."
mm-delay-graph "$UPLINK_LOG" > $(dirname "${UPLINK_LOG}")/delay-graph-up.svg
mm-throughput-graph $THROUGHPUT_GRAPH_RESOLUTION "$UPLINK_LOG" > $(dirname "${UPLINK_LOG}")/throughput-graph-up.svg
fi

if [ "$DOWNLOG_SET" = true ]
then
echo "# generating graphs for downlink from log $DOWNLINK_LOG..."
echo $(dirname "${DOWNLINK_LOG}")/throughput-graph-down.svg
mm-delay-graph "$DOWNLINK_LOG" > $(dirname "${DOWNLINK_LOG}")/delay-graph-down.svg
mm-throughput-graph $THROUGHPUT_GRAPH_RESOLUTION "$DOWNLINK_LOG" > $(dirname "${DOWNLINK_LOG}")/throughput-graph-down.svg
fi
}

ifconfig "$BRIDGE_NAME" down
sender/cellsim-setup.sh "$CLIENT_IF" "$INTERNET_IF"
sender/cellsim "$UP_TRACE" "$DOWN_TRACE" "$LOSSRATE" "$INTERNET_IF" "$CLIENT_IF" $UPLINK_LOG $DOWNLINK_LOG

#finalize

2 changes: 1 addition & 1 deletion sender/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ objects = socket.o hist.o rate-estimate.o payload.o history.o delay-servo.o acke
executables = send1way buffer-setpoint controlled-delay saturatr cellsim cellsim-tap

CXX = g++
CXXFLAGS = -g -O3 -std=c++0x -ffast-math -pedantic -Werror -Wall -Wextra -Weffc++ -fno-default-inline -pipe -D_FILE_OFFSET_BITS=64 -D_XOPEN_SOURCE=500 -D_GNU_SOURCE
CXXFLAGS = -g -O3 -std=c++0x -ffast-math -pedantic -Wall -Wextra -Weffc++ -fno-default-inline -pipe -D_FILE_OFFSET_BITS=64 -D_XOPEN_SOURCE=500 -D_GNU_SOURCE
LIBS = -lm -lrt

all: $(executables)
Expand Down
5 changes: 3 additions & 2 deletions sender/acker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "acker.hh"
#include "payload.hh"
#include "saturateservo.hh"
#include <inttypes.h>

Acker::Acker( const char *s_name, FILE* log_file_handle, const Socket & s_listen, const Socket & s_send, const Socket::Address & s_remote, const bool s_server, const int s_ack_id )
: _name( s_name ),
Expand Down Expand Up @@ -50,7 +51,7 @@ void Acker::recv( void )
outgoing.ack_number = contents->sequence_number;
_send.send( Socket::Packet( _remote, outgoing.str( sizeof( SatPayload ) ) ) );

fprintf( _log_file,"%s DATA RECEIVED senderid=%d, seq=%d, send_time=%ld, recv_time=%ld, 1delay=%.4f \n",
fprintf( _log_file,"%s DATA RECEIVED senderid=%" PRId32 ", seq=%" PRId32 ", send_time=%" PRId64 ", recv_time=%" PRId64 ", 1delay=%.4f \n",
_name.c_str(), _server ? contents->sender_id : _ack_id, contents->sequence_number, contents->sent_timestamp, contents->recv_timestamp,oneway );
}

Expand Down Expand Up @@ -83,7 +84,7 @@ void Acker::tick( void )
uint64_t Acker::wait_time( void ) const
{
if ( _server ) {
return 1000000000;
return (uint64_t) 1000000000;
}

int diff = _next_ping_time - Socket::timestamp();
Expand Down
2 changes: 1 addition & 1 deletion sender/acker.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private:

uint64_t _next_ping_time;

static const int _ping_interval = 1000000000;
static const uint32_t _ping_interval = 1000000000;

int _foreign_id;

Expand Down
3 changes: 2 additions & 1 deletion sender/delay-servo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <inttypes.h>

#include "delay-servo.hh"

Expand Down Expand Up @@ -37,7 +38,7 @@ void DelayServo::recv( void )
_hist.packet_received( *contents );
_packets_received++;
double loss_rate = (double) _hist.num_lost() / (double) _packets_sent;
printf( "%s seq = %d delay = %f recvrate = %f queueest = %f outstanding = %d Mbps = %f lost = %.5f%% arrivemilli = %ld\n",
printf( "%s seq = %" PRId32 " delay = %f recvrate = %f queueest = %f outstanding = %" PRId32 " Mbps = %f lost = %.5f%% arrivemilli = %" PRId64 "\n",
_name.c_str(),
contents->sequence_number,
(double) (contents->recv_timestamp - contents->sent_timestamp) / 1.0e9,
Expand Down
9 changes: 4 additions & 5 deletions sender/packetsocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string.h>
#include <arpa/inet.h>
#include <assert.h>
#include <inttypes.h>

#include "packetsocket.hh"

Expand Down Expand Up @@ -81,15 +82,13 @@ vector< string > PacketSocket::recv_raw( void )
perror( "recvfrom" );
exit( 1 );
} else if ( bytes_read > BUFFER_SIZE ) {
fprintf( stderr, "Received size (%ld) too long (> %d)!\n",
fprintf( stderr, "Received size (%" PRId64 ") too long (> %" PRId32 ")!\n",
bytes_read, BUFFER_SIZE );
exit( 1 );
}

if ( source_address_len != 18 ) {
fprintf( stderr, "address length = %d\n",
source_address_len );
perror( "recvfrom (unexpected address length)" );
if ( source_address_len != sizeof( source_address ) ) {
perror( "recvfrom (unexpected address length" );
exit( 1 );
}

Expand Down
11 changes: 7 additions & 4 deletions sender/saturateservo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "socket.hh"
#include "payload.hh"
#include "acker.hh"
#include <inttypes.h>

const int MTU = 1500 - 28; // MTU - (sizeof(IP4HEADER) + (sizeof(UDPHEADER))

SaturateServo::SaturateServo( const char * s_name,
FILE* log_file,
Expand Down Expand Up @@ -65,7 +68,7 @@ void SaturateServo::recv( void )
int64_t rtt_ns = contents->recv_timestamp - contents->sent_timestamp;
double rtt = rtt_ns / 1.e9;

fprintf( _log_file, "%s ACK RECEIVED senderid=%d, seq=%d, send_time=%ld, recv_time=%ld, rtt=%.4f, %d => ",
fprintf( _log_file, "%s ACK RECEIVED senderid=%" PRId32 ", seq=%" PRId32 ", send_time=%" PRId64 ", recv_time=%" PRId64 ", rtt=%.4f, %" PRId32 " => ",
_name.c_str(),_server ? _foreign_id : contents->sender_id , contents->ack_number, contents->sent_timestamp, contents->recv_timestamp, (double)rtt, _window );
/* increase-decrease rules */

Expand All @@ -86,7 +89,7 @@ uint64_t SaturateServo::wait_time( void ) const
int num_outstanding = _packets_sent - _max_ack_id - 1;

if ( _remote == UNKNOWN ) {
return 1000000000;
return (uint64_t) 1000000000;
}

if ( num_outstanding < _window ) {
Expand Down Expand Up @@ -119,7 +122,7 @@ void SaturateServo::tick( void )
outgoing.recv_timestamp = 0;
outgoing.sender_id = _send_id;

_send.send( Socket::Packet( _remote, outgoing.str( 1400 ) ) );
_send.send( Socket::Packet( _remote, outgoing.str( MTU ) ) );

/*
printf( "%s pid=%d DATA SENT %d senderid=%d seq=%d, send_time=%ld, recv_time=%ld\n",
Expand All @@ -139,7 +142,7 @@ void SaturateServo::tick( void )
outgoing.recv_timestamp = 0;
outgoing.sender_id = _send_id;

_send.send( Socket::Packet( _remote, outgoing.str( 1400 ) ) );
_send.send( Socket::Packet( _remote, outgoing.str( MTU ) ) );

/*
printf( "%s pid=%d DATA SENT senderid=%d seq=%d, send_time=%ld, recv_time=%ld\n",
Expand Down
9 changes: 5 additions & 4 deletions sender/saturatr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <assert.h>
#include <sys/types.h>
#include <unistd.h>
#include <inttypes.h>

#include "acker.hh"
#include "saturateservo.hh"
Expand Down Expand Up @@ -54,7 +55,7 @@ int main( int argc, char *argv[] )

FILE* log_file;
char log_file_name[50];
sprintf(log_file_name,"%s-%d-%d",server ? "server" : "client",(int)(ts/1e9),sender_id);
sprintf(log_file_name,"%s-%" PRId32 "-%" PRId32 "",server ? "server" : "client",(int)(ts/1e9),sender_id);
log_file=fopen(log_file_name,"w");

SaturateServo saturatr( "OUTGOING", log_file, feedback_socket, data_socket, remote_data_address, server, sender_id );
Expand All @@ -81,11 +82,11 @@ int main( int argc, char *argv[] )
uint64_t next_transmission_delay = std::min( saturatr.wait_time(), acker.wait_time() );

if ( next_transmission_delay == 0 ) {
fprintf( stderr, "ZERO %ld %ld\n", saturatr.wait_time(), acker.wait_time() );
fprintf( stderr, "ZERO %" PRId64 " %" PRId64 "\n", saturatr.wait_time(), acker.wait_time() );
}

timeout.tv_sec = next_transmission_delay / 1000000000;
timeout.tv_nsec = next_transmission_delay % 1000000000;
timeout.tv_sec = next_transmission_delay / (uint64_t)1000000000;
timeout.tv_nsec = next_transmission_delay % (uint64_t)1000000000;
ppoll( poll_fds, 2, &timeout, NULL );

if ( poll_fds[ 0 ].revents & POLLIN ) {
Expand Down
2 changes: 1 addition & 1 deletion sender/socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ uint64_t Socket::timestamp( void )
exit( 1 );
}

uint64_t ret = ts.tv_sec * 1000000000 + ts.tv_nsec;
uint64_t ret = ts.tv_sec * (uint64_t) 1000000000 + ts.tv_nsec;
return ret;
}
2 changes: 1 addition & 1 deletion sender/socket.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public:
{}

Packet( const Address &s_addr, const std::string &s_payload, const struct timespec &ts )
: addr( s_addr ), payload( s_payload ), timestamp( ts.tv_sec * 1000000000 + ts.tv_nsec )
: addr( s_addr ), payload( s_payload ), timestamp( ts.tv_sec * (uint64_t) 1000000000 + ts.tv_nsec )
{}
};

Expand Down