VRNET

Introduction

VRNET is a network emulator that allows programmers to write network protocols and algorithms and test them in a realistic environment. The emulator takes a cluster of computers connected to each other by some real network and arranges them into a virtual network with whatever topology the programmer wants and emulates packet loss, packet corruption, and dynamic traffic across all of its virtual links.

How VRNET emulates packet corruption and loss
VRNET uses a percentage to emulate packet corruption and loss. For each subnet the user defines a transmission reliability between 0.0 and 100.0. The transmission reliability represents the long run percentage of packets that will not be dropped or corrupted. Each time a packet is sent, a random number between 0.0 and 100.0 is chosen and if the random number is greater than the transmission reliability, the packet will either be corrupted or dropped.

How VRNET emulates link failure
VRNET uses a combination of a percentage and normal distribution to emulate link failures. For each subnet the user defines a link reliability, mean link failure period, link failure period standard deviation, and a change rate. The change rate is in seconds and a period is equal to the change rate. The link reliability represents the percent chance the subnet link will fail. When a user configures the subnet with a number less than 100.0, at the specified change rate the emulator will choose a random number between 0.0 and 100.0. If the random number is greater than the link reliability, then the link will go down and a random number of periods the link will remain down is chosen according to the mean link failure period and link failure period standard deviation. The mean link failure period and link failure standard deviation define a normal distribution. The larger the standard deviation the higher the probability the number of periods will vary farther from its mean value. After the random number of periods expires the link will become active again and the process will start all over again. If a link goes down, then all packets sent across that link will be dropped.

How VRNET emulates dynamic traffic
VRNET uses a normal distribution to emulate dynamic traffic. For each subnet the user defines a mean delay, delay standard deviation, and a change rate. The delay is in milliseconds and the change rate is in seconds. The mean delay and delay standard deviation define a normal distribution. The larger the standard deviation the higher the probability the delay will vary farther from its mean value. At the specified change rate a new delay will be chosen according to the normal distribution and all packets leaving a host along that subnet will be physically delayed that many milliseconds.

Compiling Instructions

To compile, use the following commands:

gcc -c vrnet_code.c
		gcc -o executable vrnet_code.o vrnet.a -lpthread -lsocket -lnsl -lm

Function Specification

To use VRNET, the programmer has the following 14 functions. All of their prototypes are defined in vrnet.h. The file vrnet.h should be included in all programs using VRNET.

Name vn_SystemInit
Synopsis int vn_SystemInit(char *config_file, int print_config_info)
Description The vn_SystemInit function initializes the VRNET emulator. This function must be called before any other VRNET function for the emulator to work properly.
Arguments
config_file String containing the name of the VRNET configuration file to use to initialize the system (see the configuration file specification below)
print_config_info Set equal to 1 if you want vn_SystemInit to print out a summary of the configured interfaces for the host and all the hosts defined in the configuration file
Set equal to 0 if you do not want vn_SystemInit to print any summary information
Return Values
If an error occurs, a non-zero value will be returned (see vrnet_error.h for the definitions of all the error codes)
0 is returned upon successful initialization of the VRNET emulator

Name vnIPSendPacket
Synopsis int vnIPSendPacket(void *pkt, int pktsize, struct in_addr NextHop, int interface)
Description The vnIPSendPacket function sends a packet to another VRNET host. The destination must be reachable on the passed interface. If the broadcast address is passed as the destination the packet will be delivered to all hosts on the subnet except for the sending host (ex. for BROADCAST to subnet 10.10.1.0, NextHop=10.10.1.255)
Arguments
pkt Pointer to the packet to send
pktsize Size of the packet to send
NextHop VRNET address of the destination of the packet
interface Interface number to send the packet out across
Return Values
0 if the function is successful
If an error occurs, a non-zero value will be returned (see vrnet_error.h for the definitions of all the error codes)

Name vnIPRecvPacket
Synopsis int vnIPRecvPacket(void *pkt, int max_pktsize, int *interface)
Description The vnIPRecvPacket function copies the next packet in the VRNET host’s receive queue into the supplied buffer. If no packets are available the function will block. If the receive queue is full, then packets will be droped
Arguments
pkt Buffer to place the packet
max_pktsize Maximum number of bytes the buffer can hold
interface Pointer to an integer to place the interface number the packet came in across
Return Values Number of bytes actually received

Name vnIPCfgIface
Synopsis int vnIPCfgIface(struct in_addr address, struct in_addr subnet, int interface, int type)
Description The vnIPCfgIface function configures the given interface with the IP address and subnet passed to it. The type variable chooses which IP address space of the interface to use. THere are currently three tyoes available (PRIMARY, SECONDARY, TERTIARY) .
Arguments
address IP address to associate with given interface.
subnetSubnet mask to associate with given interface.
interfaceThe interface to configure
typeThe type as described above to assign to the given interface
Return Valuesreturns 0 on success

Name vn_GetNumInterfaces
Synopsis int vn_GetNumInterfaces()
Description The vn_GetNumInterfaces function returns the number of interfaces connected to the current VRNET host
Arguments none
Return Values Number of interfaces off the current VRNET host

Name vrnet_perror
Synopsis void vrnet_perror()
Description The vrnet_perror function produces an error message to the screen describing the last error encountered during a call to a VRNET function
Arguments none
Return Values none

Name vnIPGetIface
Synopsis int vnIPGetIface(struct in_addr address)
Description This function returns the interface for the supplied interface
Arguments
addressThe address of the interface you wish to retrieve
Return Values 

Name vnIPGetAddr
Synopsis struct in_addr vnIPGetAddr(int interface, int type)
Description The vnIPGetAddr function returns the IP address of the VRNET host on the supplied interface
Arguments
interface Interface number to return the IP address of
type Type variable chooses which IP address space of the interface to use. [PRIMARY SECONDARY TERTIARY]
Return Values
non-zero address on success
zero address on error

Configuration file

To configure VRNET, you will need to supply a configuration file that defines the topology of the network and the settings to use for each subnet. The following is an example VRNET configuration file:

                #tag identifier subport simport trans link  mean_link std_link mean_delay std_delay change_rate
                queue 100
                network net1 6100 6101 100.0 100.0 10 2.0 100 30.0 5
                cetus26 alpha1 000afc000102
                cetus27 alpha2 000afc000103
                network net2 6200 6201 100.0 100.0 10 2.0 100 30.0 5
                cetus27 beta1 000afc000104
                cetus28 beta2 000afc000105
                network net3 6300 6301 100.0 100.0 10 2.0 100 30.0 5
                cetus28 gamma1 000afc000106
                cetus29 gamma2 000afc000107
                network net4 6400 6401 100.0 100.0 10 2.0 100 30.0 5
                cetus29 delta1 000afc000108
                cetus30 delta2 000afc000109
                network net5 6500 6501 100.0 100.0 10 2.0 100 30.0 5
                cetus30 epsilon1 000afc00010a
                cetus26 epsilon2 000afc00010b
                trace blah

		

At the top of the configuration file you can specify the send and receive queue sizes, with the line queue [SIZE]. The send queue size is the number of packets per interface that can be waiting for transit. The receive queue size is the number of packets received from other hosts that can be waiting for processing. This is optional and must be defined before any subnets. If you do not define it, then it will be set to its default value. After defining the optional queue size, the rest of the configuration file is basically a series of subnet specifications. Each subnet specification must start with the following line:

network <identifier> <subnet port #> <simulator port #> <transmission reliability> <link reliability> <mean link down period> <link down period std> <mean delay> <delay std> <change rate>

Note: “network” is a literal indicating a new subnet

<identifier> the subnet's vrnet name
<subnet port #> UDP port number the emulator will use to send packets to hosts on the subnet
<simulator port #> UDP port number the emulator will use to send control messages to other hosts on the subnet
<transmission reliability> floating point number between 0.0 and 100.0 indicating the network transmission reliability. This is the percent chance that any given packet will be successfully sent without corruption or dropped
<link reliability> floating point number between 0.0 and 100.0 indicating the reliability of the network link. This is the percent chance that the link will fail
<mean link down period> integer number that is the average number of periods the link will remain down if a link failure occurs (Note: 1 period = <change rate>)
<link down period std> floating point number that is the standard deviation of the link down period (Note: 1 period = <change rate>)
<mean delay> integer number that is the average delay in milliseconds along the subnet
<delay std> floating point number that is the standard deviation of the delay along the subnet
<change rate> integer number that is the number of seconds the delay along the subnet will be changed

After defining the subnet, the successive lines are either the hosts on the subnet, routing information, or a trace file to use. The trace file definition should be the last entry in the subnet and the other entries can occur in any order. Note that the trace file and routing information is optional. All that VRNET requires is for you to list the hosts attached to the subnet.

To define a host attached to the subnet use the following line:

<realname> <vrnetname> <vrnetmac>

<realname> the host's actual name
<vrnetname> the VRNET name for this host
<vrnetmac> the vrnet mac address for this host on this subnet (This can be any string of alpha numeric characters of length <= MACSIZE as defined in the vrnet.h file)

(ex. cetus2 alpha1 000afc000102)

Finally to define a trace file for VRNET to create use the following line: (this is optional)

trace <filename>

Note: "trace" is a literal indicating that all packets sent and received on this subnet should be written to a tracefile

<filename> filename appended with the host name that can be read by tcpdump

*this should be the last entry in the file

Return to 594 lab home page
created by: Peter Oelgoetz    modified by:Charles Walters