120 likes | 306 Views
TDMA Emulator - logic. The implementation of the logic the emulator mainly based on five classes: Users Connections TDMAEmulator Sniffer/ Sender
E N D
TDMA Emulator - logic The implementation of the logic the emulator mainly based on five classes: • Users • Connections • TDMAEmulator • Sniffer/ Sender • Use Jpcap: Java class package that allows Java applications to capture and/or send packets to the network. Jpcap is based on libpcap/winpcap and Raw Socket API. Therefore, Jpcap is supposed to work on any OS on which libpcap/winpcaphas been implemented
TDMA Emulator – Mode of operation • Mode of operation 1: • The emulator enables connections to it, in order for users (clients/servers) to sign in/out • Activated by the user – the emulator listens to both networks traffic, the sniffer chooses the packets destined to the other network (by inspecting the IP address) and passes them along to the Emulator • The emulator queues them in its buffer • Mode of operation 2: • Emulator removes packets from the buffer in cyclic order, for each fetched packet it transmits it to the appropriate network (sniffer replaces the Ethernet layer according to IP layer) • Each process of fetching and sending users packets from the buffer is limited with configured time slot, whether the user use it (it has packets) or not the configured time slot must pass before proceeding to the next user in the buffer • Buffer size is constant and configurable, a user gets number of entries according to its priority
Users • Manages the list of packets for each user. • The class holds user's information, statistics regarding packets sending and the a list of packets that are to be sent. • User is identified by IP address and the port that the packets are to be sent from.
Connection • Responsible for accepting new members to the system or removing them. • Each user should register before using the system. • The connection listener can reject a connection if the user is already registered or there is no place for additional users. • The listener works till the stopListening function is invoked.
TDMAEmulator • The managing class of the system. • It is responsible for creating connections, initiating sniffers, managing all the users and sending the packets to their destination.
TDMAEmulator (cont.) • The class implement the TDMA algorithm by letting one user at a time to use the entire bandwidth for a defined amount of time. • Each user is given its time slot even if it doesn't have any information to send. • The class holds a queue of users, where for each user it holds a collection of the packets this user wants to send.
TDMAobject: • A basic object that all the projects inherits from it. • Connects/ disconnects from the emulator. HttpClient: • Every instance sends requests to one server. • Reads the data from the server. • Update the results array - the time elapsed from sending a request till all the file received by the client.
Server: • A basic Server object that all the servers inherits from it. • Sends data to client. • The listenToclient method is pure virtual – each type of server implements it differently. HttpServer: • Multithreaded server that listens to client requests. • Sends the data according to the request. • Data is sent according to the servers prio. • (num of slots given by the emulator)
Manager: • The manager initiates the system according to a configuration file. • It manages the client and servers and saves the results.