Upload
nirmala-last
View
841
Download
3
Tags:
Embed Size (px)
Citation preview
Virtual Network Emulation Tools
A Master’s ProjectPresented by
Florence M Fowler
November 15, 2000
Proposal Specifications
Emulate the link/physical layers of the TCP/IP protocol stack
Take packets handed off from the student-designed TCP/UDP/IP layers and deliver them to the desired destination
Facilitate the setting up of student subnets and the routing of packets within a subnet and from one subnet to another
Create an environment that is as realistic as possible in which the students can work
Huh? How’s this going to work?
vnet link layer
Socket Library
UNIX domain sockets
IP
UDP TCP
Socket layer
Client Application
vnet link layer
Socket Library
IP
UDP TCP
Socket layer
Server Application
Real UDP/IP ProtocolStack
Real UDP/IP ProtocolStack
UNIX domain sockets
Justification
Writing
“IP”
Writing a
Socket Library
Working in
Groups
Writing
“UDP”
Writing
Applications
Interfacing the
Protocol layers
Writing a
Socket Layer
Using
UNIX Domain
Sockets
Exploring
Routing
Protocols
Problems to Solve:How should hosts and subnets be identified?How will you find out what a host’s identifier is?How will you connect a vnet identifier to an IP address?How should port numbers be advertised?What kind of design will allow for subnets to be connected?How should a packet be constructed?
How should network characteristics be implemented:
-reliability? -delay?How should asynchronous I/O be handled?What structures are needed? The end product needs to be a self-contained module with easy-to-use interface.Remember—try to create a realistic environment!
Some Solutions:vnet host and subnet addresses are modeled on IP host and subnet addresses (even broadcast)
vnet functions like gethostbyname(), etc. are provided to supply vnet names and addresses and convert from one to another
port numbers are assigned by subnet and included in the configuration file
host “interfaces” are configured to allow subnets to be connected
the real ip and udp headers are filled in using htons() and htonl() when appropriate
random number generation combined with an algorithm and checked against the subnet reliability determine if a packet is corrupted or lost
select() is used to simulate delay
threads and condition variables are used to handle asynchronous input
structures are used for interfaces, “arp cache”, IP queue and interface statistics
What Structures are Needed?
net 10.10.1.0 255.255.255.0 5056 55 90.0 hydra3b alpha1 10.10.1.1 hydra3c alpha2 10.10.1.6 default 10.10.1.1 net 10.10.2.0 255.255.255.0 5067 45 95.0 hydra3b beta1 10.10.2.1 hydra2c beta2 10.10.2.7 default 10.10.2.7 default 10.10.2.1 net 10.10.3.0 255.255.255.0 5078 45 95.0 hydra2c bravo1 10.10.3.1 hydra2b bravo2 10.10.3.8 default 10.10.3.1 net 10.10.4.0 255.255.255.0 5089 45 95.0 hydra3b gamma1 10.10.4.1 hydra4b gamma2 10.10.4.5 default 10.10.4.1 route 10.10.5.0 10.10.4.5 net 10.10.5.0 255.255.255.0 5090 45 95.0 hydra4b delta1 10.10.5.1 hydra4c delta2 10.10.5.4 hydra4d delta3 10.10.5.6 default 10.10.5.1 trace tracefile
Interface Structure one interface structure is “configured” for each subnet a host is on
Stats structure
each interface structure contains a Stats structure to hold statistics for that interface
Arp structure
an arp structure is set up for each host in the configuration file
IP queue all packets received are placed in the “ip” queue
Configuration file:
Designing and Connecting up Subnets
10.10.5.6
10.10.5.4
10.10.5.1
hydra4c
hydra4b
hydra4d
Designing and Connecting up Subnets
10.10.1.6
10.10.1.1 10.10.4.5
10.10.5.6
10.10.5.4
10.10.4.1 10.10.5.1
hydra4c
hydra4b
hydra3chydra4d
10.10.1.7
hydra3d
hydra3b
Designing and Connecting up Subnets
10.10.3.8
10.10.1.6
10.10.3.1
10.10.1.1 10.10.4.5
10.10.5.6
10.10.5.4
10.10.4.1
10.10.2.1
10.10.2.7
10.10.5.1
hydra3b
hydra2b
hydra2c
hydra4c
hydra4b
hydra3chydra4d
10.10.1.7
hydra3d
vnet InterfaceStudents call 3 primary, easy-to-use functions to access vnet:
int vn_SystemInit(char *ConfigFile)
int vn_SendPkt(void *pkt, int pktsize, struct in_addr nexthop,
int interface)
int vn_RecvPkt(void *buf, int bufsize)
4 additional functions are provided to be used as needed:
int vn_gethostname(char *myname, int len)
struct in_addr vn_gethostbyname(char *vnetname)
int vn_gethostbyaddr(struct in_addr vnetaddr, char *vnetname,
int len)
int vn_Stats(int *ifaces, Stats *buf)
vnet Interface
int vn_SystemInit(char *ConfigFile)
- Opens and reads the configuration file configuring the “interfaces” for a host and creating an “arp cache” to cross reference the vnet name & address with the IP name & address for each host in the file
- Mallocs and initializes the “IP” queue
- Creates a thread for each “interface” to wait for packets
- If the configuration file has a trace entry, the tracefile is opened and a pcap file header is written
vnet Interfaceint vn_SendPkt(void *pkt, int pktsize, struct in_addr nexthop, int interface)
- takes a packet, packet size, next-hop address and outgoing interface from the ip layer
- checks for a valid interface and packet size
- appends an “ethernet” header to the packet
- uses the “arp cache” to look up the “physical address” (ip address) of the next hop
- calls vn_Corrupt() to simulate corruption, loss and delay of packets as specified in the configuration file
- sends the packet out the specified “interface” to the next hop address
- if TRACE is enabled, a pcap pkthdr and the packet are written to the tracefile
vnet Interface
int vn_RecvPkt(void *buf, int bufsize)
- blocks until receiving a signal that a packet has been placed in the “IP” queue
- copies “bufsize” characters into “buf” both of which are provided by the caller
- returns the number of characters actually received
- packets are dropped by vnet if “IP” does not call this function in a timely fashion and the queue fills up
vnet Interfaceint vn_gethostname(char *myname, int len)
- matches one of the IP names found in the “arp cache” with the name returned from the gethostname() (ex. hydra1a)
struct in_addr vn_gethostbyname(char *myname)
- matches “myname” (ex. delta1) with one of the vnet names found in the “arp cache” and returns the vnet address as a struct in_addr
Int vn_gethostbyaddr(struct in_addr nexthop, char *nhopname, int len)
- matches “nexthop” with a vnet address found in the “arp cache” and returns the vnet name
Int vn_Stats(int *ifaces, Stats *buf)
- stores the number of interfaces for this host into “ifaces” and stores the statistics for all interfaces in the list of Stats structures passed to it by the calling function
Packet Corruption and Loss10.10.1.6
host1
10.10.1.1
10.10.2.1 10.10.2.7
host 3
Reliability: 85%
Reliability: 50%
Reliability Test
host 1 and host 3 are each sending 5700 1000 byte packets to host 2
while host 2 is sending 5700 1000 byte packets to host 1
host 2
Host Corrupted Lost Reliability /host Reliability/network
host 1 2016 573 54.5
host 2 1961 564 55.7 55.1
host 3 562 152 87.4 87.4
*test was performed in the hydra lab with host1=hydra5f, host2=hydra5c, host3=hydra5d
PerformancePerformance tests were conducted on 2 hydra machines sending and receiving 1000 byte packets.
Repetitions time kilobits/sec
echo_client, echo_server 100 0.063 25427.103
(using UDP and sockets) 500 0.320 24965.593
1000 0.629 25447.761
5000 3.301 24235.140
vnet_client, vnet_server 100 0.082 19436.324
(using the vnet interface 500 0.390 20529.771
functions) 1000 0.814 19664.451
5000 4.017 19916.342
Error HandlingReworked error handling routines from software by Brian Davis 3/13/95
Modeled on the actual system error reporting and uses:
An structure containing a vnet error number and a system error number
set_error(int, int) which allows the setting of either or both members of the structure where an error occurs
can return 0 on success and –1 or an error code on failure
vnet_perror() which may be called to print vnet and system error messages
#defined errors are coupled with error messages that the student can expand as needed
The Student Gets:VNET.README containing a full description of the interface, error reporting, a detailed description of the configuration file and a tutorial to use with the sample executable
sample executable composed of an “ip” layer implementing static routing and compiled in with the vnet library
vnet_link.a the vnet library routines to be compiled in with ip, udp, tcp and a socket layer to produce a “vnet kernel”
vnet_ip.h containing pertinent #defines and #includes, the Stats structure and function prototypes for the interface
sample configuration filesecho client and server code both for internet sockets and UNIX domain sockets
vnet_error.h and vnet_error.c for use and possible expansion
Additional Components Completed:
“ip” layer which includes the ip header checksum and static routing
“udp” layer using PCBs
“socket layer “ using socket buffers
“socket library “ including Socket(), Bind(), Sendto() and Recvfrom()
vnet trace capability produces files tcpdump can read
Future Enhancements?
vnet link layer: * Optimization of vnet code
* Multicast * Arp requests
vnet ip layer * ICMP messaging * Active routing
add a vnet tcp layerexpand the application socket library
I Learned:How the Internet protocol layers actually work by closely examining the code and explanations contained in Richard Stevens books, “TCP/IP Vol 1” and “TCP/IP Vol 2”
How threads and semaphores work
How to use threads and buffers to create a realistic network simulation
Some of the intricacies involved in various routing protocols
Just a glimpse of how much there is to know