@@ -5,6 +5,7 @@ namespace VirtualClient.Actions.NetworkPerformance
55{
66 using System ;
77 using System . Collections . Generic ;
8+ using System . Linq ;
89 using Microsoft . Extensions . DependencyInjection ;
910 using VirtualClient . Contracts ;
1011
@@ -30,6 +31,113 @@ public NTttcpServerExecutor(VirtualClientComponent component)
3031 public NTttcpServerExecutor ( IServiceCollection dependencies , IDictionary < string , IConvertible > parameters )
3132 : base ( dependencies , parameters )
3233 {
34+ this . IntializeLinuxServerCommandline ( ) ;
35+ this . IntializeWindowsServerCommandline ( ) ;
36+ }
37+
38+ private void IntializeWindowsServerCommandline ( )
39+ {
40+ string serverIPAddress = this . GetLayoutClientInstances ( ClientRole . Server ) . First ( ) . IPAddress ;
41+ if ( ! this . CommandLineWindowsServer . Contains ( "-r" ) && ! this . CommandLineWindowsServer . Contains ( "-s" ) )
42+ {
43+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + " -r" ;
44+ }
45+
46+ if ( ! this . CommandLineWindowsServer . Contains ( "-t" ) && this . TestDuration != null )
47+ {
48+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ " -t { this . TestDuration . TotalSeconds } ";
49+ }
50+
51+ if ( ! this . CommandLineWindowsServer . Contains ( "-l" ) && this . BufferSizeServer != null )
52+ {
53+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ " -l { this . BufferSizeServer } ";
54+ }
55+
56+ if ( ! this . CommandLineWindowsServer . Contains ( "-p" ) )
57+ {
58+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ " -p { this . Port } ";
59+ }
60+
61+ if ( ! this . CommandLineWindowsServer . Contains ( "-xml" ) && this . ResultsPath != null )
62+ {
63+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ " -xml { this . ResultsPath } ";
64+ }
65+
66+ if ( ! this . CommandLineWindowsServer . Contains ( "-u" ) && this . Protocol != null )
67+ {
68+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ "{ ( this . Protocol . ToLowerInvariant ( ) == "udp" ? " -u" : string . Empty ) } ";
69+ }
70+
71+ if ( ! this . CommandLineWindowsServer . Contains ( "-ns" ) && this . NoSyncEnabled != null )
72+ {
73+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ "{ ( this . NoSyncEnabled == true ? " -ns" : string . Empty ) } ";
74+ }
75+
76+ if ( ! this . CommandLineWindowsServer . Contains ( "-m" ) )
77+ {
78+ this . CommandLineWindowsServer = this . CommandLineWindowsServer + $ " -m { this . ThreadCount } ,*,{ serverIPAddress } ";
79+ }
80+ }
81+
82+ private void IntializeLinuxServerCommandline ( )
83+ {
84+ string serverIPAddress = this . GetLayoutClientInstances ( ClientRole . Server ) . First ( ) . IPAddress ;
85+ string clientIPAddress = this . GetLayoutClientInstances ( ClientRole . Client ) . First ( ) . IPAddress ;
86+
87+ if ( ! this . CommandLineLinuxClient . Contains ( "-r" ) && ! this . CommandLineLinuxServer . Contains ( "-s" ) )
88+ {
89+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + " -r" ;
90+ }
91+
92+ if ( ! this . CommandLineLinuxServer . Contains ( "-t" ) && this . TestDuration != null )
93+ {
94+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ " -t { this . TestDuration . TotalSeconds } ";
95+ }
96+
97+ if ( ! this . CommandLineLinuxServer . Contains ( "-l" ) && this . BufferSizeClient != null )
98+ {
99+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ " -l { this . BufferSizeServer } ";
100+ }
101+
102+ if ( ! this . CommandLineWindowsServer . Contains ( "-p" ) )
103+ {
104+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ " -p { this . Port } ";
105+ }
106+
107+ if ( ! this . CommandLineLinuxServer . Contains ( "-xml" ) && this . ResultsPath != null )
108+ {
109+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ " -xml { this . ResultsPath } ";
110+ }
111+
112+ if ( ! this . CommandLineLinuxServer . Contains ( "-u" ) && this . Protocol != null )
113+ {
114+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ "{ ( this . Protocol . ToLowerInvariant ( ) == "udp" ? " -u" : string . Empty ) } ";
115+ }
116+
117+ if ( ! this . CommandLineLinuxServer . Contains ( "-ns" ) && this . NoSyncEnabled != null )
118+ {
119+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ "{ ( this . NoSyncEnabled == true ? " -ns" : string . Empty ) } ";
120+ }
121+
122+ if ( ! this . CommandLineLinuxServer . Contains ( "-m" ) )
123+ {
124+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ " -m { this . ThreadCount } ,*,{ serverIPAddress } ";
125+ }
126+
127+ if ( ! this . CommandLineLinuxServer . Contains ( "-M" ) )
128+ {
129+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ "{ ( ( this . ReceiverMultiClientMode == true ) ? " -M" : string . Empty ) } ";
130+ }
131+
132+ if ( ! this . CommandLineLinuxServer . Contains ( "-N" ) && this . NoSyncEnabled != null )
133+ {
134+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ "{ ( this . NoSyncEnabled == true ? " -N" : string . Empty ) } ";
135+ }
136+
137+ if ( ! this . CommandLineLinuxServer . Contains ( "--show-dev-interrupts" ) && this . DevInterruptsDifferentiator != null )
138+ {
139+ this . CommandLineLinuxServer = this . CommandLineLinuxServer + $ "{ ( ( this . DevInterruptsDifferentiator != null ) ? $ " --show-dev-interrupts { this . DevInterruptsDifferentiator } " : string . Empty ) } ". Trim ( ) ;
140+ }
33141 }
34142 }
35143}
0 commit comments