Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multi-routing the '.Net' Gigax, Kevin Edward Torres, Francisco Javier

Similar presentations


Presentation on theme: "Multi-routing the '.Net' Gigax, Kevin Edward Torres, Francisco Javier"— Presentation transcript:

1 Multi-routing the '.Net' Gigax, Kevin Edward Torres, Francisco Javier
CS522 – Computer Communications 5/4/2019

2 Project Goals The Goal of this project is to enable multi-routing in a Microsoft .NET environment using the C# language. The projects initial phase is to implement multi-routing using routes that are hard-coded into the servers. In the future, the project plans to implement multi-routing to any server running the .NET framework. 5/4/2019

3 Description The project calculates the bandwidth from a source server through n different routes to a destination server. The project will be expanded to route through multiple servers in the future. 5/4/2019

4 Function Call: getBandwidth Finds the fastest route from S1
to D1 using specific servers R1 S1 R2 D1 Rn 5/4/2019

5 Function Call: getBandwidth2 Finds the fastest route from S1
to D1 using x amount of servers R12 R13 R11 S1 D1 R21 R22 Rn1 Rnn 5/4/2019

6 Implementation The software design uses a software created packet of x bytes. This packet is transmitted across the network using a socket connection as an ICMP packet. The software times the amount of time for the packet to be transmitted and for a reply to be received. This timing is the estimated bandwidth of that route. The routers are hard-coded into the servers as character arrays. Each router in the array is tested for its bandwidth abilities. 5/4/2019

7 Implementation Function Calls
getBandwidth(sourceServer, destinationServer, routingServer) For each proxy server available, call getBandwidth function Once an acceptable bandwidth is found exit call and use this proxy server findBandwidth(sourceServer, destinationServer) Execute a packet send and receive to the source and to the destination Time the packet’s total round trip time 5/4/2019

8 Drawbacks The primary drawbacks of the project are as follows:
Congesting the network: if we continual send out queries for bandwidth, we start to cause serious network congestion Estimated Bandwidth: available bandwidth is a large topic and we cannot insure that this is the best way to find the bandwidth of a connection 5/4/2019

9 Performance Analysis Waiting for multiple queries highly degrades performance: We need to implement multi-threaded queries to solve this Getting the absolute best bandwidth can also degrade performance We can set an acceptable bandwidth value and stop the queries once we find a bandwidth that is >= to this value 5/4/2019

10 Socket connections in .NET
How to create both ends of a TCP/IP socket connection between two or more applications? 5/4/2019

11 Sequence of events 5/4/2019

12 Why use sockets in .NET? .NET uses sockets in many instances such as Web services and remoting, but here the low level stuff is done for us. However, when interfacing with other non .NET system, sockets are a necessary and simple communication method. 5/4/2019

13 Why use Stream Sockets? Stream Sockets (TCP)
Session (or connection) based service Guarantees that packets are sent without errors, sent (and received) in sequence and without duplication Unlimited data size in packets Communication between server and client occurs through streams The base class for this communication is NetworkStream . Streams can be used for binary, text, and string data or serialized objects. Datagram sockets are supported by class System.Net.Sockets.UDPClient 5/4/2019

14 Scenario for Stream Sockets
Sockets are created by both client and server, Server specifies a port number Server may customize aspects of connections (wait queue, etc) Client specifies the internet address and port in creating its socket. In C#, when the client creates its TCPClient instance, a connection is established with the TCPListener 5/4/2019

15 Scenario… (continued)
Server listens for arriving requests ( AcceptSocket or AcceptTcpClient method) to establish a session (connection) with a client. If no connections are pending, the server blocks . If one or more clients are waiting, they are queued and in turn, the server creates a new thread (stay tuned) to service each client. The parent thread re-issues the accept to service another client on the same socket. The client and server identify input and output streams for passing information according to a protocol they both agree to. The input and output streams perform the work of the application. The client and server must both close the connection to allow resources to be used in another connection. 5/4/2019

16 .NET sample socket Client and Server
5/4/2019

17 Socket Server: using System.Net.Sockets; using System;
/// <summary> /// Example program showing simple TCP socket connections in C#.NET. /// TCPSocketServer is the socket server. /// </summary> public class TCPSocketServer { public static void Main (string [] args) { TcpListener tcpl = new TcpListener(9090); tcpl.Start(); Console.Write("TCPSocketServer up and waiting for connections on 9090"); Socket sock = tcpl.AcceptSocket(); string msg = "Hello Client"; Byte[] msgBytes = System.Text.Encoding.ASCII.GetBytes(msg); sock.Send(msgBytes, msgBytes.Length, SocketFlags.DontRoute); tcpl.Stop(); sock.Close(); } 5/4/2019

18 Socket Client: using System; using System.IO;
using System.Windows.Forms; using System.Net.Sockets; /// <summary> /// Example program showing simple TCP socket connections in C#.NET. /// TCPSocketClient is the socket client. /// </summary> public class TCPSocketClient { public static void Main (string[] args) { TcpClient tcpc = new TcpClient("localhost", 9090); Stream tcpStream = tcpc.GetStream(); StreamReader reader = new StreamReader(tcpStream, System.Text.Encoding.ASCII); MessageBox.Show(reader.ReadLine()); reader.Close(); tcpc.Close(); } 5/4/2019

19 Thread Concept Why threads? 5/4/2019

20 Threaded Socket Servers
How does a threaded socket server, for protocols such as http or ftp, allow multiple clients to be simultaneously connected to the server? 5/4/2019

21 A thread is a single sequential flow of control within a program
What is a Thread? A thread is a single sequential flow of control within a program A multi-threaded program Two or more threads seemingly active simultaneously All within the overhead of a single executing C# program A single starting point and ending point for all threads in the program and for the program itself. 5/4/2019

22 Other Threading capabilities:
Thread.Join() method - used to wait for another thread to complete. Sleep -- suspend for a number of milliseconds Thread.Sleep(2000) ; Thread States ; Thread includes a property to query a state. Priorities - .NET supports 1 to 10 lowest to highest priorities Volatile modifier for attributes (don't cache) multi-CPU one RAM. 5/4/2019

23 Synchronization. What is a Shared Object ?
Multiple threads of single program may access or change the same object. When should access to shared objects be controlled ? When multiple threads only read the object - no synchronization . If any thread modifies the object - synchronization is necessary. Why must access be controlled when some thread changes the object? consider: stack.push(item) , for example multiple actions are necessary to achieve consistent state, for example: (1) increment stack pointer; (2) place the new item into the collection using the stack pointer. If one thread is interrupted after step 1, but before step 2 , then another thread may see an inconsistent stack state (visualize a = stack.top() ). Monitor - a lock used to protect a critical section of code Each thread calls Enter() to get the lock before push(item) Each thread calls Exit() to release the lock after push(item) completes 5/4/2019

24 C# .NET Monitors A Monitor protects access to the Object
See System.Threading.Monitor class All Monitor methods are static Basic Monitor methods to lock and unlock an object void Enter(object) and bool TryEnter(object, TimeSpan) lock the object. A thread may be recursive (call multiple Enter's before first Exit) void Exit(object) indicate the calling thread is ready to unlock the object 5/4/2019

25 Issues with Multi-Threaded programs:
Synchronization - "I can't go past this statement until another thread reaches that statement" Concurrency , parallelism and asynchronous behavior Deadlock Threads with shared data (objects) Scheduling and blocking operations, such as input and output Underlying support for implementing threads Performance 5/4/2019

26 Overview 5/4/2019

27 Process Creation in C# To run outside software using C#, we create a PROCESS object using the System.Diagnostics library To find the bandwidth, we create an outside process for ftp and we then time a download for a file to find the estimated bandwidth 5/4/2019

28 Process Creation Process p = new Process(); //Create a process obj
p.EnableRaisingEvents=false; //Disable events from interrupting //Set the directory to find the batch file for ftp’ing p.StartInfo.WorkingDirectory="c:/Inetpub/ftproot/kegigax"; //Set arguments: -s: reads a file of commands for ftp p.StartInfo.Arguments="-s:ftp_batch.txt" + server; //Designate the program to execute p.StartInfo.FileName="ftp"; start = System.Environment.TickCount; //Start the timing p.Start(); //Start the process p.WaitForExit(); //Wait for process finish //Calculate time for ftp call bandwidth = System.Environment.TickCount - start; p.Close(); //Close the process 5/4/2019

29 Conclusions Our project progress has reached being able to calculate a path from a source to destination server using socket connections when the routing servers are hard-coded Our continued efforts involve creating actual packets and headers to relay through multiple paths to increase throughput and researching algorithms that locate ‘good’ paths through the internet to a destination server 5/4/2019

30 What is next? Find a proper way to calculate the bandwidth.
A specific design of threads, server, clients, frame’s headers. Design a bidirectional communication, in order to implement a multimedia (voice and sound) application. 5/4/2019

31 References VisualC Ideas: Using Sockets in C#
Stream Sockets in C#.NET The Code Project Programing with threads in C# O'Reilly Network: Multithreading with C# C# Primer – A Practical Approach Stanley B. Lippman, Addison-Wesley, 2002 Pearson Education C# Essentials Ben Albahari, Peter Drayton & Brad Merril, 2002 O’Reilly 5/4/2019


Download ppt "Multi-routing the '.Net' Gigax, Kevin Edward Torres, Francisco Javier"

Similar presentations


Ads by Google