diff --git a/skyscraper8.sln.DotSettings.user b/skyscraper8.sln.DotSettings.user
index 6aa6dc7..48f0a70 100644
--- a/skyscraper8.sln.DotSettings.user
+++ b/skyscraper8.sln.DotSettings.user
@@ -27,6 +27,7 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
diff --git a/skyscraper8/QuickAndDirtySatIpClient.cs b/skyscraper8/QuickAndDirtySatIpClient.cs
index deaf70c..33829f2 100644
--- a/skyscraper8/QuickAndDirtySatIpClient.cs
+++ b/skyscraper8/QuickAndDirtySatIpClient.cs
@@ -21,7 +21,6 @@ namespace skyscraper8
internal class QuickAndDirtySatIpClient
{
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
- private const bool ENABLE_TS_WRITER = true;
public QuickAndDirtySatIpClient(string[] args)
{
@@ -73,6 +72,7 @@ namespace skyscraper8
return;
}
symbolRate = Int32.Parse(args[6]);
+ _modeOfOperation = SatIpOldconfigModeOfOperation.RunSkyscraper;
}
public void SetPlayoutMode(string[] args)
@@ -83,7 +83,7 @@ namespace skyscraper8
return;
}
destinationPort = int.Parse(args[7]);
- playoutMode = true;
+ _modeOfOperation = SatIpOldconfigModeOfOperation.MulticastPlayout;
if (args.Length == 10)
{
if (args[8].ToLowerInvariant().Equals("multicast"))
@@ -161,7 +161,7 @@ namespace skyscraper8
dataStorage = new InMemoryScraperStorage();
if (objectStorage == null)
objectStorage = new FilesystemStorage(new DirectoryInfo("."));
- if (!playoutMode)
+ if (_modeOfOperation == SatIpOldconfigModeOfOperation.RunSkyscraper)
{
context = new SkyscraperContext(new TsContext(), dataStorage, objectStorage);
context.EnableTimeout = true;
@@ -173,47 +173,71 @@ namespace skyscraper8
DateTime lastTimestamp = DateTime.Now;
bool initMessagePrinted = false;
- while (true)
+ bool runLoop = true;
+ while (runLoop)
{
- if (playoutMode)
+ switch (_modeOfOperation)
{
- Thread.Sleep(1000);
- Keepalive(url);
- if (!initMessagePrinted)
- {
- logger.InfoFormat("Began SAT>IP playout to port {0}", destinationPort);
- initMessagePrinted = true;
- }
- }
- else
- {
- if (packetQueue.Count >= 1)
- {
- byte[] buffer;
- lock (packetQueue)
- {
- buffer = packetQueue.Dequeue();
- }
- context.IngestSinglePacket(buffer);
+ case SatIpOldconfigModeOfOperation.MulticastPlayout:
+ Thread.Sleep(1000);
+ Keepalive(url);
if (!initMessagePrinted)
{
- logger.InfoFormat("Began SAT>IP stream.");
+ if (destinationPort == 0)
+ {
+ destinationPort = oldconfig.DestinationPort;
+ }
+ logger.InfoFormat("Began SAT>IP playout to port {0}", destinationPort);
initMessagePrinted = true;
}
- }
- else
- {
- Thread.Sleep(1);
- }
-
- if (context.IsAbortConditionMet())
break;
+ case SatIpOldconfigModeOfOperation.RecordSample:
+ TimeSpan duration = DateTime.Now - lastTimestamp;
+ if (duration.TotalSeconds > oldconfig.SampleLength)
+ {
+ runLoop = false;
+ break;
+ }
+ else
+ {
+ Thread.Sleep(100);
+ }
+ break;
+ case SatIpOldconfigModeOfOperation.RunSkyscraper:
+ if (packetQueue.Count >= 1)
+ {
+ byte[] buffer;
+ lock (packetQueue)
+ {
+ buffer = packetQueue.Dequeue();
+ }
+ context.IngestSinglePacket(buffer);
+ if (!initMessagePrinted)
+ {
+ logger.InfoFormat("Began SAT>IP stream.");
+ initMessagePrinted = true;
+ }
+ }
+ else
+ {
+ Thread.Sleep(1);
+ }
- if (DateTime.Now.Second != lastTimestamp.Second)
- {
- Keepalive(url);
- lastTimestamp = DateTime.Now;
- }
+ if (context.IsAbortConditionMet())
+ {
+ runLoop = false;
+ break;
+ }
+
+ if (DateTime.Now.Second != lastTimestamp.Second)
+ {
+ Keepalive(url);
+ lastTimestamp = DateTime.Now;
+ }
+
+ break;
+ default:
+ throw new NotImplementedException(_modeOfOperation.ToString());
}
}
@@ -252,12 +276,14 @@ namespace skyscraper8
private void DumpPacket(byte[] buffer)
{
- if (!ENABLE_TS_WRITER)
+ if (_modeOfOperation != SatIpOldconfigModeOfOperation.RecordSample)
return;
if (fs == null)
{
string fname = String.Format("{0}.ts", DateTime.Now.Ticks);
+ FileInfo fi = new FileInfo(fname);
+ logger.InfoFormat("Writing Sample to: {0}", fi.FullName);
fs = File.OpenWrite(fname);
}
@@ -267,7 +293,7 @@ namespace skyscraper8
private int rtcps;
private IPAddress destinationIp;
private int destinationPort;
- private bool playoutMode;
+ private SatIpOldconfigModeOfOperation _modeOfOperation;
private bool multicastMode;
private readonly SatIpOldconfig oldconfig;
@@ -291,10 +317,10 @@ namespace skyscraper8
this.symbolRate = args.SymbolRate;
//Playout mode
- this.destinationPort = args.DestinationPort;
- this.playoutMode = true;
+ this.destinationPort = _modeOfOperation == SatIpOldconfigModeOfOperation.MulticastPlayout ? args.DestinationPort : 0;
+ this._modeOfOperation = args.ModeOfOperation;
this.destinationIp = IPAddress.Parse(args.DestinationIp);
- this.multicastMode = true;
+ this.multicastMode = (_modeOfOperation == SatIpOldconfigModeOfOperation.MulticastPlayout);
}
diff --git a/skyscraper8/Skyscraper/Net/Pcap/PcapIpTrafficHandler.cs b/skyscraper8/Skyscraper/Net/Pcap/PcapIpTrafficHandler.cs
index 080673b..4aa29bd 100644
--- a/skyscraper8/Skyscraper/Net/Pcap/PcapIpTrafficHandler.cs
+++ b/skyscraper8/Skyscraper/Net/Pcap/PcapIpTrafficHandler.cs
@@ -70,7 +70,7 @@ namespace skyscraper8.Skyscraper.Net.Pcap
EnsureOutputdirExists();
}
- if (pcapWritersLlc[network] == null)
+ if (!pcapWritersLlc.ContainsKey(network))
{
string fname = String.Format("{0:X4},llc,{1}.pcap", network, DateTime.Now.Ticks);
if (outputDirectory != null)
diff --git a/skyscraper8/Skyscraper/SatIpOldconfig.cs b/skyscraper8/Skyscraper/SatIpOldconfig.cs
index 1484be3..4912f62 100644
--- a/skyscraper8/Skyscraper/SatIpOldconfig.cs
+++ b/skyscraper8/Skyscraper/SatIpOldconfig.cs
@@ -24,6 +24,8 @@ public class SatIpOldconfig
public byte MisSelection{ get; private set; }
public string DestinationIp{ get; private set; }
public ushort DestinationPort{ get; private set; }
+ public SatIpOldconfigModeOfOperation ModeOfOperation { get; private set; }
+ public int SampleLength { get; private set; }
public void Run()
{
@@ -46,7 +48,8 @@ public class SatIpOldconfig
MisSelection = ini.ReadValue(INI_CATEGORY, "misSelector", (byte)1);
DestinationIp = ini.ReadValue(INI_CATEGORY, "destinationIp", "239.192.0.1");
DestinationPort = ini.ReadValue(INI_CATEGORY, "destinationPort", (ushort)6969);
-
+ ModeOfOperation = Enum.Parse(ini.ReadValue(INI_CATEGORY, "modeOfOperation", SatIpOldconfigModeOfOperation.MulticastPlayout.ToString()));
+ SampleLength = ini.ReadValue(INI_CATEGORY, "sampleLength", 60);
ConfigOption ipOption = new ConfigOption("ip", "The IP of the SAT>IP server or \"auto\"", ConfigType.ValidatedString, ServerIp);
ipOption.Validator = validateIpTuple;
@@ -96,23 +99,42 @@ public class SatIpOldconfig
PlsValue = Int32.Parse(configEngine.PromptUser(plsValueOption));
}
- ConfigOption misEnabledOption = new ConfigOption("misEnabled", "Tune for Multi Input Stream?", ConfigType.Bool, "false");
- EnableMis = Boolean.Parse(configEngine.PromptUser(misEnabledOption));
- if (EnableMis)
+ if (!ForceBbframeOutput && !ForceIqOutput)
{
- ConfigOption misSelectorOptions = new ConfigOption("misValue", "Multi Input Stream Selection? (0-255)", ConfigType.ValidatedString, MisSelection.ToString());
- misSelectorOptions.Validator = byteValidator;
- MisSelection = Byte.Parse(configEngine.PromptUser(misSelectorOptions));
+ ConfigOption misEnabledOption = new ConfigOption("misEnabled", "Tune for Multi Input Stream?", ConfigType.Bool, "false");
+ EnableMis = Boolean.Parse(configEngine.PromptUser(misEnabledOption));
+ if (EnableMis)
+ {
+ ConfigOption misSelectorOptions = new ConfigOption("misValue", "Multi Input Stream Selection? (0-255)", ConfigType.ValidatedString, MisSelection.ToString());
+ misSelectorOptions.Validator = byteValidator;
+ MisSelection = Byte.Parse(configEngine.PromptUser(misSelectorOptions));
+ }
}
}
- ConfigOption destIpOption = new ConfigOption("destinationIp", "SAT>IP Multicast destination IP address?",ConfigType.ValidatedString, DestinationIp);
- destIpOption.Validator = serverIpValidatorTuple;
- DestinationIp = configEngine.PromptUser(destIpOption);
+ ConfigOption modeOfOperation = new ConfigOption("modeOfOperation", "Mode of Operation?", ConfigType.Choice, ModeOfOperation.ToString());
+ modeOfOperation.Choices = new List(Enum.GetNames());
+ ModeOfOperation = Enum.Parse(configEngine.PromptUser(modeOfOperation));
- ConfigOption destPortOption = new ConfigOption("destinationPort", "SAT>IP Multicast destination Port?", ConfigType.ValidatedString, DestinationPort.ToString());
- destPortOption.Validator = destinationTypeValidatorTuple;
- DestinationPort = ushort.Parse(configEngine.PromptUser(destPortOption));
+ switch (ModeOfOperation)
+ {
+ case SatIpOldconfigModeOfOperation.RunSkyscraper:
+ break;
+ case SatIpOldconfigModeOfOperation.RecordSample:
+ ConfigOption sampleLengthOption = new ConfigOption("sampleLength", "Sample Length in seconds?", ConfigType.ValidatedString, "60");
+ sampleLengthOption.Validator = frequencyValid;
+ SampleLength = int.Parse(configEngine.PromptUser(sampleLengthOption));
+ break;
+ case SatIpOldconfigModeOfOperation.MulticastPlayout:
+ ConfigOption destIpOption = new ConfigOption("destinationIp", "SAT>IP Multicast destination IP address?",ConfigType.ValidatedString, DestinationIp);
+ destIpOption.Validator = serverIpValidatorTuple;
+ DestinationIp = configEngine.PromptUser(destIpOption);
+
+ ConfigOption destPortOption = new ConfigOption("destinationPort", "SAT>IP Multicast destination Port?", ConfigType.ValidatedString, DestinationPort.ToString());
+ destPortOption.Validator = destinationTypeValidatorTuple;
+ DestinationPort = ushort.Parse(configEngine.PromptUser(destPortOption));
+ break;
+ }
ini.WriteValue(INI_CATEGORY, "ip", ServerIp);
ini.WriteValue(INI_CATEGORY, "diseqc", Diseqc);
@@ -129,6 +151,8 @@ public class SatIpOldconfig
ini.WriteValue(INI_CATEGORY, "misSelector", MisSelection);
ini.WriteValue(INI_CATEGORY, "destinationIp", DestinationIp);
ini.WriteValue(INI_CATEGORY, "destinationPort", DestinationPort);
+ ini.WriteValue(INI_CATEGORY, "modeOfOperation", ModeOfOperation.ToString());
+ ini.WriteValue(INI_CATEGORY, "sampleLength", SampleLength);
pluginManager.SaveConfiguration();
Console.WriteLine("Settings saved.");
diff --git a/skyscraper8/Skyscraper/SatIpOldconfigModeOfOperation.cs b/skyscraper8/Skyscraper/SatIpOldconfigModeOfOperation.cs
new file mode 100644
index 0000000..e1b3058
--- /dev/null
+++ b/skyscraper8/Skyscraper/SatIpOldconfigModeOfOperation.cs
@@ -0,0 +1,8 @@
+namespace skyscraper8.Skyscraper;
+
+public enum SatIpOldconfigModeOfOperation : int
+{
+ RunSkyscraper = 0,
+ RecordSample = 1,
+ MulticastPlayout = 2
+}
\ No newline at end of file
diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs
index 7c429f3..bb7f2c8 100644
--- a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs
+++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs
@@ -3242,6 +3242,10 @@ namespace skyscraper5.Skyscraper.Scraper
if (dsap == 0xff || ssap == 0xff)
{
ushort llcLength = llcStream.ReadUInt16BE();
+ if (llcLength > llcStream.Length)
+ {
+ return;
+ }
if (llcLength == etherType)
{
//TEST or XID PDU, likely unneeded.