// tcp_sim.h by Brett Tjaden #include #include #include // Set the constant DEBUG to 0 if you don't want to see every message // sent/received on the network (i.e. only the summary statistics will // be printed at the end of the simulation). Set DEBUG to a non-zero // value to see all the gory details during the simulation. #define DEBUG 1 // The constant MAX_SEGMENT_SIZE defines the maximum number of bytes // that can fit in a network message. It should be at least one if you // want any data to get through. #define MAX_SEGMENT_SIZE 1 // The TIMEOUT values represent how many ticks each host will wait for // an acknowledgement of a packet it sent. If an ack doesn't arrive in // time the sender assumes the packet was lost and retransmits it. #define TIMEOUT_FOR_A 6 #define TIMEOUT_FOR_B 6 // The DELAY values specify how many ticks it takes for a packet to // get from A to B and vice versa. #define DELAY_FROM_A_TO_B 2 #define DELAY_FROM_B_TO_A 3 // Below are the values that specify how likely a message sent by A or // B is to get lost by the network. Values between 0 and 1 are // reasonable. A value of zero for a certain direction means that // messages are never lost in that direction, a value of 0.25 means // that about 25% of messages will be lost, 0.5 means that about 50% // of messages will be lost, etc. #define CHANCE_MESSAGE_FROM_A_IS_LOST 0.20 #define CHANCE_MESSAGE_FROM_B_IS_LOST 0.20 // These are the actual messages that the two sides are sending to // each other (in large or small pieces depending on the value of // MAX_SEGMENT_SIZE). #define A_MESSAGE "We hold these truths to be self-evident, that all men are created equal" #define B_MESSAGE "I prefer freedom with danger to slavery with ease."